Xyce  6.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
N_TIA_MPDEInterface.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_MPDEInterface.C,v $
27 // Purpose : This file contains the functions which define the time
28 // integration interface for the MPDE classes.
29 // Special Notes :
30 // Creator : Todd S. Coffey, 9214
31 // Creation Date : 03/25/04
32 //
33 // Revision Information:
34 // ---------------------
35 // Revision Number: $Revision: 1.31 $
36 // Revision Date : $Date: 2014/02/24 23:49:27 $
37 // Current Owner : $Author: tvrusso $
38 //-----------------------------------------------------------------------------
39 
40 #include <Xyce_config.h>
41 
42 
43 // ---------- Standard Includes ----------
44 
45 #include <iostream>
46 
47 // ---------- Xyce Includes ----------
48 
49 #include <N_TIA_MPDEInterface.h>
50 #include <N_TIA_TimeIntInfo.h>
51 #include <N_TIA_TwoLevelError.h>
52 
53 //-----------------------------------------------------------------------------
54 // Function : N_TIA_MPDEInterface::N_TIA_MPDEInterface
55 // Purpose : constructor
56 // Special Notes :
57 // Scope : public
58 // Creator : Todd S. Coffey, 9214
59 // Creation Date : 03/25/04
60 //-----------------------------------------------------------------------------
62  : anaManagerPtr_(NULL),
63  tiaParams_(tp),
64  dsPtr_(NULL)
65 {
66 }
67 
68 //-----------------------------------------------------------------------------
69 // Function : N_TIA_MPDEInterface::~N_TIA_MPDEInterface
70 // Purpose : destructor
71 // Special Notes :
72 // Scope : public
73 // Creator : Todd S. Coffey, 9214
74 // Creation Date : 03/25/04
75 //-----------------------------------------------------------------------------
77 {
78 }
79 
80 //-----------------------------------------------------------------------------
81 // Function : N_TIA_MPDEInterface::registerTIAParams
82 // Purpose :
83 // Special Notes :
84 // Scope : public
85 // Creator : Todd S. Coffey, 9214
86 // Creation Date : 03/25/04
87 //-----------------------------------------------------------------------------
89 
90 {
91  tiaParams_ = tiaParams_tmp;
92  if (anaManagerPtr_)
93  {
95  }
96 
97  return true;
98 }
99 
100 //-----------------------------------------------------------------------------
101 // Function : N_TIA_MPDEInterface::registerTIADataStore
102 // Purpose :
103 // Special Notes :
104 // Scope : public
105 // Creator : Todd S. Coffey, 9214
106 // Creation Date : 03/25/04
107 //-----------------------------------------------------------------------------
109 
110 {
111  dsPtr_ = ds_tmp;
112  return true;
113 }
114 
115 //-----------------------------------------------------------------------------
116 // Function : N_TIA_MPDEInterface::registerTIAControl
117 // Purpose :
118 // Special Notes :
119 // Scope : public
120 // Creator : Todd S. Coffey, 9214
121 // Creation Date : 03/25/04
122 //-----------------------------------------------------------------------------
124 
125 {
126  anaManagerPtr_ = anaManager_tmp;
127  return true;
128 }
129 
130 //-----------------------------------------------------------------------------
131 // Function : N_TIA_MPDEInterface::registerTIAStepErrorControl
132 // Purpose :
133 // Special Notes :
134 // Scope : public
135 // Creator : Todd S. Coffey, 1414
136 // Creation Date : 10/04/05
137 //-----------------------------------------------------------------------------
139 
140 {
141  tiaSecPtr_ = tiaSec_tmp;
142  return true;
143 }
144 
145 //-----------------------------------------------------------------------------
146 // Function : N_TIA_MPDEInterface::setInitialCondition
147 // Purpose : Method to specify transient initial condition
148 // Special Notes :
149 // Scope : public
150 // Creator : Todd S. Coffey, 9214
151 // Creation Date : 03/25/04
152 //-----------------------------------------------------------------------------
153 bool N_TIA_MPDEInterface::setInitialCondition(N_LAS_Vector * initialConditionPtr)
154 {
155  *(dsPtr_->nextSolutionPtr) = *(initialConditionPtr);
156  return true;
157 }
158 
159 //-----------------------------------------------------------------------------
160 // Function : N_TIA_MPDEInterface::setStateInitialCondition
161 // Purpose : Method to specify transient state initial condition
162 // Special Notes :
163 // Scope : public
164 // Creator : Todd S. Coffey, 1414
165 // Creation Date : 01/17/07
166 //-----------------------------------------------------------------------------
167 bool N_TIA_MPDEInterface::setStateInitialCondition(N_LAS_Vector * stateInitialConditionPtr)
168 {
169  *(dsPtr_->nextStatePtr) = *(stateInitialConditionPtr);
170  return true;
171 }
172 
173 //-----------------------------------------------------------------------------
174 // Function : N_TIA_MPDEInterface::setStoreInitialCondition
175 // Purpose : Method to specify transient store initial condition
176 // Special Notes :
177 // Scope : public
178 // Creator : Eric Keiter, SNL
179 // Creation Date :
180 //-----------------------------------------------------------------------------
181 bool N_TIA_MPDEInterface::setStoreInitialCondition(N_LAS_Vector * storeInitialConditionPtr)
182 {
183  *(dsPtr_->nextStorePtr) = *(storeInitialConditionPtr);
184  return true;
185 }
186 
187 //-----------------------------------------------------------------------------
188 // Function : N_TIA_MPDEInterface::setInitialCondition
189 // Purpose : Method to specify transient initial condition
190 // Special Notes :
191 // Scope : public
192 // Creator : Todd S. Coffey, 9214
193 // Creation Date : 03/25/04
194 //-----------------------------------------------------------------------------
195 bool N_TIA_MPDEInterface::setQVectorInitialCondition(N_LAS_Vector * qVectorInitialConditionPtr)
196 {
197  *(dsPtr_->daeQVectorPtr) = *(qVectorInitialConditionPtr);
198  return true;
199 }
200 
201 //-----------------------------------------------------------------------------
202 // Function : N_TIA_MPDEInterface::runDCOP
203 // Purpose : Execute the top level DC sweep control loop.
204 // Special Notes :
205 // Scope : public
206 // Creator : Todd S. Coffey, 9214
207 // Creation Date : 03/25/04
208 //-----------------------------------------------------------------------------
210 {
211  if( !tiaParams_.NOOP )
212  {
213  // as long as the user didn't request "noop"
214  // try and do the operating point calculation
216  return anaManagerPtr_->run();
217  }
218  return false;
219 }
220 
221 //-----------------------------------------------------------------------------
222 // Function : N_TIA_MPDEInterface::runTransient
223 // Purpose : Execute the top level transient control loop without DCOP.
224 // Special Notes :
225 // Scope : public
226 // Creator : Todd S. Coffey, 9214
227 // Creation Date : 03/25/04
228 //-----------------------------------------------------------------------------
230 {
232  tiaParams_.NOOP = true;
233  return anaManagerPtr_->run();
234 }
235 
236 
237 //-----------------------------------------------------------------------------
238 // Function : N_TIA_MPDEInterface::runTransient
239 // Purpose : Execute the top level transient control loop with DCOP.
240 // Special Notes :
241 // Scope : public
242 // Creator : Todd S. Coffey, 9214
243 // Creation Date : 03/25/04
244 //-----------------------------------------------------------------------------
246 {
248  return anaManagerPtr_->run();
249 }
250 
251 //-----------------------------------------------------------------------------
252 // Function : N_TIA_MPDEInterface::getTimeIntInfo
253 // Purpose : Get details from time integrator on last step.
254 // Special Notes :
255 // Scope : public
256 // Creator : Richard Schiek, 1437
257 // Creation Date : 10/22/07
258 //-----------------------------------------------------------------------------
260 {
262 }
263 
264 
265 //-----------------------------------------------------------------------------
266 // Function : N_TIA_MPDEInterface::runStep
267 // Purpose : Take one, prescribed, time-step
268 // Special Notes :
269 // Scope : public
270 // Creator : Richard Schiek, 1437
271 // Creation Date : 10/22/07
272 //-----------------------------------------------------------------------------
274 {
275  anaManagerPtr_->startTimeStep(tiInfo);
276  return anaManagerPtr_->runStep(tiInfo, tlError);
277 }
278 
279 
280 //-----------------------------------------------------------------------------
281 // Function : N_TIA_MPDEInterface::stepSuccess
282 // Purpose : Process a successful step
283 // Special Notes :
284 // Scope : public
285 // Creator : Richard Schiek, 1437
286 // Creation Date : 10/22/07
287 //-----------------------------------------------------------------------------
288 void N_TIA_MPDEInterface::stepSuccess(int analysisType)
289 {
290  anaManagerPtr_->stepSuccess( analysisType );
291 }
292 
293 
294 //-----------------------------------------------------------------------------
295 // Function : N_TIA_MPDEInterface::getFinalSolution
296 // Purpose : Method to return output solution (either from DCOP or transient)
297 // Special Notes :
298 // Scope : public
299 // Creator : Todd S. Coffey, 9214
300 // Creation Date : 03/25/04
301 //-----------------------------------------------------------------------------
303 {
304  return dsPtr_->currSolutionPtr;
305 }
306 
307 //-----------------------------------------------------------------------------
308 // Function : N_TIA_MPDEInterface::getStateFinalSolution
309 // Purpose : Method to return output state vector (either from DCOP or transient)
310 // Special Notes :
311 // Scope : public
312 // Creator : Todd S. Coffey, 1414
313 // Creation Date : 01/17/07
314 //-----------------------------------------------------------------------------
316 {
317  return dsPtr_->currStatePtr;
318 }
319 
320 //-----------------------------------------------------------------------------
321 // Function : N_TIA_MPDEInterface::getStoreFinalSolution
322 // Purpose : Method to return output store vector (either from DCOP or transient)
323 // Special Notes :
324 // Scope : public
325 // Creator : Eric Keiter, SNL
326 // Creation Date :
327 //-----------------------------------------------------------------------------
329 {
330  return dsPtr_->currStorePtr;
331 }
332 
333 //-----------------------------------------------------------------------------
334 // Function : N_TIA_MPDEInterface::getQVectorFinalSolution
335 // Purpose : Method to return output Q vector (either from DCOP or transient)
336 // Special Notes :
337 // Scope : public
338 // Creator : Todd S. Coffey, 1414
339 // Creation Date : 01/17/07
340 //-----------------------------------------------------------------------------
342 {
343  return dsPtr_->daeQVectorPtr;
344 }
345 
346 //-----------------------------------------------------------------------------
347 // Function : N_TIA_MPDEInterface::getQVectorHistoryFinalSolution
348 // Purpose : Method to return output Q vector (either from DCOP or transient)
349 // Special Notes :
350 // Scope : public
351 // Creator : Todd S. Coffey, 1414
352 // Creation Date : 01/17/07
353 //-----------------------------------------------------------------------------
355 {
356  return dsPtr_->qHistory[0];
357 }
358 
359 //-----------------------------------------------------------------------------
360 // Function : N_TIA_MPDEInterface::reInitialize
361 // Purpose : Method to re-initialize time integrator in between separate
362 // : integrations with the same size vectors.
363 // Special Notes :
364 // Scope : public
365 // Creator : Todd S. Coffey, 9214
366 // Creation Date : 03/25/04
367 //-----------------------------------------------------------------------------
369 {
370  tiaParams_.resume = false;
372  // 10/04/05 tscofffe: We need to reinitialize the variables in the
373  // StepErrorControl object.
374 #ifdef Xyce_DEBUG_TIME
375  Xyce::dout() << *(tiaSecPtr_) << std::endl;
376 #endif
377  tiaSecPtr_->resetAll();
378 #ifdef Xyce_DEBUG_TIME
379  Xyce::dout() << *(tiaSecPtr_) << std::endl;
380 #endif
381 
382  // 10/04/05 tscoffe: BackwardDifferentiation15 needs to be re-initialized here.
383  anaManagerPtr_->wimPtr->initialize();
384  return true;
385 }
386