Xyce  6.1
N_TIA_Gear12.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-2015 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_Gear12.C,v $
27 //
28 // Purpose : This file contains the functions which define the
29 // backward differentiation, order 1-2, class.
30 //
31 // Special Notes :
32 //
33 // Creator : Ting Mei
34 //
35 // Creation Date : 2/16/04
36 //
37 // Revision Information:
38 // ---------------------
39 //
40 // Revision Number: $Revision: 1.64 $
41 //
42 // Revision Date : $Date: 2015/09/03 22:11:40 $
43 //
44 // Current Owner : $Author: rlschie $
45 //-----------------------------------------------------------------------------
46 
47 #include <Xyce_config.h>
48 
49 // ---------- Standard Includes ----------
50 #include <iostream>
51 
52 // ---------- Xyce Includes ----------
53 #include <N_ANP_OutputMgrAdapter.h>
54 #include <N_ERH_ErrorMgr.h>
55 #include <N_IO_InitialConditions.h>
56 #include <N_LAS_BlockVector.h>
57 #include <N_LAS_Matrix.h>
58 #include <N_LAS_System.h>
59 #include <N_LAS_Vector.h>
60 #include <N_PDS_Comm.h>
61 #include <N_PDS_Manager.h>
62 #include <N_TIA_DataStore.h>
63 #include <N_TIA_Gear12.h>
64 #include <N_TIA_StepErrorControl.h>
65 #include <N_TIA_TIAParams.h>
67 #include <N_UTL_Diagnostic.h>
68 #include <N_UTL_FeatureTest.h>
69 #include <N_UTL_MachDepParams.h>
70 
71 using std::abs;
72 
73 namespace Xyce {
74 namespace TimeIntg {
75 
76 const char *
77 Gear12::name = "Gear 12";
78 
79 //-----------------------------------------------------------------------------
80 // Function : Gear12::factory
81 // Purpose :
82 // Special Notes :
83 // Scope : public
84 // Creator : Ting Mei, SNL
85 // Creation Date : 10/31/07
86 //-----------------------------------------------------------------------------
87 TimeIntegrationMethod *
89  const TIAParams & tia_params,
90  StepErrorControl & step_error_control,
91  DataStore & data_store)
92 {
93  return new Gear12(tia_params, step_error_control, data_store);
94 }
95 
96 //-----------------------------------------------------------------------------
97 // Function : Gear::Gear
98 // Purpose : constructor
99 // Special Notes :
100 // Scope : public
101 // Creator : Ting Mei, SNL
102 // Creation Date : 10/10/12
103 //-----------------------------------------------------------------------------
105  const TIAParams & tia_params,
106  StepErrorControl & secTmp,
107  DataStore & dsTmp)
109  leadingCoeff(1.0),
110  sec(secTmp),
111  ds(dsTmp)
112 {
113  leadingCoeff = 1;
114  sec.maxOrder_=(std::min(2,tia_params.maxOrder));
115  sec.minOrder_=(std::max(1,tia_params.minOrder));
116 
117  if (sec.minOrder_ > sec.maxOrder_)
118  {
120  }
121  // sec.maxOrder_ = 2;
122  timept_ = -1.0;
123 }
124 
125 //-----------------------------------------------------------------------------
126 // Function : Gear12::obtainPredictor
127 // Purpose : Calculate predictor
128 // Special Notes : stored in ds.xn0Ptr,qn0Ptr,qpn0Ptr
129 // Scope : public
130 // Creator : Ting Mei, SNL
131 // Creation Date : 10/10/12
132 //-----------------------------------------------------------------------------
134 {
135  // evaluate predictor
136  *ds.sn0Ptr = *(ds.sHistory[0]);
137  ds.xn0Ptr->putScalar(0.0);
138  ds.qn0Ptr->putScalar(0.0);
141 
142  ds.spn0Ptr->putScalar(0.0);
143  for (int i=0;i<=sec.currentOrder_;++i)
144  {
145  ds.xn0Ptr->linearCombo(sec.beta_[i],*(ds.xHistory[i]),1.0,*ds.xn0Ptr);
146  ds.qn0Ptr->linearCombo(sec.beta_[i],*(ds.qHistory[i]),1.0,*ds.qn0Ptr);
147  }
148 
149  if (DEBUG_TIME && isActive(Diag::TIME_PREDICTOR))
150  {
151  Xyce::dout().width(21); Xyce::dout().precision(13); Xyce::dout().setf(std::ios::scientific);
152  Xyce::dout() << std::endl
153  << Xyce::section_divider << std::endl
154  << " Gear12::obtainPredictor" << std::endl
155  << "\n currentOrder = " << sec.currentOrder_ << std::endl
156  << "\n sec.nscsco_: " << sec.nscsco_ << std::endl;
157  for (int i=0; i<=sec.currentOrder_ ; ++i)
158  Xyce::dout() << "\n sec.beta_[" << i << "] = " << sec.beta_[i] << "\n" << std::endl;
159  for (int i=0; i<=sec.currentOrder_ ; ++i)
160  {
161  Xyce::dout() << "\n xHistory["<< i << "]: \n" << std::endl;
162  (ds.xHistory[i])->printPetraObject(Xyce::dout());
163  Xyce::dout() << std::endl;
164  }
165  for (int i=0; i<=sec.currentOrder_ ; ++i)
166  {
167  Xyce::dout() << "\n qHistory["<< i << "]: \n" << std::endl;
168  (ds.qHistory[i])->printPetraObject(Xyce::dout());
169  Xyce::dout() << std::endl;
170  }
171  for (int i=0; i<=sec.currentOrder_ ; ++i)
172  {
173  Xyce::dout() << "\n sHistory["<< i << "]: \n" << std::endl;
174  (ds.sHistory[i])->printPetraObject(Xyce::dout());
175  Xyce::dout() << std::endl;
176  }
177  Xyce::dout() << "\n xn0: \n" << std::endl;
178  ds.xn0Ptr->printPetraObject(Xyce::dout());
179  Xyce::dout() << std::endl;
180  Xyce::dout() << "\n qn0: \n" << std::endl;
181  ds.qn0Ptr->printPetraObject(Xyce::dout());
182  Xyce::dout() << std::endl;
183  Xyce::dout() << "\n qpn0: \n" << std::endl;
184  ds.qpn0Ptr->printPetraObject(Xyce::dout());
185  Xyce::dout() << std::endl;
186  Xyce::dout() << "\n sn0: \n" << std::endl;
187  ds.sn0Ptr->printPetraObject(Xyce::dout());
188  Xyce::dout() << std::endl;
189  Xyce::dout() << "\n spn0: \n" << std::endl;
190  ds.spn0Ptr->printPetraObject(Xyce::dout());
191  Xyce::dout() << std::endl;
192  Xyce::dout() << Xyce::section_divider << std::endl;
193  }
194 
195  // copy the prediction into the next solution:
196  *(ds.nextSolutionPtr) = *(ds.xn0Ptr);
197 
199 
200  return;
201 }
202 
203 //-----------------------------------------------------------------------------
204 // Function : Gear12::obtainSensitivityPredictors
205 // Purpose : Calculate predictor
206 // Special Notes :
207 // Scope : public
208 // Creator : Eric Keiter, SNL
209 // Creation Date :
210 //-----------------------------------------------------------------------------
212 {}
213 
214  // Computes the step addjustment.
215  // 2/16/04 tscoffe: I'm not exactly sure what this routine is for...
216 double
218  double stepadjust)
219 {
220  return pow(stepadjust, 1.0 / 3.0);
221 }
222 
223 //-----------------------------------------------------------------------------
224 // Function : Gear12::obtainResidual
225 // Purpose : Calculate Residual
226 // Special Notes :
227 // Scope : public
228 // Creator : Ting Mei, SNL
229 // Creation Date : 11/16/07
230 //-----------------------------------------------------------------------------
232 {
233  // output: ds.RHSVectorPtr
234  // Note: ds.nextSolutionPtr is used to get Q,F,B in Analysis::AnalysisManager::loadRHS.
235  ds.RHSVectorPtr->linearCombo(sec.alpha_[0],*ds.daeQVectorPtr, sec.alpha_[1],*(ds.qHistory[0]) );
236 
237  if (DEBUG_TIME && isActive(Diag::TIME_RESIDUAL))
238  {
239  Xyce::dout() << std::endl
240  << Xyce::section_divider << std::endl
241  << " Gear12::obtainResidual" << std::endl
242  << "\n t = " << sec.nextTime << "\n" << std::endl
243  << "\n solution: \n" << std::endl;
244  ds.nextSolutionPtr->printPetraObject(Xyce::dout());
245  Xyce::dout() << "\n daeQVector: \n" << std::endl;
246  ds.daeQVectorPtr->printPetraObject(Xyce::dout());
247  Xyce::dout() << "\n qn0: \n" << std::endl;
248  ds.qn0Ptr->printPetraObject(Xyce::dout());
249  Xyce::dout() << "\n qpn0: \n" << std::endl;
250  ds.qpn0Ptr->printPetraObject(Xyce::dout());
251  Xyce::dout() << "\n sec.alphas_/hn: " << sec.alphas_/sec.currentTimeStep << "\n" << std::endl
252  << "\n daeFVector: \n" << std::endl;
253  ds.daeFVectorPtr->printPetraObject(Xyce::dout());
254 
255  Xyce::dout() << "\n dQdt-vector: \n" << std::endl;
256  ds.RHSVectorPtr->printPetraObject(Xyce::dout());
257  Xyce::dout() << std::endl;
258  }
259 
260  if (sec.currentOrder_ == 2)
261  {
262  ds.RHSVectorPtr->linearCombo(1.0, *ds.RHSVectorPtr, sec.alpha_[2],*(ds.qHistory[1]));
263  }
264 
266  ds.RHSVectorPtr->linearCombo(1.0,*ds.RHSVectorPtr,-1.0,*ds.daeBVectorPtr);
267 
268  // since the nonlinear solver is expecting a -f, scale by -1.0:
269  ds.RHSVectorPtr->scale(-1.0);
270 
271  // if voltage limiting is on, add it in:
272  if (ds.limiterFlag)
273  {
275  // double qscalar(sec.alpha_[0]/sec.currentTimeStep);
276 
277  (ds.RHSVectorPtr)->daxpy(
278  *(ds.RHSVectorPtr), +1.0, *(ds.dQdxdVpVectorPtr));
279 
280  (ds.RHSVectorPtr)->daxpy(
281  *(ds.RHSVectorPtr), +1.0, *(ds.dFdxdVpVectorPtr));
282  }
283 
284  if (DEBUG_TIME && isActive(Diag::TIME_RESIDUAL))
285  {
286  Xyce::dout() << "\n Residual-vector: \n" << std::endl
287  << "-(qpn0-(sec.alpha_s/h)*(Q-qn0)+F-B) \n" << std::endl;
288  ds.RHSVectorPtr->printPetraObject(Xyce::dout());
289  Xyce::dout() << Xyce::section_divider << std::endl
290  << std::endl;
291  }
292 }
293 
294 //-----------------------------------------------------------------------------
295 // Function : Gear12::obtainSensitivityResiduals
296 // Purpose : Calculate sensitivity residual
297 // Special Notes :
298 // Scope : public
299 // Creator : Eric Keiter
300 // Creation Date :
301 //-----------------------------------------------------------------------------
303 {
304  int numParams = ds.sensRHSPtrVector.size();
305  for (int ip=0; ip<numParams;++ip)
306  {
307  Linear::Vector & RHSVec = *(ds.sensRHSPtrVector[ip]);
308  Linear::Vector & dfdpVec = *(ds.nextDfdpPtrVector[ip]);
309  Linear::Vector & dqdpVec = *(ds.nextDqdpPtrVector[ip]);
310  Linear::Vector & dbdpVec = *(ds.nextDbdpPtrVector[ip]);
311 
312  Linear::Vector & currDXdpVec = *(ds.currDXdpPtrVector[ip]);
313  Linear::Vector & lastDXdpVec = *(ds.lastDXdpPtrVector[ip]);
314 
315  std::vector<Linear::Vector*> & dqdpHistoryVec = ds.dqdpHistory[ip];
316 
317  Linear::Vector & currDQdxDXdpVec = *(ds.currDQdxDXdpPtrVector[ip]);
318  Linear::Vector & lastDQdxDXdpVec = *(ds.lastDQdxDXdpPtrVector[ip]);
319 
320  RHSVec.linearCombo(sec.alpha_[0],dqdpVec, sec.alpha_[1],*(dqdpHistoryVec[0]) );
321 
322  if (sec.currentOrder_ == 2)
323  {
324  RHSVec.linearCombo(1.0, RHSVec, sec.alpha_[2],*(dqdpHistoryVec[1]));
325  }
326 
327  RHSVec.linearCombo(1.0/sec.currentTimeStep,RHSVec,+1.0,dfdpVec);
328  RHSVec.linearCombo(1.0,RHSVec,-1.0,dbdpVec);
329 
330  // since the nonlinear solver is expecting a -f, scale by -1.0:
331  RHSVec.scale(-1.0);
332 
333  // deal with the matvec corrections
334  // This assumes that the matvecs have been properly stored.
335  double qscalar1(sec.alpha_[1]/sec.currentTimeStep);
336  RHSVec.linearCombo(1.0,RHSVec, -qscalar1, currDQdxDXdpVec);
337 
338  if (sec.currentOrder_ == 2)
339  {
340  double qscalar2(sec.alpha_[2]/sec.currentTimeStep);
341  RHSVec.linearCombo(1.0,RHSVec, -qscalar2, lastDQdxDXdpVec);
342  }
343 
344 #ifdef DEBUG_SENS
345  Xyce::dout() << "obtainSensitivityResiduals: RHS Vector, ip = " << ip << ":\n";
346  RHSVec.printPetraObject(Xyce::dout());
347 #endif
348  }
349 }
350 
351 //-----------------------------------------------------------------------------
352 // Function : Gear12::obtainJacobian
353 // Purpose : Calculate Jacobian
354 // Special Notes :
355 // Scope : public
356 // Creator : Ting Mei, SNL
357 // Creation Date : 11/16/07
358 //-----------------------------------------------------------------------------
360 {
361 
362  if (DEBUG_TIME && isActive(Diag::TIME_JACOBIAN))
363  {
364  Xyce::dout() << std::endl
365  << Xyce::section_divider << std::endl
366  << " Gear12::obtainJacobian" << std::endl;
367  }
368 
369  // output: ds.JMatrixPtr
370 
371  // This function returns the following matrix:
372  // $-(sec.alphas_/hn)dQdx(x)+dFdx$
373 
374  // Note: ds.nextSolutionPtr is used to get dQdx,dFdx in Analysis::AnalysisManager::loadJacobian.
375 
376  Linear::Matrix & dQdx = *(ds.dQdxMatrixPtr);
377  Linear::Matrix & dFdx = *(ds.dFdxMatrixPtr);
378  Linear::Matrix & Jac = *(ds.JMatrixPtr);
379 
380  double qscalar(sec.alpha_[0]/sec.currentTimeStep);
381  double fscalar(1.0);
382 
383  Jac.linearCombo( qscalar, dQdx, fscalar, dFdx );
384 
385  if (DEBUG_TIME && isActive(Diag::TIME_JACOBIAN))
386  {
387  Xyce::dout() << "\n dFdx:" <<std::endl;
388  dFdx.printPetraObject(Xyce::dout());
389  Xyce::dout() << "\n Total Jacobian:" <<std::endl;
390  Jac.printPetraObject(Xyce::dout());
391  // for (int i=0;i<3;++i)
392  // {
393  // printf("[ %25.20g\t%25.20g\t%25.20g ]\n",Jac[i][0],Jac[i][1],Jac[i][2]);
394  // }
395 
396  Xyce::dout() << Xyce::section_divider << std::endl << std::endl;
397  }
398 }
399 
400 //-----------------------------------------------------------------------------
401 // Function : Gear12::interpolateSolution
402 // Purpose : Interpolate solution approximation at prescribed time point.
403 // Scope : public
404 // Creator : Ting Mei, SNL
405 // Creation Date : 11/16/07
406 //-----------------------------------------------------------------------------
407 bool Gear12::interpolateSolution(double timepoint,
408  Linear::Vector * tmpSolVectorPtr, std::vector<Linear::Vector*> & historyVec)
409 
410 {
411  // this is a very course approximation to determine if we are too
412  // close to the actual time step to do an interpolation.
413  // it could use more work.
414  double dtr = timepoint - sec.currentTime; // the delta time requested.
415  if( -dtr < 100 * Util::MachineDependentParams::MachinePrecision() )
416  {
417  *tmpSolVectorPtr = *(historyVec[0]);
418  return false;
419  }
420 
421  tmpSolVectorPtr->linearCombo(1.0, *(historyVec[0]), -1.0, *(historyVec[1]));
422 
423  if( sec.usedOrder_ <= 2)
424  {
425  // do first order interpolation
426  // X_interp = X + delta_t_requested * delta_X/delta_t[last step]
427  dtr = dtr / sec.lastTimeStep;
428  tmpSolVectorPtr->linearCombo(1.0, *(historyVec[0]), dtr, *tmpSolVectorPtr);
429  }
430 
431  return true;
432 }
433 
434 //-----------------------------------------------------------------------------
435 // Function : Gear12::interpolateMPDESolution
436 // Purpose : Interpolate solution approximation at prescribed time points.
437 // Special Notes : This routine computes the solution at the output
438 // : timepoints by intepolation of the history using the order
439 // : used for the most recent completed step, orderUsed.
440 // : The output is put into provided Linear::Vector pointer.
441 // : The interpolation is as follows:
442 // : tmpSolVectorPtr->block(i) is interpolated at timepoint(i)
443 // : Therefore, if you want them all interpolated at the same time,
444 // : then use timepoint(i) = timepoint(0) forall i
445 // : or use interpolateSolution.
446 // Scope : public
447 // Creator : Ting Mei, Eric Keiter, SNL
448 // Creation Date : 11/28/06
449 //-----------------------------------------------------------------------------
450 bool Gear12::interpolateMPDESolution(std::vector<double>& timepoint,
451  Linear::Vector * tmpSolVectorPtr)
452 {
453  Linear::BlockVector * blockTempSolVectorPtr =
454  dynamic_cast<Linear::BlockVector*>(tmpSolVectorPtr);
455  if (blockTempSolVectorPtr == NULL)
456  {
457  std::string msg = "Gear12::interpolateMPDESolution: ";
458  msg += "Linear::Vector tmpSolVectorPtr is not of type Linear::BlockVector";
459  N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::DEV_FATAL_0, msg);
460  return(false);
461  }
462 
463  double tfuzz; // fuzz factor to check for valid output time
464  double tp; // approximately t_{n-1}
465  int numblocks = timepoint.size();
466  int blockCount = blockTempSolVectorPtr->blockCount();
467  if (numblocks > blockCount)
468  {
469  std::string msg = "Gear12::interpolateMPDESolution: ";
470  msg += "Number of time points requested is greater than number of fast time points in MPDE block vector";
471  N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::DEV_FATAL_0, msg);
472  return(false);
473  }
474  double delt;
475  double c = 1.0;
476  double gam;
477  int kord; // order of interpolation
478  double tn = sec.currentTime;
479  double hh = sec.currentTimeStep;
480  double hused = sec.usedStep_;
481  int kused = sec.usedOrder_;
482  double uround = 0.0; // unit round-off (set to zero for now)
483 
484  tfuzz = 100 * uround * (tn + hh);
485  tp = tn - hused - tfuzz;
486  for (int i=0; i<numblocks ; ++i)
487  {
488  if ( (timepoint[i] - tp)*hh < 0.0 )
489  return false;
490  }
491 
492  *tmpSolVectorPtr = *(ds.xHistory[0]);
493 
494  Linear::Vector * solVectorPtr;
495  Linear::Vector * xHistoryVectorPtr;
496  // Loop over blocks first so that maximal order can be maintained
497  for (int i=0; i < numblocks ; ++i)
498  {
499  if ((kused == 0) || (timepoint[i] == tn)) { kord = 1; }
500  else { kord = kused; }
501  solVectorPtr = &(blockTempSolVectorPtr->block(i));
502  c = 1.0;
503  delt = timepoint[i] - tn;
504  gam = delt/sec.psi_[0];
505  for (int j=1 ; j <= kord ; ++j)
506  {
507  c = c*gam;
508  gam = (delt + sec.psi_[j-1])/sec.psi_[j];
509  Linear::BlockVector * blockXHistoryVectorPtr =
510  dynamic_cast<Linear::BlockVector*>(ds.xHistory[j]);
511  if (blockXHistoryVectorPtr == NULL)
512  {
513  Xyce::Report::DevelFatal0().in("Gear12::interpolateMPDESolution") << "Linear::Vector ds.xHistory[j] is not of type Linear::BlockVector\n j = " << j;
514  return(false);
515  }
516  xHistoryVectorPtr = &(blockXHistoryVectorPtr->block(i));
517  solVectorPtr->linearCombo(1.0,*solVectorPtr,c,*xHistoryVectorPtr);
518  }
519  }
520  return true;
521 }
522 
523 //-----------------------------------------------------------------------------
524 // Function : Gear12::printMPDEOutputSolution()
525 // Purpose : Print transient output from MPDE simulation
526 // Special Notes : This routine uses interpolateMPDESolution.
527 // Scope : public
528 // Creator : Ting Mei, SNL, 1414
529 // Creation Date : 11/28/06
530 //-----------------------------------------------------------------------------
532  Analysis::OutputMgrAdapter & outputManagerAdapter,
533  const double time,
534  Linear::Vector * solnVecPtr,
535  const std::vector<double> & fastTimes )
536 {
537  return true;
538 }
539 
540 
541 //-----------------------------------------------------------------------------
542 // Function : Gear12::printWaMPDEOutputSolution()
543 // Purpose : Print transient output from WaMPDE simulation
544 // Special Notes : This routine uses interpolateSolution.
545 // Scope : public
546 // Creator : Ting Mei, SNL, 1414
547 // Creation Date : 12/15/06
548 //-----------------------------------------------------------------------------
550  Analysis::OutputMgrAdapter & outputManagerAdapter,
551  const double time,
552  Linear::Vector * solnVecPtr,
553  const std::vector<double> & fastTimes,
554  const int phiGID )
555 {
556  return true;
557 }
558 
559 //-----------------------------------------------------------------------------
560 // Function : Gear12::printOutputSolution()
561 // Purpose : Print output that is dumbed down in order.
562 // Special Notes : This routine picks smaller time steps to approximate first
563 // : order integration from the perspective of the output.
564 // Scope : public
565 // Creator : Ting Mei, SNL, 1414
566 // Creation Date : 11/16/07
567 //-----------------------------------------------------------------------------
568 
570  Analysis::OutputMgrAdapter & outputManagerAdapter,
571  const TIAParams & tia_params,
572  const double time,
573  Linear::Vector * solnVecPtr,
574  const bool doNotInterpolate,
575  const std::vector<double> & outputInterpolationTimes,
576  bool skipPrintLineOutput)
577 {
578  if (DEBUG_TIME && isActive(Diag::TIME_OUTPUT))
579  {
580  Xyce::dout() << std::endl
581  << Xyce::section_divider << std::endl
582  << " Gear12::printOutputSolution" << std::endl
583  << "usedOrder_ = " << sec.usedOrder_ << std::endl;
584  }
585 
586  double timestep = sec.lastAttemptedTimeStep;
587  double lasttime = sec.currentTime - timestep;
588  bool dointerp = true;
589  double hh = timestep/(sec.usedOrder_);
590 
591  if (hh <= 10*sec.minTimeStep)
592  {
593  dointerp = false;
594  }
595 
596  if (!tia_params.interpOutputFlag)
597  {
598  dointerp = false;
599  }
600 
601  if (doNotInterpolate)
602  {
603  dointerp = false;
604  }
605 
606  if (dointerp && !outputInterpolationTimes.empty())
607  {
608  for (unsigned int i=0;i<outputInterpolationTimes.size();++i)
609  {
610  interpolateSolution(outputInterpolationTimes[i], ds.tmpSolVectorPtr, ds.xHistory); // interpolate solution vector
611  interpolateSolution(outputInterpolationTimes[i], ds.tmpStaVectorPtr, ds.sHistory); // interpolate state vector
612  interpolateSolution(outputInterpolationTimes[i], ds.tmpStoVectorPtr, ds.stoHistory); // interpolate store vector
613  interpolateSolution(outputInterpolationTimes[i], ds.tmpLeadCurrentVectorPtr, ds.leadCurrentHistory); // interpolate store vector
614  interpolateSolution(outputInterpolationTimes[i], ds.tmpLeadDeltaVPtr, ds.leadDeltaVHistory); // interpolate store vector
615  interpolateSolution(outputInterpolationTimes[i], ds.tmpLeadCurrentQDerivVectorPtr, ds.leadCurrentQDerivHistory); // interpolate store vector
616  outputManagerAdapter.tranOutput(outputInterpolationTimes[i], *ds.tmpSolVectorPtr,
620  skipPrintLineOutput);
621 
622  }
623  }
624 
625  // Either way, do an output on the actual computed time step, but only
626  // if we weren't given a list of specific times *or* we were told not to
627  // interpoloate.
628  if (outputInterpolationTimes.empty() || doNotInterpolate)
629  {
630  outputManagerAdapter.tranOutput(time, *ds.currSolutionPtr,
634  skipPrintLineOutput);
635  }
636 
637  if (DEBUG_TIME && isActive(Diag::TIME_OUTPUT))
638  Xyce::dout() << Xyce::section_divider << std::endl;
639 
640  return true;
641 }
642 
643 //-----------------------------------------------------------------------------
644 // Function : Gear12::saveOutputSolution
645 // Purpose : This is similar to printOutputSolution, but is in support of
646 // the .SAVE capability, rather than .PRINT.
647 // Special Notes :
648 // Scope : public
649 // Creator : Eric Keiter, SNL
650 // Creation Date : 10/21/07
651 //-----------------------------------------------------------------------------
652 bool
654  Parallel::Machine comm,
655  IO::InitialConditionsManager & initial_conditions_manager,
656  const NodeNameMap & node_name_map,
657  const TIAParams & tia_params,
658  Linear::Vector * solnVecPtr,
659  const double saveTime,
660  const bool doNotInterpolate)
661 {
662  if (DEBUG_TIME && isActive(Diag::TIME_OUTPUT))
663  {
664  Xyce::dout() << std::endl
665  << Xyce::section_divider << std::endl
666  << " Gear12::saveOutputSolution" << std::endl;
667  }
668 
669  double timestep = sec.lastAttemptedTimeStep;
670  double lasttime = sec.currentTime - timestep;
671  bool dointerp = true;
672  double hh = timestep/(sec.usedOrder_);
673 
674  // outputManagerAdapter.outputDCOP( *(ds.currSolutionPtr) );
675  initial_conditions_manager.outputDCOP(comm, node_name_map, *ds.currSolutionPtr);
676 
677  if (DEBUG_TIME && isActive(Diag::TIME_OUTPUT))
678  Xyce::dout() << Xyce::section_divider << std::endl;
679 
680  return true;
681 }
682 
683 //-----------------------------------------------------------------------------
684 // Function : Gear12::updateHistory
685 // Purpose : Update history array after a successful step
686 // Special Notes :
687 // Scope : public
688 // Creator : Ting Mei, SNL
689 // Creation Date : 11/16/07
690 //-----------------------------------------------------------------------------
692 {
693  if (DEBUG_TIME && isActive(Diag::TIME_OUTPUT))
694  {
695  Xyce::dout() << std::endl
696  << Xyce::section_divider << std::endl
697  << " Gear12::updateHistory" << std::endl
698  << "\n Before updates \n" << std::endl;
699  for (int i=0; i<=sec.maxOrder_ ; ++i)
700  {
701  Xyce::dout() << "\n xHistory["<< i << "]: \n" << std::endl;
702  (ds.xHistory[i])->printPetraObject(Xyce::dout());
703  Xyce::dout() << std::endl;
704  }
705  for (int i=0; i<=sec.maxOrder_ ; ++i)
706  {
707  Xyce::dout() << "\n qHistory["<< i << "]: \n" << std::endl;
708  (ds.qHistory[i])->printPetraObject(Xyce::dout());
709  Xyce::dout() << std::endl;
710  }
711  for (int i=0; i<=sec.maxOrder_ ; ++i)
712  {
713  Xyce::dout() << "\n sHistory["<< i << "]: \n" << std::endl;
714  (ds.sHistory[i])->printPetraObject(Xyce::dout());
715  Xyce::dout() << std::endl;
716  }
717  Xyce::dout() << Xyce::section_divider << std::endl;
718  }
719 
720  if (sec.currentOrder_ == 2)
721  {
722  *(ds.xHistory[2]) = *(ds.xHistory[1]);
723  }
724  *(ds.qHistory[1]) = *(ds.qHistory[0]);
725  *(ds.xHistory[1]) = *(ds.xHistory[0]);
726 
728  *(ds.sHistory[1]) = *(ds.sHistory[0]);
729  *(ds.stoHistory[1]) = *(ds.stoHistory[0]);
730 
734 
735  *(ds.xHistory[0]) = *ds.nextSolutionPtr;
736  *(ds.qHistory[0]) = *ds.daeQVectorPtr;
737  *(ds.sHistory[0]) = *ds.nextStatePtr;
739  *(ds.stoHistory[0]) = *ds.nextStorePtr;
740 
744 
745  if (DEBUG_TIME && isActive(Diag::TIME_HISTORY))
746  {
747  Xyce::dout() << "\n After updates \n" << std::endl;
748  Xyce::dout() << "\n newtonCorrectionPtr: " << std::endl;
749  ds.newtonCorrectionPtr->printPetraObject(Xyce::dout());
750  Xyce::dout() << "\n qnewtonCorrectionPtr: " << std::endl;
751  ds.qNewtonCorrectionPtr->printPetraObject(Xyce::dout());
752  for (int i=0; i<=sec.maxOrder_ ; ++i)
753  {
754  Xyce::dout() << "\n xHistory["<< i << "]: \n" << std::endl;
755  (ds.xHistory[i])->printPetraObject(Xyce::dout());
756  Xyce::dout() << std::endl;
757  }
758  for (int i=0; i<=sec.maxOrder_ ; ++i)
759  {
760  Xyce::dout() << "\n qHistory["<< i << "]: \n" << std::endl;
761  (ds.qHistory[i])->printPetraObject(Xyce::dout());
762  Xyce::dout() << std::endl;
763  }
764  Xyce::dout() << "\n sNewtonCorrectionPtr: " << std::endl;
765  ds.sNewtonCorrectionPtr->printPetraObject(Xyce::dout());
766  Xyce::dout() << std::endl;
767  Xyce::dout() << "\n nextStatePtr: " << std::endl;
768  ds.nextStatePtr->printPetraObject(Xyce::dout());
769  Xyce::dout() << std::endl;
770  for (int i=0; i<=sec.maxOrder_ ; ++i)
771  {
772  Xyce::dout() << "\n sHistory["<< i << "]: \n" << std::endl;
773  (ds.sHistory[i])->printPetraObject(Xyce::dout());
774  Xyce::dout() << std::endl;
775  }
776  Xyce::dout() << Xyce::section_divider << std::endl;
777  }
778 
780 }
781 
782 //-----------------------------------------------------------------------------
783 // Function : Gear12::updateSensitivityHistory
784 // Purpose : Update sensitivity history array after a successful step
785 // Special Notes :
786 // Scope : public
787 // Creator : Eric Keiter, SNL
788 // Creation Date :
789 //-----------------------------------------------------------------------------
791 {
792  int numParams = ds.sensRHSPtrVector.size();
793  for (int ip=0; ip<numParams;++ip)
794  {
795  std::vector<Linear::Vector*> & dqdpHistory = ds.dqdpHistory[ip];
796  std::vector<Linear::Vector*> & dXdpHistory = ds.dXdpHistory[ip];
797  std::vector<Linear::Vector*> & dQdxdXdpHistory = ds.dQdxdXdpHistory[ip];
798 
799  Linear::Vector & nextDQdxDXdpVec = *(ds.nextDQdxDXdpPtrVector[ip]);
800  Linear::Vector & nextDXdpVec = *(ds.nextDXdpPtrVector[ip]);
801  Linear::Vector & nextDqdpVec = *(ds.nextDqdpPtrVector[ip]);
802 
803  if (sec.currentOrder_ == 2)
804  {
805  *(dQdxdXdpHistory[2]) = *(dQdxdXdpHistory[1]);
806  *(dXdpHistory[2]) = *(dXdpHistory[1]);
807  *(dqdpHistory[1]) = *(dqdpHistory[0]);
808  }
809 
810  *(dQdxdXdpHistory[1]) = *(dQdxdXdpHistory[0]);
811  *(dXdpHistory[1]) = *(dXdpHistory[0]);
812 
813  *(dQdxdXdpHistory[0]) = nextDQdxDXdpVec;
814  *(dXdpHistory[0]) = nextDXdpVec;
815  *(dqdpHistory[0]) = nextDqdpVec;
816  }
817 }
818 
819 //-----------------------------------------------------------------------------
820 // Function : Gear12::restoreHistory
821 // Purpose : Restore history array after a failed step
822 // Special Notes :
823 // Scope : public
824 // Creator : Ting Mei, SNL
825 // Creation Date : 10/21/07
826 //-----------------------------------------------------------------------------
828 {
829  for (int i=1;i<=sec.currentOrder_;++i)
830  {
831  sec.psi_[i-1] = sec.psi_[i];
832  }
833  if (DEBUG_TIME && isActive(Diag::TIME_HISTORY))
834  {
835  Xyce::dout() << std::endl
836  << Xyce::section_divider << std::endl
837  << " Gear12::restoreHistory" << std::endl;
838  for (int i=1;i<=sec.currentOrder_;++i)
839  Xyce::dout() << "\n sec.psi_[i] = " << sec.psi_[i] << std::endl;
840  for (int i=0; i<=sec.maxOrder_ ; ++i)
841  {
842  Xyce::dout() << "\n xHistory["<< i << "]: \n" << std::endl;
843  (ds.xHistory[i])->printPetraObject(Xyce::dout());
844  Xyce::dout() << std::endl;
845  }
846  for (int i=0; i<=sec.maxOrder_ ; ++i)
847  {
848  Xyce::dout() << "\n qHistory["<< i << "]: \n" << std::endl;
849  (ds.qHistory[i])->printPetraObject(Xyce::dout());
850  Xyce::dout() << std::endl;
851  }
852  for (int i=0; i<=sec.maxOrder_ ; ++i)
853  {
854  Xyce::dout() << "\n sHistory["<< i << "]: \n" << std::endl;
855  (ds.sHistory[i])->printPetraObject(Xyce::dout());
856  Xyce::dout() << std::endl;
857  }
858  Xyce::dout() << Xyce::section_divider << std::endl;
859  }
860 }
861 
862 //-----------------------------------------------------------------------------
863 // Function : Gear12::updateCoeffs
864 // Purpose : Update method coefficients
865 // Special Notes :
866 // Scope : public
867 // Creator : Ting Mei, SNL
868 // Creation Date : 10/21/07
869 //-----------------------------------------------------------------------------
871 {
872  // synchronize with Step Error Control
873  // sec.psi_[0] = sec.currentTimeStep;
874  if (DEBUG_TIME && isActive(Diag::TIME_COEFFICIENTS))
875  {
876  Xyce::dout() << std::endl
877  << Xyce::section_divider << std::endl
878  << " Gear12::updateCoeffs" << std::endl
879  << " currentTimeStep = " << sec.currentTimeStep << std::endl
880  << " numberOfSteps_ = " << sec.numberOfSteps_ << std::endl
881  << " currentOrder_ = " << sec.currentOrder_ << std::endl
882  << " nscsco_ = " << sec.nscsco_ << std::endl
883  << " psi_[0] = " << sec.psi_[0] << std::endl;
884  }
885 
886  double temp1 = sec.currentTimeStep;
887 
888  if (sec.currentOrder_ == 2)
889  {
890  sec.psi_[2] = sec.psi_[1];
891  }
892  sec.psi_[1] = sec.psi_[0];
893  sec.psi_[0] = temp1;
894 
895  // sec.beta_[0] = 1.0;
896  // sec.alpha_[0] = 1.0;
897  sec.ck_ = 1.0;
898  sec.alphas_ = -1.0;
899 
900  if (sec.currentOrder_ == 2)
901  {
902  // the coeffs of predictor
903  sec.beta_[2] = temp1/sec.psi_[2] * (temp1 + sec.psi_[1])/(sec.psi_[1] + sec.psi_[2]);
904  sec.beta_[1] = -temp1/sec.psi_[1] - sec.beta_[2] * (sec.psi_[1] + sec.psi_[2])/sec.psi_[1];
905  sec.beta_[0] = 1.0 - sec.beta_[2] - sec.beta_[1];
906 
907  sec.alpha_[2] = -temp1/sec.psi_[1] * temp1/(2 * temp1 + sec.psi_[1]);
908  sec.alpha_[1] = 1 - sec.alpha_[2];
909  sec.alpha_[0] = -sec.alpha_[1] - sec.alpha_[2] * (1 + sec.psi_[1]/temp1);
910 
911  sec.alpha_[2] = sec.alpha_[2]/sec.alpha_[0];
912  sec.alpha_[1] = sec.alpha_[1]/sec.alpha_[0];
913  sec.alpha_[0] = -1/sec.alpha_[0];
914 
915  sec.ck_ = sec.currentTimeStep/(temp1 + sec.psi_[1] + sec.psi_[2]);
916  }
917  else
918  {
919  sec.beta_[0] = 1.0 + temp1/sec.psi_[1];
920  sec.beta_[1] = -temp1/sec.psi_[1];
921  sec.alpha_[0] = 1.0;
922  sec.alpha_[1] = -1.0;
923 
924  sec.ck_ = sec.currentTimeStep/(temp1 + sec.psi_[1]);
925  }
926 
927  if (DEBUG_TIME && isActive(Diag::TIME_COEFFICIENTS))
928  {
929  Xyce::dout() << " nscsco_ = " << sec.nscsco_ << std::endl
930  << " beta_[0] = " << sec.beta_[0] << std::endl
931  << " beta_[1] = " << sec.beta_[1] << std::endl
932  << " beta_[2] = " << sec.beta_[2] << std::endl
933  << " beta_[3] = " << sec.beta_[3] << std::endl
934  << " beta_[4] = " << sec.beta_[4] << std::endl
935  << " alpha_[0] = " << sec.alpha_[0] << std::endl
936  << " alpha_[1] = " << sec.alpha_[1] << std::endl
937  << " alpha_[2] = " << sec.alpha_[2] << std::endl
938  << " alpha_[3] = " << sec.alpha_[3] << std::endl
939  << " alpha_[4] = " << sec.alpha_[4] << std::endl
940  << " alphas_ = " << sec.alphas_ << std::endl
941  << " alpha0_ = " << sec.alpha0_ << std::endl
942  << " gamma_[0] = " << sec.gamma_[0] << std::endl
943  << " gamma_[1] = " << sec.gamma_[1] << std::endl
944  << " gamma_[2] = " << sec.gamma_[2] << std::endl
945  << " gamma_[3] = " << sec.gamma_[3] << std::endl
946  << " gamma_[4] = " << sec.gamma_[4] << std::endl
947  << " psi_[0] = " << sec.psi_[0] << std::endl
948  << " psi_[1] = " << sec.psi_[1] << std::endl
949  << " psi_[2] = " << sec.psi_[2] << std::endl
950  << " psi_[3] = " << sec.psi_[3] << std::endl
951  << " psi_[4] = " << sec.psi_[4] << std::endl
952  << " sigma_[0] = " << sec.sigma_[0] << std::endl
953  << " sigma_[1] = " << sec.sigma_[1] << std::endl
954  << " sigma_[2] = " << sec.sigma_[2] << std::endl
955  << " sigma_[3] = " << sec.sigma_[3] << std::endl
956  << " sigma_[4] = " << sec.sigma_[4] << std::endl
957  << " ck_ = " << sec.ck_ << std::endl
958  << Xyce::section_divider << std::endl;
959  }
960 }
961 
962 //-----------------------------------------------------------------------------
963 // Function : Gear12::initialize
964 // Purpose : Initialize method with initial solution & step-size
965 // Special Notes :
966 // Scope : public
967 // Creator : Ting Mei, SNL
968 // Creation Date : 10/21/07
969 //-----------------------------------------------------------------------------
970 void Gear12::initialize(const TIAParams &tia_params)
971 {
972  // we assume the solution vector is available here
973  // Note that I'm using currSolutionPtr instead of
974  // nextSolutionPtr because this is the first step.
975 
976  // Update next stop time from StepErrorControl:
977  // ERK. Commenting this out, as it is already called from Analysis::AnalysisManager,
978  // right before this initialize call. It should not be called 2x, as
979  // it is history dependent (unfortunately), so calling it 2x in a row changes
980  // the stop time to a different number.
981  // sec.updateStopTime();
982 
983  // Choose initial step-size
984  double time_to_stop = sec.stopTime - sec.currentTime;
985  double currentTimeStep;
986 
987  sec.TimeStepLimitedbyBP = false;
988 
989  if (tia_params.constantTimeStepFlag)
990  {
991  currentTimeStep = 0.1 * time_to_stop;
992  currentTimeStep = std::min(sec.startingTimeStep, currentTimeStep);
993  sec.currentTimeStep = currentTimeStep;
994  }
995  else
996  {
997  // compute an initial step-size based on rate of change in the
998  // solution initially
999  double dnorm_q = ds.delta_x_errorNorm_q1();
1000  if (dnorm_q > 0.0) // time-dependent DAE
1001  {
1002  if (sec.currentTime == sec.initialTime)
1003  currentTimeStep = std::min(sec.h0_max_factor_*abs(time_to_stop),sqrt(2.0)/(sec.h0_safety_*dnorm_q));
1004  else
1005  currentTimeStep = 0.1* std::min(sec.savedTimeStep, abs(time_to_stop));
1006  }
1007  else // non-time-dependent DAE
1008  {
1009  if (sec.currentTime == sec.initialTime)
1010  currentTimeStep = sec.h0_max_factor_*abs(time_to_stop);
1011  else
1012  currentTimeStep = 0.1* std::min(sec.savedTimeStep, abs(time_to_stop));
1013  }
1014 
1015  // choose min of user specified value and our value:
1016  if (sec.startingTimeStep > 0.0 && (sec.currentTime == sec.initialTime))
1017  currentTimeStep = std::min(sec.startingTimeStep, currentTimeStep);
1018 
1019  // check for maximum step-size:
1020  double rh = abs(currentTimeStep)*sec.h_max_inv_;
1021  if (rh>1.0)
1022  currentTimeStep = currentTimeStep/rh;
1023 
1024  sec.currentTimeStep = currentTimeStep;
1025  }
1026 
1027  sec.currentTimeStepRatio = 1.0;
1029 
1033 
1035  sec.stepAttemptStatus = true;
1036 
1037  if (VERBOSE_TIME && tia_params.errorAnalysisOption == TimeIntg::NO_LOCAL_TRUNCATED_ESTIMATES)
1038  {
1039  Xyce::dout() << "ERROROPTION=1: DeltaT Grow = 2" << "\n" << std::endl
1040  << "ERROROPTION=1: DeltaT Cut = 0.125" << "\n" << std::endl
1041  << "ERROROPTION=1: NL MIN = " << tia_params.NLmin << "\n" << std::endl
1042  << "ERROROPTION=1: NL MAX = " << tia_params.NLmax << "\n" << std::endl
1043  << "ERROROPTION=1: DELMAX = " << sec.maxTimeStep << "\n" << std::endl;
1044  }
1045 
1046  // sec.tolAimFac_ = 0.5;
1047 
1049 
1050  // if (sec.currentTime == sec.initialTime)
1051  {
1052  // x history
1053  *(ds.xHistory[0]) = *(ds.currSolutionPtr);
1054  *(ds.xHistory[1]) = *(ds.currSolutionPtr);
1055 
1056  // q history
1057  *(ds.qHistory[0]) = *(ds.daeQVectorPtr);
1058  // *(ds.qHistory[1]) = *(ds.daeFVectorPtr);
1059  // (ds.qHistory[1])->scale(-sec.currentTimeStep);
1060  // (ds.qHistory[1])->putScalar(0.0);
1061  *(ds.qHistory[1]) = *(ds.daeQVectorPtr);
1062 
1063  // state history
1064  *(ds.sHistory[0]) = *(ds.currStatePtr);
1065  (ds.sHistory[1])->putScalar(0.0);
1066 
1067  // lead current Q compontent history
1070 
1071  // store history
1072  *(ds.stoHistory[0]) = *(ds.currStorePtr);
1073  (ds.stoHistory[1])->putScalar(0.0);
1074 
1075  // lead current history
1077  (ds.leadCurrentHistory[1])->putScalar(0.0);
1081  (ds.leadDeltaVHistory[1])->putScalar(0.0);
1082  }
1083 
1084  // Coefficient initialization
1085  sec.numberOfSteps_ = 0; // number of total time integration steps taken
1086  sec.currentOrder_ = 1;
1087  // sec.usedOrder_ = 1;
1088  // if (sec.currentTime == sec.initialTime)
1089  // {
1090  sec.usedOrder_ = 1;
1091  sec.psi_[0] = sec.currentTimeStep;
1092  sec.cj_ = 1/sec.psi_[0];
1093  // }
1094  sec.nscsco_ = 0;
1095  if (DEBUG_TIME && isActive(Diag::TIME_HISTORY))
1096  {
1097  Xyce::dout() << std::endl
1098  << Xyce::section_divider << std::endl
1099  << " Gear12::initialize" << std::endl
1100  << "\n xHistory: \n" << std::endl;
1101  (ds.xHistory[0])->printPetraObject(Xyce::dout());
1102  Xyce::dout() << std::endl;
1103  (ds.xHistory[1])->printPetraObject(Xyce::dout());
1104  Xyce::dout() << std::endl
1105  << "\n qHistory: \n" << std::endl;
1106  (ds.qHistory[0])->printPetraObject(Xyce::dout());
1107  Xyce::dout() << std::endl;
1108  (ds.qHistory[1])->printPetraObject(Xyce::dout());
1109  Xyce::dout() << std::endl
1110  << "\n sHistory: \n" << std::endl;
1111  (ds.sHistory[0])->printPetraObject(Xyce::dout());
1112  Xyce::dout() << std::endl;
1113  (ds.sHistory[1])->printPetraObject(Xyce::dout());
1114  Xyce::dout() << std::endl
1115  << "\n" << "currentTimeStep = " << currentTimeStep << "\n" << std::endl
1116  << "\n" << "time_to_stop = " << time_to_stop << "\n" << std::endl
1117  << Xyce::section_divider << std::endl;
1118  }
1119 
1121 }
1122 
1123 //-----------------------------------------------------------------------------
1124 // Function : Gear12::initializeSensitivities
1125 // Purpose :
1126 // Special Notes :
1127 // Scope : public
1128 // Creator : Eric Keiter, SNL
1129 // Creation Date :
1130 //-----------------------------------------------------------------------------
1132 {
1133  int numParams = ds.sensRHSPtrVector.size();
1134  for (int ip=0; ip<numParams;++ip)
1135  {
1136  std::vector<Linear::Vector*> & dqdpHistory = ds.dqdpHistory[ip];
1137  std::vector<Linear::Vector*> & dXdpHistory = ds.dXdpHistory[ip];
1138  std::vector<Linear::Vector*> & dQdxdXdpHistory = ds.dQdxdXdpHistory[ip];
1139 
1140  Linear::Vector * currDQdxDxdpPtr = ds.currDQdxDXdpPtrVector[ip];
1141  Linear::Vector * currDxdpPtr = ds.currDXdpPtrVector[ip];
1142  Linear::Vector * currDqdpPtr = ds.currDqdpPtrVector[ip];
1143 
1144  // dQdx*dXdp matvec history
1145  *(dQdxdXdpHistory[0]) = *(currDQdxDxdpPtr);
1146  *(dQdxdXdpHistory[1]) = *(currDQdxDxdpPtr);
1147 
1148  // dXdp history
1149  *(dXdpHistory[0]) = *(currDxdpPtr);
1150  *(dXdpHistory[1]) = *(currDxdpPtr);
1151 
1152  // dqdp history
1153  *(dqdpHistory[0]) = *(currDqdpPtr);
1154  *(dqdpHistory[1]) = *(currDqdpPtr);
1155  }
1156 }
1157 
1158 //-----------------------------------------------------------------------------
1159 // Function : Gear12::setTwoLevelTimeInfo
1160 // Purpose :
1161 // Special Notes :
1162 // Scope : public
1163 // Creator : Eric Keiter, SNL
1164 // Creation Date : 03/01/07
1165 //-----------------------------------------------------------------------------
1166 void
1168 {
1169  // set initial step-size
1170  double time_to_stop = sec.stopTime - sec.currentTime;
1171 
1172 
1173  // x history
1174  *(ds.xHistory[0]) = *(ds.currSolutionPtr);
1175  *(ds.xHistory[1]) = *(ds.currSolutionPtr);
1176 
1177  // q history
1178  *(ds.qHistory[0]) = *(ds.daeQVectorPtr);
1179  *(ds.qHistory[1]) = *(ds.daeQVectorPtr);
1180 
1181  // state history
1182  *(ds.sHistory[0]) = *(ds.currStatePtr);
1183  (ds.sHistory[1])->putScalar(0.0);
1184 
1185  // Coefficient initialization
1186  sec.numberOfSteps_ = 0; // number of total time integration steps taken
1187  sec.usedOrder_ = 1;
1188  sec.psi_[0] = sec.currentTimeStep;
1189  sec.cj_ = 1/sec.psi_[0];
1190  sec.nscsco_ = 0;
1191 }
1192 
1193 //-----------------------------------------------------------------------------
1194 // Function : Gear12::checkReduceOrder()
1195 // Purpose : check whether to reduce order independent of local error test
1196 // Special Notes :
1197 // Scope : public
1198 // Creator : Ting Mei, SNL
1199 // Creation Date : 10/21/07
1200 //-----------------------------------------------------------------------------
1202 {
1203 
1204 }
1205 
1206 //-----------------------------------------------------------------------------
1207 // Function : Gear12::rejectStep()
1208 // Purpose : code to restore history, choose new order/step-size
1209 // Special Notes :
1210 // Scope : public
1211 // Creator : Ting Mei, SNL
1212 // Creation Date : 10/21/07
1213 //-----------------------------------------------------------------------------
1214 void
1216  const TIAParams & tia_params)
1217 {
1218  // This routine puts its output in newTimeStep_ and sec.newOrder_
1219 
1220  // This routine changes the following variables:
1221  // lastAttemptedTimeStep, sec.initialPhase_, sec.nef_, sec.psi_, newTimeStep_,
1222  // sec.newOrder_, sec.currentOrder_, currentTimeStep_, ds.xHistory,
1223  // ds.qHistory, nextTimePt, nextTime, currentTimeStepRatio,
1224  // currentTimeStepSum, nextTimePt
1225 
1226  // This routine reades but does not change the following variables:
1227  // stepAttemptStatus, sec.r_factor_, sec.r_safety_, sec.Est_, sec.r_fudge_, sec.r_min_, sec.r_max_,
1228  // minTimeStep, maxTimeStep, currentTime, stopTime, lastTimeStep
1229 
1230  sec.TimeStepLimitedbyBP = false;
1231 
1232  if (DEBUG_TIME && isActive(Diag::TIME_STEP))
1233  {
1234  Xyce::dout() << std::endl
1235  << Xyce::section_divider << std::endl
1236  << " Gear12::rejectStep" << std::endl;
1237  }
1238 
1239  // Only update the time step if we are NOT running constant stepsize.
1240  bool adjustStep = !tia_params.constantTimeStepFlag;
1241 
1243 
1244 
1245  double newTimeStep_ = sec.currentTimeStep;
1246  double rr = 1.0; // step size ratio = new step / old step
1247  if ((sec.stepAttemptStatus == false) && (adjustStep))
1248  {
1250  {
1251  newTimeStep_ = sec.currentTimeStep/8;
1252  }
1253  else
1254  {
1255  sec.initialPhase_ = false;
1256  sec.nef_++;
1257  restoreHistory();
1258  // restore sec.psi_
1259  // for (int i=1;i<=sec.currentOrder_;++i)
1260  // sec.psi_[i-1] = sec.psi_[i] - sec.currentTimeStep;
1261 
1262  if (sec.nef_ >= sec.max_LET_fail_)
1263  {
1264  std::string msg = "Gear12::rejectStep: ";
1265  msg += " Maximum number of local error test failures. ";
1266  N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::DEV_FATAL_0, msg);
1267  }
1268 
1269  if ((sec.newtonConvergenceStatus <= 0))
1270  {
1271  /// 11/11/05 erkeite: If the Newton solver fails, don't
1272  // rely on the error estimate - it may be full of Nan's.
1273  // rr = sec.r_min_;
1274 
1275  newTimeStep_ = sec.currentTimeStep/8;
1276  // sec.currentOrder_ = 1;
1278  // if (sec.nef_ > 2) sec.newOrder_ = 1;//consistent with block below.
1279  }
1280  else
1281  {
1282  // 03/11/04 tscoffe: Here is the block for choosing order &
1283  // step-size when the local error test FAILS (but Newton
1284  // succeeded).
1285  if (sec.nef_ == 1) // first local error test failure
1286  {
1287  // sec.estOverTol_
1288  sec.Est_ = sec.estOverTol_;
1289 
1290  rr = sec.tolAimFac_/(sec.estOverTol_ + 0.0001);
1291  rr = pow(rr, 1.0/(sec.currentOrder_+1.0));
1292  rr = std::max(sec.r_min_,std::min(sec.r_max_,rr));
1293 
1294  newTimeStep_ = rr * sec.currentTimeStep;
1295 
1296  // sec.currentOrder_ = 1;
1297  // sec.currentOrder_ = sec.minOrder_;
1298  }
1299  else // if (sec.nef_ == 2) // second Dae failure
1300  {
1301  rr = sec.r_min_;
1302  newTimeStep_ = rr * sec.currentTimeStep;
1303 
1304  // sec.currentOrder_ = 1;
1306  }
1307  }
1308  if (DEBUG_TIME && isActive(Diag::TIME_STEP) && isActive(Diag::TIME_COEFFICIENTS))
1309  {
1310  Xyce::dout() << " currentTimeStep = " << sec.currentTimeStep << std::endl
1311  << " numberOfSteps_ = " << sec.numberOfSteps_ << std::endl
1312  << " currentOrder_ = " << sec.currentOrder_ << std::endl
1313  << " nscsco_ = " << sec.nscsco_ << std::endl
1314  << " alpha_[0] = " << sec.alpha_[0] << std::endl
1315  << " alpha_[1] = " << sec.alpha_[1] << std::endl
1316  << " alpha_[2] = " << sec.alpha_[2] << std::endl
1317  << " alpha_[3] = " << sec.alpha_[3] << std::endl
1318  << " alpha_[4] = " << sec.alpha_[4] << std::endl
1319  << " psi_[0] = " << sec.psi_[0] << std::endl
1320  << " psi_[1] = " << sec.psi_[1] << std::endl
1321  << " psi_[2] = " << sec.psi_[2] << std::endl
1322  << " psi_[3] = " << sec.psi_[3] << std::endl
1323  << " psi_[4] = " << sec.psi_[4] << std::endl
1324  << " sigma_[0] = " << sec.sigma_[0] << std::endl
1325  << " sigma_[1] = " << sec.sigma_[1] << std::endl
1326  << " sigma_[2] = " << sec.sigma_[2] << std::endl
1327  << " sigma_[3] = " << sec.sigma_[3] << std::endl
1328  << " sigma_[4] = " << sec.sigma_[4] << std::endl
1329  << " rr = " << rr << std::endl
1330  << " r_factor_ = " << sec.r_factor_ << std::endl
1331  << " r_safety_ = " << sec.r_safety_ << std::endl
1332  << " Est_ = " << sec.Est_ << std::endl
1333  << " r_fudge_ = " << sec.r_fudge_ << std::endl
1334  << " newOrder_ = " << sec.newOrder_ << std::endl
1335  << " currentTimeStep = " << sec.currentTimeStep << std::endl
1336  << " newTimeStep_ = " << newTimeStep_ << std::endl;
1337  }
1338  }
1339  }
1340  else if ((sec.stepAttemptStatus == false) & (!adjustStep))
1341  {
1342  std::string tmp = " Gear12:rejectStep: Warning: Local error test failed with constant step-size.\n";
1343  Xyce::dout() << tmp << std::endl;
1344  }
1345 
1346  // If the step needs to be adjusted:
1347  if (adjustStep)
1348  {
1349  newTimeStep_ = std::max(newTimeStep_, sec.minTimeStep);
1350  newTimeStep_ = std::min(newTimeStep_, sec.maxTimeStep);
1351 
1352  double nextTimePt = sec.currentTime + newTimeStep_;
1353 
1354  if (nextTimePt > sec.stopTime)
1355  {
1356  nextTimePt = sec.stopTime;
1357  newTimeStep_ = sec.stopTime - sec.currentTime;
1358  sec.TimeStepLimitedbyBP = true;
1359  }
1360 
1361  sec.nextTime = nextTimePt;
1362 
1363  sec.currentTimeStepRatio = newTimeStep_/sec.lastTimeStep;
1364  sec.currentTimeStepSum = newTimeStep_ + sec.lastTimeStep;
1365 
1366  if (DEBUG_TIME && isActive(Diag::TIME_STEP))
1367  {
1368  Xyce::dout() << " newTimeStep_ = " << newTimeStep_ << std::endl
1369  << " nextTime = " << sec.nextTime << std::endl;
1370  }
1371 
1372  sec.currentTimeStep = newTimeStep_;
1373  }
1374  else // if time step is constant for this step:
1375  {
1376  double nextTimePt = sec.currentTime + sec.currentTimeStep;
1377 
1378  if (nextTimePt > sec.stopTime)
1379  {
1380  nextTimePt = sec.stopTime;
1382  }
1383 
1386 
1387  sec.nextTime = nextTimePt;
1388  }
1389  if (DEBUG_TIME && isActive(Diag::TIME_STEP))
1390  {
1391  Xyce::dout() << Xyce::section_divider << std::endl;
1392  }
1393 }
1394 
1395 //-----------------------------------------------------------------------------
1396 // Function : Gear12::rejectStepForHabanero
1397 // Purpose : step rejection, but from an outside program (Habanero API)
1398 // Special Notes :
1399 // Scope : public
1400 // Creator : Eric Keiter, SNL
1401 // Creation Date : 08/11/09
1402 //-----------------------------------------------------------------------------
1404 {
1405  restoreHistory();
1407 }
1408 
1409 //-----------------------------------------------------------------------------
1410 // Function : Gear12::completeStep()
1411 // Purpose : code to update history, choose new order/step-size
1412 // Special Notes :
1413 // Scope : public
1414 // Creator : Ting Mei, SNL
1415 // Creation Date : 10/21/07
1416 //-----------------------------------------------------------------------------
1417 void Gear12::completeStep(const TIAParams &tia_params)
1418 {
1419  sec.TimeStepLimitedbyBP = false;
1420 
1421  sec.numberOfSteps_ ++;
1422  sec.nef_ = 0;
1425 
1426  if (DEBUG_TIME && isActive(Diag::TIME_STEP))
1427  {
1428  Xyce::dout() << std::endl
1429  << Xyce::section_divider << std::endl
1430  << " Gear12::completeStep" << std::endl;
1431  }
1432 
1433  // Only update the time step if we are NOT running constant stepsize.
1434  bool adjustStep = !tia_params.constantTimeStepFlag;
1435 
1437 
1438  double newTimeStep_ = sec.currentTimeStep;
1439  double rr = 1.0; // step size ratio = new step / old step
1440  // 03/11/04 tscoffe: Here is the block for choosing order & step-size when
1441  // the local error test PASSES (and Newton succeeded).
1443  sec.lastTimeStepRatio = sec.currentTimeStepRatio; // copied from calcTStep1
1444  sec.lastTimeStepSum = sec.currentTimeStepSum; // copied from calcTStep1
1445  int orderDiff = sec.currentOrder_ - sec.usedOrder_;
1448 
1449  if (DEBUG_TIME && isActive(Diag::TIME_STEP))
1450  {
1451  Xyce::dout() << " initialPhase_ = " << sec.initialPhase_ << std::endl
1452  << " rr = " << rr << std::endl
1453  << " currentTimeStep = " << sec.currentTimeStep << std::endl
1454  << " currentTime = " << sec.currentTime << std::endl
1455  << " nextTime = " << sec.nextTime << std::endl
1456  << " newTimeStep_ = " << newTimeStep_ << std::endl
1457  << " minTimeStep = " << sec.minTimeStep << std::endl
1458  << " maxTimeStep = " << sec.maxTimeStep << std::endl;
1459  }
1460 
1461  // 03/22/04 tscoffe: Note that updating the history has nothing to do with
1462  // the step-size and everything to do with the newton correction vectors.
1463 
1464 
1465  /* if (sec.numberOfSteps_ >= 2)
1466  {
1467  sec.currentOrder_ = 2;
1468  // (ds.relErrTolPtr)->putScalar(1e-2);
1469  }
1470  */
1472  {
1473 
1474  if (sec.numberOfSteps_ >= 2 && sec.maxOrder_ == 2)
1475  {
1476  sec.currentOrder_ = 2;
1477  }
1478 
1479  rr = 1;
1480 
1481  if (sec.nIterations <= tia_params.NLmin)
1482  rr = 2;
1483 
1484  if (sec.nIterations > tia_params.NLmax)
1485  rr = 1.0/8;
1486 
1487  newTimeStep_ = rr*sec.currentTimeStep;
1488  }
1489  else
1490  {
1491  rr = sec.tolAimFac_/(sec.estOverTol_ + 0.0001);
1492  rr = pow(rr, 1.0/(sec.currentOrder_+1.0));
1493 
1494  if (sec.numberOfSteps_ >= 2 && sec.maxOrder_ == 2)
1495  {
1496  if (sec.currentOrder_ == 1)
1497  {
1498  sec.currentOrder_ = 2;
1499  rr = sec.tolAimFac_/(sec.estOverTol_ + 0.0001);
1500  rr = pow(rr, 1.0/(sec.currentOrder_+1.0));
1501 
1502  if (rr <= 1.05)
1503  {
1504  // sec.currentOrder_ = 1;
1506  }
1507  }
1508  }
1509  if (DEBUG_TIME && isActive(Diag::TIME_STEP))
1510  {
1511  Xyce::dout() << " currentOrder_ = " << sec.currentOrder_ << std::endl;
1512  Xyce::dout() << " r_safety = " << sec.r_safety_ << std::endl;
1513  Xyce::dout() << " r_fudge_ = " << sec.r_fudge_ << std::endl;
1514  Xyce::dout() << " r_hincr_ = " << sec.r_hincr_ << std::endl;
1515  Xyce::dout() << " r_hincr_test_ = " << sec.r_hincr_test_ << std::endl;
1516  Xyce::dout() << " Est = " << sec.Est_ << std::endl;
1517  Xyce::dout() << " raw rr = " << rr << std::endl;
1518  }
1519 
1520  if (rr >= sec.r_hincr_test_)
1521  {
1522  rr = sec.r_hincr_;
1523  newTimeStep_ = rr*sec.currentTimeStep;
1524  }
1525  else if (rr <= 1)
1526  {
1527  rr = std::max(sec.r_min_,std::min(sec.r_max_,rr));
1528  newTimeStep_ = rr*sec.currentTimeStep;
1529  }
1530  }
1531 
1532  updateHistory();
1533 
1534  newTimeStep_ = std::max(newTimeStep_, sec.minTimeStep);
1535  newTimeStep_ = std::min(newTimeStep_, sec.maxTimeStep);
1536 
1537  // 12/01/05 tscoffe: This is necessary to avoid currentTimeStep == 0 right
1538  // before a breakpoint. So I'm checking to see if currentTime is identically
1539  // equal to stopTime, in which case we are right before a breakpoint and we
1540  // should not adjust currentStepSize because that would result in
1541  // currentStepSize == 0.
1542  // if (sec.currentTime < sec.stopTime)
1543  if ((sec.stopTime - sec.currentTime) >= sec.minTimeStep)
1544  {
1545  // If the step needs to be adjusted:
1546  if (adjustStep)
1547  {
1548  // newTimeStep_ = Xycemax(newTimeStep_, sec.minTimeStep);
1549  // newTimeStep_ = Xycemin(newTimeStep_, sec.maxTimeStep);
1550 
1551  double nextTimePt = sec.currentTime + newTimeStep_;
1552 
1553  if (nextTimePt > sec.stopTime)
1554  {
1555 
1556  sec.savedTimeStep = newTimeStep_;
1557 
1558  nextTimePt = sec.stopTime;
1559  newTimeStep_ = sec.stopTime - sec.currentTime;
1560  sec.TimeStepLimitedbyBP = true;
1561  }
1562 
1563  sec.nextTime = nextTimePt;
1564 
1565  sec.currentTimeStepRatio = newTimeStep_/sec.lastTimeStep;
1566  sec.currentTimeStepSum = newTimeStep_ + sec.lastTimeStep;
1567 
1568  if (DEBUG_TIME && isActive(Diag::TIME_STEP))
1569  {
1570  Xyce::dout() << " nextTime = " << sec.nextTime << std::endl;
1571  Xyce::dout() << " newTimeStep_ = " << newTimeStep_ << std::endl;
1572  }
1573 
1574 
1575  sec.currentTimeStep = newTimeStep_;
1576  }
1577  else // if time step is constant for this step:
1578  {
1579  double nextTimePt = sec.currentTime + sec.currentTimeStep;
1580 
1581  if (nextTimePt > sec.stopTime)
1582  {
1584 
1585  nextTimePt = sec.stopTime;
1587  }
1588 
1591 
1592  sec.nextTime = nextTimePt;
1593  }
1594  }
1595 
1596  if (DEBUG_TIME && isActive(Diag::TIME_STEP))
1597  {
1598  Xyce::dout() << Xyce::section_divider << std::endl;
1599  }
1600 
1601 // sec.currentTimeStep = newTimeStep_;
1602 }
1603 
1604 //-----------------------------------------------------------------------------
1605 // Function : Gear12::updateStateDeriv
1606 // Purpose :
1607 // Special Notes :
1608 // Scope : public
1609 // Creator : Ting Mei, SNL
1610 // Creation Date : 11/17/05
1611 //-----------------------------------------------------------------------------
1613 {
1615  linearCombo(sec.alpha_[0],*ds.nextStatePtr, sec.alpha_[1],*ds.sn0Ptr);
1616 
1617  if (sec.currentOrder_ == 2)
1618  {
1620  linearCombo(1.0,*ds.nextStateDerivPtr, sec.alpha_[2], *(ds.sHistory[1]));
1621  }
1622 
1624 
1625  if (DEBUG_TIME && isActive(Diag::TIME_DUMP_SOLUTION_ARRAYS))
1626  {
1627  Xyce::dout() << "\n next state Ptr: \n" << std::endl;
1628  ds.nextStatePtr->printPetraObject(Xyce::dout());
1629  Xyce::dout() << std::endl;
1630 
1631  Xyce::dout() << "\n sn0: \n" << std::endl;
1632  ds.sn0Ptr->printPetraObject(Xyce::dout());
1633  Xyce::dout() << std::endl;
1634 
1635  Xyce::dout() << "\n next State Deriv: \n" << std::endl;
1636  ds.nextStateDerivPtr->printPetraObject(Xyce::dout());
1637  Xyce::dout() << std::endl;
1638  }
1639 }
1640 
1641 //-----------------------------------------------------------------------------
1642 // Function : OneStep::updateLeadCurrent
1643 // Purpose : calculates lead currents in store vector with
1644 // the storeLeadCurrQVec.
1645 // Special Notes :
1646 // Scope : public
1647 // Creator : Richard Schiek, Electrical Systems Modeling, SNL
1648 // Creation Date : 03/22/2013
1649 //-----------------------------------------------------------------------------
1651 {
1653  linearCombo(sec.alpha_[0],*ds.nextStoreLeadCurrQPtr, sec.alpha_[1],*ds.stoQn0Ptr);
1654 
1655  if (sec.currentOrder_ == 2)
1656  {
1658  linearCombo(1.0,*ds.nextStoreLeadCurrQDerivPtr, sec.alpha_[2], *(ds.stoLeadCurrQHistory[1]));
1659  }
1660 
1662 
1663  ds.nextStorePtr->linearCombo(1.0,*ds.nextStorePtr,1.0,*ds.nextStoreLeadCurrQDerivPtr);
1664 
1665  if (DEBUG_TIME && isActive(Diag::TIME_DUMP_SOLUTION_ARRAYS))
1666  {
1667  Xyce::dout() << "\n next store Ptr: \n" << std::endl;
1668  ds.nextStorePtr->printPetraObject(Xyce::dout());
1669  Xyce::dout() << std::endl;
1670  }
1671 }
1672 
1673 //-----------------------------------------------------------------------------
1674 // Function : OneStep::updateLeadCurrentVec
1675 // Purpose : calculates lead currents in lead current vector with
1676 // the leadCurrQVec.
1677 // Special Notes :
1678 // Scope : public
1679 // Creator : Richard Schiek, Electrical Systems Modeling, SNL
1680 // Creation Date : 03/22/2013
1681 //-----------------------------------------------------------------------------
1683 {
1686 
1687  if (sec.currentOrder_ == 2)
1688  {
1690  linearCombo(1.0,*ds.nextLeadCurrentQDerivPtr, sec.alpha_[2], *(ds.leadCurrentQHistory[1]));
1691  }
1692 
1694 
1696 
1697  if (DEBUG_TIME && isActive(Diag::TIME_DUMP_SOLUTION_ARRAYS))
1698  {
1699  Xyce::dout() << "\n next leadcurrent q Ptr: \n" << std::endl;
1700  ds.nextLeadCurrentPtr->printPetraObject(Xyce::dout());
1701  Xyce::dout() << std::endl;
1702  }
1703 }
1704 
1705 
1706 //-----------------------------------------------------------------------------
1707 // Function : Gear12::getInitialQnorm
1708 // Purpose : Needed by 2-level solves.
1709 // Special Notes :
1710 // Scope : public
1711 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
1712 // Creation Date : 03/18/07
1713 //-----------------------------------------------------------------------------
1715 {
1716  tle.q1HistorySum = ds.partialSum_q1();
1717 }
1718 
1719 //-----------------------------------------------------------------------------
1720 // Function : Gear12::setupTwoLevelError
1721 // Purpose : Needed by 2-level solves.
1722 // Special Notes :
1723 // Scope : public
1724 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
1725 // Creation Date : 03/15/07
1726 //-----------------------------------------------------------------------------
1728 {
1729  tle.xErrorSum = ds.partialErrorNormSum ();
1734  tle.innerSize = ds.globalLength ();
1735 
1736  if (DEBUG_TIME && isActive(Diag::TIME_ERROR))
1737  Xyce::dout() << tle;
1738 }
1739 
1741 {
1742  if (sec.currentTimeStep < 1e-30)
1743  {
1744  Xyce::Report::UserWarning() << "Excessively small current time step, incorrectly returning with large value";
1745 
1746  return leadingCoeff * 1.e+30;
1747  }
1748 
1749  return leadingCoeff / sec.currentTimeStep;
1750 }
1751 
1752 } // namespace TimeIntg
1753 } // namespace Xyce
bool saveOutputSolution(Parallel::Machine comm, IO::InitialConditionsManager &initial_conditions_manager, const NodeNameMap &node_name_map, const TIAParams &tia_params, Linear::Vector *solnVecPtr, const double saveTime, const bool doNotInterpolate)
Definition: N_TIA_Gear12.C:653
bool interpolateMPDESolution(std::vector< double > &timepoint, Linear::Vector *tmpSolVectorPtr)
Definition: N_TIA_Gear12.C:450
void rejectStep(const TIAParams &tia_params)
Linear::Vector * sNewtonCorrectionPtr
Linear::Vector * nextLeadCurrentQPtr
Linear::Vector * leadCurrentQn0Ptr
Gear12(const TIAParams &tia_params, StepErrorControl &step_error_control, DataStore &data_store)
Definition: N_TIA_Gear12.C:104
Linear::Vector * tmpLeadDeltaVPtr
std::vector< Linear::Vector * > nextDqdpPtrVector
static const char * name
Definition: N_TIA_Gear12.h:75
std::vector< std::vector< Linear::Vector * > > dQdxdXdpHistory
Pure virtual class to augment a linear system.
int nIterations
Number of newton iterations.
std::vector< double > dOdpVec_
std::vector< double > scaled_dOdpVec_
void getInitialQnorm(TwoLevelError &tle) const
std::vector< Linear::Vector * > nextDXdpPtrVector
Linear::Vector * tmpStaVectorPtr
Linear::Vector * currStorePtr
std::vector< double > scaled_dOdpAdjVec_
std::vector< Linear::Vector * > leadDeltaVHistory
Linear::Vector * tmpSolVectorPtr
std::vector< Linear::Vector * > nextDbdpPtrVector
double partialSum_m2(int currentOrder)
bool interpolateSolution(double timepoint, Linear::Vector *tmpSolVectorPtr, std::vector< Linear::Vector * > &historyVec)
Definition: N_TIA_Gear12.C:407
int errorAnalysisOption
Error analysis option.
Linear::Vector * tmpStoVectorPtr
std::vector< Linear::Vector * > nextDfdpPtrVector
void completeStep(const TIAParams &tia_params)
bool printOutputSolution(Analysis::OutputMgrAdapter &outputManagerAdapter, const TIAParams &tia_params, const double time, Linear::Vector *solnVecPtr, const bool doNotInterpolate, const std::vector< double > &outputInterpolationTimes, bool skipPrintLineOutput)
Definition: N_TIA_Gear12.C:569
std::vector< Linear::Vector * > qHistory
Linear::Vector * nextLeadDeltaVPtr
Linear::Vector * currStatePtr
std::vector< double > objectiveVec_
std::vector< Linear::Vector * > currDXdpPtrVector
std::vector< Linear::Vector * > leadCurrentHistory
bool constantTimeStepFlag
Constant time step integration flag.
static TimeIntegrationMethod * factory(const TIAParams &tia_params, StepErrorControl &step_error_control, DataStore &data_store)
Definition: N_TIA_Gear12.C:88
void initialize(const TIAParams &tia_params)
Definition: N_TIA_Gear12.C:970
Linear::Vector * daeQVectorPtr
Linear::Vector * tmpLeadCurrentVectorPtr
double partialSum_p1(int currentOrder, int maxOrder)
Linear::Vector * daeFVectorPtr
Linear::Vector * qNewtonCorrectionPtr
Linear::Vector * currLeadCurrentQPtr
double leadingCoeff
Time-integration method leading coefficient value.
Definition: N_TIA_Gear12.h:258
Linear::Vector * nextStoreLeadCurrQDerivPtr
std::vector< Linear::Vector * > leadCurrentQDerivHistory
Linear::Matrix * dFdxMatrixPtr
Linear::Matrix * JMatrixPtr
Linear::Vector * nextStatePtr
std::vector< Linear::Vector * > leadCurrentQHistory
DataStore & ds
Reference to the TIA data-store object.
Definition: N_TIA_Gear12.h:256
Linear::Vector * dFdxdVpVectorPtr
double computeExpoStepAdjust(double stepadjust)
Definition: N_TIA_Gear12.C:217
std::vector< std::vector< Linear::Vector * > > dqdpHistory
Linear::Vector * currLeadDeltaVPtr
bool printWaMPDEOutputSolution(Analysis::OutputMgrAdapter &outputManagerAdapter, const double time, Linear::Vector *solnVecPtr, const std::vector< double > &fastTimes, const int phiGID)
Definition: N_TIA_Gear12.C:549
Linear::Vector * currStoreLeadCurrQPtr
Linear::Vector * nextSolutionPtr
void getTwoLevelError(TwoLevelError &tle) const
Linear::Vector * RHSVectorPtr
bool printMPDEOutputSolution(Analysis::OutputMgrAdapter &outputManagerAdapter, const double time, Linear::Vector *solnVecPtr, const std::vector< double > &fastTimes)
Definition: N_TIA_Gear12.C:531
Linear::Vector * nextStorePtr
Linear::Vector * stoQn0Ptr
Linear::Vector * dQdxdVpVectorPtr
Linear::Vector * currLeadCurrentPtr
std::vector< double > dOdpAdjVec_
double partialTimeDeriv() const
std::vector< Linear::Vector * > lastDQdxDXdpPtrVector
Linear::Vector * nextLeadCurrentQDerivPtr
Linear::Vector * newtonCorrectionPtr
Linear::Vector * tmpLeadCurrentQDerivVectorPtr
Linear::Vector * currSolutionPtr
StepErrorControl & sec
Reference to step-error control object.
Definition: N_TIA_Gear12.h:257
std::vector< Linear::Vector * > stoHistory
void obtainSensitivityPredictors()
Definition: N_TIA_Gear12.C:211
Linear::Vector * nextStoreLeadCurrQPtr
Linear::Vector * nextStateDerivPtr
std::vector< Linear::Vector * > xHistory
std::vector< Linear::Vector * > sensRHSPtrVector
Linear::Matrix * dQdxMatrixPtr
void tranOutput(double time, Linear::Vector &currSolutionPtr, Linear::Vector &stateVecPtr, Linear::Vector &storeVecPtr, Linear::Vector &lead_current_vector, Linear::Vector &junction_voltage_vector, Linear::Vector &lead_current_dqdt_vector, std::vector< double > &objectiveVec_, std::vector< double > &dOdpVec_, std::vector< double > &dOdpAdjVec_, std::vector< double > &scaled_dOdpVec_, std::vector< double > &scaled_dOdpAdjVec_, bool skipPrintLineOutput=false)
std::vector< Linear::Vector * > currDQdxDXdpPtrVector
double partialSum_m1(int currentOrder)
std::vector< std::vector< Linear::Vector * > > dXdpHistory
Linear::Vector * daeBVectorPtr
std::vector< Linear::Vector * > nextDQdxDXdpPtrVector
std::vector< Linear::Vector * > currDqdpPtrVector
std::vector< Linear::Vector * > stoLeadCurrQHistory
double timept_
Keep track of last interpolation point in printMPDEOutputSolution.
Definition: N_TIA_Gear12.h:255
Linear::Vector * nextLeadCurrentPtr
std::vector< Linear::Vector * > lastDXdpPtrVector
std::vector< Linear::Vector * > sHistory