Xyce  6.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
N_TIA_NoTimeIntegration.C
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 // Copyright Notice
3 //
4 // Copyright 2002 Sandia Corporation. Under the terms
5 // of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S.
6 // Government retains certain rights in this software.
7 //
8 // Xyce(TM) Parallel Electrical Simulator
9 // Copyright (C) 2002-2014 Sandia Corporation
10 //
11 // This program is free software: you can redistribute it and/or modify
12 // it under the terms of the GNU General Public License as published by
13 // the Free Software Foundation, either version 3 of the License, or
14 // (at your option) any later version.
15 //
16 // This program is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // GNU General Public License for more details.
20 //
21 // You should have received a copy of the GNU General Public License
22 // along with this program. If not, see <http://www.gnu.org/licenses/>.
23 //-----------------------------------------------------------------------------
24 
25 //-----------------------------------------------------------------------------
26 // Filename : $RCSfile: N_TIA_NoTimeIntegration.C,v $
27 //
28 // Purpose : This file contains the functions which define the
29 // time integration methods classes.
30 //
31 // Special Notes :
32 //
33 // Creator : Eric Keiter
34 //
35 // Creation Date : 7/21/00
36 //
37 // Revision Information:
38 // ---------------------
39 //
40 // Revision Number: $Revision: 1.43 $
41 //
42 // Revision Date : $Date: 2014/02/24 23:49:27 $
43 //
44 // Current Owner : $Author: tvrusso $
45 //-----------------------------------------------------------------------------
46 
47 #include <Xyce_config.h>
48 
49 
50 // ---------- Standard Includes ----------
51 #include <N_UTL_Misc.h>
52 
53 #ifdef HAVE_IOSTREAM
54 #include <iostream>
55 #else
56 #include <iostream.h>
57 #endif
58 
59 // ---------- Xyce Includes ----------
62 #include <N_TIA_StepErrorControl.h>
63 #include <N_TIA_DataStore.h>
64 #include <N_TIA_TIAParams.h>
65 #include <N_TIA_TwoLevelError.h>
66 #include <N_ERH_ErrorMgr.h>
67 
68 #include <N_LAS_Vector.h>
69 #include <N_LAS_Matrix.h>
70 #include <N_LAS_System.h>
71 
72 //Need Epetra Stuff for now, since directly manipulating Epetra Objs for
73 //obtainJacobian. This will be abstracted later
74 #include <Epetra_Import.h>
75 #include <Epetra_CrsMatrix.h>
76 #include <Epetra_Map.h>
77 
78 //-----------------------------------------------------------------------------
79 // Function : N_TIA_NoTimeIntegration::N_TIA_NoTimeIntegration
80 // Purpose : constructor
81 // Special Notes :
82 // Scope : public
83 // Creator : Buddy Watts, SNL
84 // Creation Date : 6/01/00
85 //-----------------------------------------------------------------------------
87  (N_TIA_TIAParams & tiaP,
88  N_TIA_StepErrorControl & secTmp,
89  N_TIA_DataStore & dsTmp)
90 
91  : N_TIA_TimeIntegrationMethod(tiaP,secTmp,dsTmp)
92 {
93  leadingCoeff = 1.0;
94  alphas = -1.0;
95  return;
96 }
97 
98 //-----------------------------------------------------------------------------
99 // Function : N_TIA_NoTimeIntegration::~N_TIA_NoTimeIntegration
100 // Purpose : destructor
101 // Special Notes :
102 // Scope : public
103 // Creator : Buddy Watts, SNL
104 // Creation Date : 6/01/00
105 //-----------------------------------------------------------------------------
107 
108 
109 //-----------------------------------------------------------------------------
110 // Function : N_TIA_NoTimeIntegration::obtainCorrectorDeriv
111 // Purpose : Evaluate the Corrector Derivative Formula
112 // Special Notes : For "no integration" the derivatives should always be zero.
113 // Scope : public
114 // Creator : Eric Keiter, SNL
115 // Creation Date : 01/10/01
116 //-----------------------------------------------------------------------------
118 {
119  ds.nextSolutionDerivPtr->putScalar(0.0);
120  ds.nextStateDerivPtr->putScalar(0.0);
121  ds.nextStoreLeadCurrQCompDerivPtr->putScalar(0.0);
122 }
123 
124 
125 //-----------------------------------------------------------------------------
126 // Function : N_TIA_NoTimeIntegration::obtainResidual
127 //
128 // Purpose : This function returns the residual for the steady state
129 // case.
130 //
131 // Special Notes : For "no integration" the derivatives should always be zero,
132 // so don't add in the dqdt term.
133 //
134 // This function is only called in the new-DAE case.
135 //
136 // Scope : public
137 // Creator : Eric Keiter, SNL
138 // Creation Date : 03/09/04
139 //-----------------------------------------------------------------------------
141 {
142  ds.RHSVectorPtr->linearCombo
143  (0.0,*ds.RHSVectorPtr,+1.0,*ds.daeFVectorPtr);
144 
145  // since the nonlinear solver is expecting a -f, scale by -1.0:
146  ds.RHSVectorPtr->scale(-1.0);
147 
148  // if voltage limiting is on, add it in:
149  if (ds.limiterFlag)
150  {
151  (ds.RHSVectorPtr)->daxpy(
152  *(ds.RHSVectorPtr), +1.0, *(ds.dFdxdVpVectorPtr));
153  }
154 }
155 
156 //-----------------------------------------------------------------------------
157 // Function : N_TIA_NoTimeIntegration::obtainJacobian
158 //
159 // Purpose : Returns the full Jacobian matrix for the steady state
160 // case.
161 //
162 // Special Notes : For "no integration" the derivatives should always be zero.
163 // However, to prevent singular matrices, the dQdt term is
164 // added in anyway, with an assumed very large time step.
165 //
166 // There may be a better way to handle this - the assumed
167 // large time step leads to a very small alpha/dt, which
168 // could (maybe?) have an adverse effect on the matrix
169 // conditioning.
170 //
171 // The singular matrix problem will happen for the case of
172 // capacitors in serial. Any voltage node which is *only*
173 // connected to capacitors will not really be part of the
174 // system of equations. Ideally nodes like this would just
175 // be removed from the system altogether. No current is
176 // passing through them, and they are really just floating
177 // in space.
178 //
179 // For the time being, however, what we do is put some
180 // bogus C*alpha/dt terms into the Jacobian. If dt is
181 // large, then the C*alpha/dt is very small, and doesn't
182 // significantly change any Jacobian entries, except for
183 // zero entries.
184 //
185 // This function is only called in the new-DAE case.
186 //
187 // Scope : public
188 // Creator : Eric Keiter, SNL
189 // Creation Date : 03/09/04
190 //-----------------------------------------------------------------------------
192 {
193  N_LAS_Matrix & dQdx = *(ds.dQdxMatrixPtr);
194  N_LAS_Matrix & dFdx = *(ds.dFdxMatrixPtr);
195  N_LAS_Matrix & Jac = *(ds.JMatrixPtr);
196 
197  Jac.linearCombo( 1.0e-20, dQdx, 1.0, dFdx );
198 }
199 
200 //-----------------------------------------------------------------------------
201 // Function : N_TIA_NoTimeIntegration::applyJacobian
202 //
203 // Purpose : Applies the Jacobian operator for the steady state
204 // case.
205 //
206 // Special Notes :
207 // This function is only called in the new-DAE HB (matrix-free) case.
208 //
209 // Scope : public
210 // Creator : Todd Coffey, Ting Mei
211 // Creation Date : 07/29/08
212 //-----------------------------------------------------------------------------
213 void N_TIA_NoTimeIntegration::applyJacobian (const N_LAS_Vector& input, N_LAS_Vector& result)
214 {
215  N_LAS_Vector & dQdxV = *(ds.dQdxVecVectorPtr);
216  N_LAS_Vector & dFdxV = *(ds.dFdxVecVectorPtr);
217  result.linearCombo( 1.0e-20, dQdxV, 1.0, dFdxV );
218 }
219 
220 //-----------------------------------------------------------------------------
221 // Function : N_TIA_NoTimeIntegration::getInitialQnorm
222 // Purpose : Needed by 2-level solves.
223 // Special Notes :
224 // Scope : public
225 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
226 // Creation Date : 03/18/07
227 //-----------------------------------------------------------------------------
229 {
230  tle.q1HistorySum = 0.0;
231 }
232 
233 //-----------------------------------------------------------------------------
234 // Function : N_TIA_NoTimeIntegration::setupTwoLevelError
235 // Purpose : Needed by 2-level solves.
236 // Special Notes :
237 // Scope : public
238 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
239 // Creation Date : 03/15/07
240 //-----------------------------------------------------------------------------
242 {
243  tle.xErrorSum = 0.0;
244  tle.qErrorSum = 0.0;
245  tle.xErrorSum_m1 = 0.0;
246  tle.xErrorSum_m2 = 0.0;
247  tle.innerSize = ds.globalLength ();
248 }
249