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