47 #include <Xyce_config.h>
55 #include <N_ERH_ErrorMgr.h>
57 #include <N_PDS_Comm.h>
58 #include <N_PDS_Manager.h>
59 #include <N_PDS_Serial.h>
60 #include <N_PDS_MPI.h>
65 #include <N_UTL_BreakPoint.h>
66 #include <N_UTL_Diagnostic.h>
67 #include <N_UTL_FeatureTest.h>
68 #include <N_UTL_Functors.h>
69 #include <N_UTL_MachDepParams.h>
70 #include <N_UTL_SaveIOSState.h>
84 const std::string & netlist_filename,
89 wimPtr_(working_integration_method),
90 netlistFilename_(netlist_filename),
91 startingTimeStep(1.0e-10),
92 currentTimeStep(1.0e-10),
93 lastAttemptedTimeStep(1.0e-10),
94 lastTimeStep(1.0e-10),
97 maxTimeStepUser(1.0e+99),
99 savedTimeStep(1.0e-10),
106 currentTimeStepRatio(0.0),
107 currentTimeStepSum(0.0),
109 pauseSetAtZero(false),
110 lastTimeStepRatio(0.0),
111 lastTimeStepSum(0.0),
112 newtonConvergenceStatus(-1),
114 numberSuccessiveFailures(0),
115 stepAttemptStatus(true),
116 previousCallStepSuccessful(false),
118 TimeStepLimitedbyBP(false),
119 minStepPrecisionFac_(10.0),
120 newtonStepReduction_(0.25),
121 restartTimeStepScale_(0.005),
158 h0_max_factor_(0.005),
162 Tkm1_Tk_safety_(2.0),
163 Tkp1_Tk_safety_(0.5),
164 #ifndef Xyce_USE_Q_NORM
177 breakPointLess_(Util::BreakPoint::defaultTolerance_),
178 breakPoints_(breakPointLess_),
179 currentPauseBP(breakPoints_.end())
306 if (DEBUG_TIME && isActive(Diag::TIME_BREAKPOINTS))
308 Xyce::dout() <<
" after resetAll:" << std::endl;
310 Xyce::dout() <<
" currentPauseBP = " <<
currentPauseBP->value() << std::endl
311 << Xyce::section_divider << std::endl;
373 Parallel::Machine comm,
374 bool breakpoints_enabled,
376 bool min_time_steps_breakpoint_given,
377 double min_time_steps_breakpoint)
380 double diffStopTime = 0.0;
382 if (breakpoints_enabled)
393 if (itBP->bptype() == Xyce::Util::BreakPoint::PAUSE)
403 diffStopTime = fabs(stopTime-oldStopTime);
410 stopTime = itBP->value();
413 Parallel::AllReduce(comm, MPI_MIN, &stopTime, 1);
423 if (min_time_steps_breakpoint_given && (min_time_steps_breakpoint > 0) )
430 if (DEBUG_TIME && isActive(Diag::TIME_STEP))
432 Xyce::dout() << std::endl
433 <<
" stopTime = " <<
stopTime << std::endl
434 <<
" pauseTime = " <<
pauseTime << std::endl
436 <<
" oldStopTime = " << oldStopTime << std::endl
437 <<
" finalTime = " <<
finalTime << std::endl
440 << Xyce::section_divider << std::endl;
457 Parallel::Machine comm,
458 bool breakpoints_enabled)
462 if (breakpoints_enabled)
473 Parallel::AllReduce(comm, MPI_MIN, &nextTime, 1);
495 bool sAStatus(
false);
496 bool errorOptionStatus(
true);
497 bool testTimeIntegrationError(
false);
519 testTimeIntegrationError =
true;
523 if (!step_attempt_status)
525 testTimeIntegrationError =
false;
529 if (testTimeIntegrationError)
548 errorOptionStatus =
true;
550 errorOptionStatus =
false;
555 Xyce::dout() <<
"ERROROPTION=1: DOREJECTSTEP = ";
558 Xyce::dout() <<
"1" << std::endl;
562 Xyce::dout() <<
"0" << std::endl;
571 if (DEBUG_TIME && isActive(Diag::TIME_ERROR))
573 Xyce::dout() <<
"Trying to skip time integrator error checks: " <<
currentTimeStep
574 <<
" newton status " << step_attempt_status << std::endl;
584 step_attempt_status = step_attempt_status && errorOptionStatus;
586 step_attempt_status = step_attempt_status && sAStatus;
590 if (DEBUG_TIME && isActive(Diag::TIME_ERROR))
592 integrationStepReport(Xyce::dout(), step_attempt_status, sAStatus, testTimeIntegrationError, tia_params);
594 else if (VERBOSE_TIME)
615 bool step_attempt_status,
621 <<
" STEP STATUS: " << (step_attempt_status ?
" success" :
" fail")
636 if (isActive(Diag::TIME_PARAMETERS))
638 os <<
"\n estOverTol = " <<
estOverTol_ << std::endl
641 <<
"\nSTEP ATTEMPT STATUS:" << std::endl
642 <<
"NOTE:" << std::endl;
648 os <<
" We are running in variable stepsize mode " << std::endl
649 <<
" and we have NOT just passed a breakpoint. As such " << std::endl
650 <<
" for an integration step to succeed the " << std::endl
651 <<
" nonlinear solver must succeed AND the predictor" << std::endl
652 <<
" and corrector need to be close within a tolerance." << std::endl;
656 os <<
"ADDENDUM: This is with erroption=1 so predictor-corrector is ignored for step error control." << std::endl;
661 os <<
" We are either running constant stepsize " << std::endl
662 <<
" or we just passed a breakpoint. As such " << std::endl
663 <<
" the only criteria we use in accepting/rejecting" << std::endl
664 <<
" an integration step is the nonlinear solver" << std::endl
665 <<
" success/failure." << std::endl;
668 if (step_attempt_status)
670 os <<
"\n This has been a successful step:" << std::endl;
674 os <<
"\n This has NOT been a successful step:" << std::endl;
692 os <<
" - predictor vs. corrector analysis succeeded." << std::endl;
696 os <<
" - predictor vs. corrector analysis failed." << std::endl;
699 os <<
" (compare estOverTol with error tolerance above.)" << std::endl;
703 os <<
"If we had been using it << " << std::endl;
707 os <<
" - predictor vs. corrector analysis would have succeeded." << std::endl;
711 os <<
" - predictor vs. corrector analysis would have failed." << std::endl;
714 os <<
" (compare estOverTol with error tolerance above.)" << std::endl;
719 os <<
" predictor vs. corrector was not tested" << std::endl;
722 os << Xyce::section_divider << std::endl;
736 double initial_output_time,
740 bool bsuccess =
true;
755 setBreakPoint(Util::BreakPoint(final_time, Xyce::Util::BreakPoint::PAUSE), initial_time);
780 bool bsuccess =
true;
782 if (DEBUG_TIME && isActive(Diag::TIME_BREAKPOINTS))
784 Xyce::dout() << std::endl
785 << Xyce::section_divider << std::endl
786 <<
" StepErrorControl::updateBreakPoints. time = " <<
currentTime << std::endl
790 std::vector<Util::BreakPoint> tmpBP;
796 std::vector<Util::BreakPoint>::iterator iter;
797 std::vector<Util::BreakPoint>::iterator first = tmpBP.begin();
798 std::vector<Util::BreakPoint>::iterator last = tmpBP.end();
801 BreakPointSet::iterator itBP;
802 BreakPointSet::iterator itBP_2;
807 for (iter=first; iter!=last; ++iter)
815 if (DEBUG_TIME &&isActive(Diag::TIME_BREAKPOINTS))
819 Xyce::dout() <<
netlistFilename_ <<
" breakPoints_ vector container, before any removals:" << std::endl;
822 for (itBP = firstBP; itBP != lastBP; ++i, ++itBP)
826 Xyce::dout() << i <<
" " << itBP->value() << std::endl;
830 Xyce::dout() << i <<
" " << itBP->value() <<
" diff=" << (itBP->value()-itBP_2->value()) << std::endl;
835 Xyce::dout() <<
"" << std::endl;
863 if (DEBUG_TIME && isActive(Diag::TIME_BREAKPOINTS))
865 Xyce::dout() <<
" bpTol = " << bpTol << std::endl;
866 Xyce::dout() <<
" Must now eliminate new duplicates " << std::endl;
869 bool doneRemove =
false;
876 for (icount = 0, itBP=firstBP, itBP_2=firstBP;
880 double diff = (itBP->value() - itBP_2->value());
884 if (fabs(diff) < bpTol)
887 if (itBP->bptype() == Xyce::Util::BreakPoint::SIMPLE &&
888 itBP_2->bptype() == Xyce::Util::BreakPoint::SIMPLE)
900 Xyce::Util::BreakPoint::Type overridingType = itBP->bptype();
901 double minTime=std::min(itBP->value(),itBP_2->value());
906 if (itBP_2->bptype() != Xyce::Util::BreakPoint::SIMPLE)
908 overridingType = itBP_2->bptype();
912 Util::BreakPoint tmpBP(minTime, overridingType);
917 if (DEBUG_TIME && isActive(Diag::TIME_BREAKPOINTS))
918 Xyce::dout() <<
" Purging breakpoints, overriding with breakpoint of type " << tmpBP.bptype();
932 if (DEBUG_TIME && isActive(Diag::TIME_BREAKPOINTS))
936 Xyce::dout() <<
" breakPoints_ vector container after:" << std::endl;
939 for (itBP=firstBP;itBP!=lastBP;++i,++itBP)
943 Xyce::dout() << i <<
" " << itBP->value() <<
" type=" << itBP->bptype() << std::endl;
947 Xyce::dout() << i <<
" " << itBP->value() <<
" type=" << itBP->bptype() <<
" diff=" << (itBP->value()-itBP_2->value()) << std::endl;
953 Xyce::dout() << std::endl
954 << Xyce::section_divider << std::endl;
971 Parallel::Machine comm,
973 double suggestedMaxTimeStep)
975 bool bsuccess =
true;
977 if (DEBUG_TIME && isActive(Diag::TIME_STEP))
979 Xyce::dout() << Xyce::section_divider << std::endl
980 <<
" StepErrorControl::updateMaxTimeStep" << std::endl;
983 double maxDevStep = 1.0e+99;
1000 if( suggestedMaxTimeStep > 0.0 )
1010 if (maxDevStep > 0.0)
1020 Parallel::AllReduce(comm, MPI_MIN, &
maxTimeStep, 1);
1022 if (DEBUG_TIME && isActive(Diag::TIME_STEP))
1026 Xyce::dout() <<
" User did not specify a maximum time step." << std::endl;
1030 Xyce::dout() <<
" User specified a maximum time step. = " <<
maxTimeStepUser << std::endl;
1033 Xyce::dout() <<
" maxDevStep = " << maxDevStep << std::endl
1035 << Xyce::section_divider << std::endl;
1040 const std::string msg =
"Maximum Time step is invalid!\n";
1041 N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::DEV_FATAL_0, msg);
1057 bool bsuccess =
true;
1073 const Util::BreakPoint & breakpoint,
1074 double initial_time)
1076 if (breakpoint.bptype() == Xyce::Util::BreakPoint::SIMPLE)
1082 if (DEBUG_TIME && isActive(Diag::TIME_BREAKPOINTS))
1084 Xyce::dout() <<
"In setBreakPoint, got non-simple breakpoint of type "
1085 << breakpoint.bptype() <<
" at time " << breakpoint.value() << std::endl;
1123 Util::BreakPoint breakpoint,
1124 double initial_time)
1136 if ((breakpoint.bptype() > 0) && (breakpoint.value() == 0.0))
1155 if (DEBUG_TIME && isActive(Diag::TIME_BREAKPOINTS))
1159 <<
" encountered breakpoint " << breakpoint.value() <<
" current time is "
1178 double initial_time)
1195 BreakPointSet::const_iterator itBP;
1196 BreakPointSet::const_iterator itBP2;
1197 BreakPointSet::const_iterator firstBP =
breakPoints_.begin();
1198 BreakPointSet::const_iterator lastBP =
breakPoints_.end();
1203 for (i=0, itBP=firstBP;itBP!=lastBP;++i,++itBP)
1206 sprintf(tmp,
"%4d %16.8e type=%d",i,itBP->value(),itBP->bptype());
1208 sprintf(tmp,
"%4d %16.8e type=%d diff=%16.8e", i, itBP->value(),
1209 itBP->bptype(),(itBP->value()-itBP2->value()));
1211 os << std::string(tmp);
1240 int numdoubles = 21;
1242 int count =
sizeof(double)*numdoubles;
1243 count +=
sizeof(int)*numints;
1256 int baseClassSize = count;
1262 totalSize = baseClassSize;
1263 totalSize +=
sizeof(double) * numdoubles;
1264 totalSize +=
sizeof(int) * numints;
1269 totalSize = baseClassSize + 24*(numdoubles+numints);
1306 for(
int i = pos; i < (newPos); ++i) buf[i] =
' ';
1312 << Xyce::section_divider << std::endl
1320 <<
"lastTime: " <<
lastTime << std::endl
1322 <<
"nextTime: " <<
nextTime << std::endl
1328 Xyce::dout() << iterSD->value() <<
" ";
1330 Xyce::dout() << std::endl
1335 << Xyce::section_divider << std::endl << std::endl;
1347 comm->pack( &
lastTime, 1, buf, bsize, pos );
1349 comm->pack( &
nextTime, 1, buf, bsize, pos );
1358 comm->pack( &flag, 1, buf, bsize, pos );
1361 comm->pack( &
tolAimFac_, 1, buf, bsize, pos );
1366 BreakPointSet::iterator bpStart =
breakPoints_.begin();
1368 comm->pack( &size, 1, buf, bsize, pos );
1372 for( BreakPointSet::iterator iterSD = bpStart;
1373 iterSD != bpEnd; ++iterSD)
1375 val=iterSD->value();
1376 bptype=iterSD->bptype();
1377 if (!(bptype == Xyce::Util::BreakPoint::PAUSE && val ==
finalTime))
1379 comm->pack( &(val), 1, buf, bsize, pos );
1380 comm->pack( &(bptype), 1, buf, bsize, pos );
1384 comm->pack( &im, 1, buf, bsize, pos );
1386 comm->pack( &sN, 1, buf, bsize, pos );
1388 comm->pack( &tSN, 1, buf, bsize, pos );
1390 comm->pack( &bPRS, 1, buf, bsize, pos );
1392 comm->pack( &beginFlag, 1, buf, bsize, pos );
1399 int startIndex = pos;
1402 for(
int i = startIndex; i < (startIndex+count); ++i) buf[i] =
' ';
1404 std::ostringstream ost;
1405 ost.width(24);ost.precision(16);ost.setf(std::ios::scientific);
1434 BreakPointSet::iterator bpStart =
breakPoints_.begin();
1436 for( BreakPointSet::iterator iterSD = bpStart;
1437 iterSD != bpEnd; ++iterSD )
1439 if (!(iterSD->bptype() == Xyce::Util::BreakPoint::PAUSE && iterSD->value() ==
finalTime))
1441 ost << iterSD->value() <<
" ";
1442 ost << iterSD->bptype() <<
" ";
1454 ost << beginFlag <<
" ";
1456 std::string data( ost.str() );
1457 for(
unsigned int i = 0; i < data.length(); ++i ) buf[startIndex+i] = data[i];
1462 buf[startIndex+data.length()] =
'\0';
1463 pos += data.length();
1467 std::string outputString(buf);
1469 Xyce::dout() <<
"StepErrorControl UNPACKED output buffer:" << std::endl
1470 << outputString << std::endl;
1476 Xyce::dout() <<
"TIA Restart Data DUMP (DAE)! " <<
netlistFilename_ <<
"\n"
1477 << Xyce::section_divider << std::endl<<std::endl
1478 <<
"alphas_ = " <<
alphas_<<std::endl
1479 <<
"alpha0_ = " <<
alpha0_<<std::endl
1480 <<
"cj_ = " <<
cj_<<std::endl
1481 <<
"ck_ = " <<
ck_<<std::endl
1482 <<
"usedStep_ = " <<
usedStep_<<std::endl
1483 <<
"Ek_ = " <<
Ek_<<std::endl
1484 <<
"Ekm1_ = " <<
Ekm1_<<std::endl
1485 <<
"Ekm2_ = " <<
Ekm2_<<std::endl
1486 <<
"Ekp1_ = " <<
Ekp1_<<std::endl
1487 <<
"Est_ = " <<
Est_<<std::endl
1488 <<
"Tk_ = " <<
Tk_<<std::endl
1489 <<
"Tkm1_ = " <<
Tkm1_<<std::endl
1490 <<
"Tkm2_ = " <<
Tkm2_<<std::endl
1491 <<
"Tkp1_ = " <<
Tkp1_<<std::endl
1498 <<
"r_factor_ = " <<
r_factor_<<std::endl
1499 <<
"r_safety_ = " <<
r_safety_<<std::endl
1500 <<
"r_fudge_ = " <<
r_fudge_<<std::endl
1501 <<
"r_min_ = " <<
r_min_<<std::endl
1502 <<
"r_max_ = " <<
r_max_<<std::endl
1504 <<
"r_hincr_ = " <<
r_hincr_<<std::endl;
1506 for (
int i=0;i<6;++i)
1508 Xyce::dout() <<
" alpha_["<<i<<
"] = " <<
alpha_[i]<<std::endl
1509 <<
" sigma_["<<i<<
"] = " <<
sigma_[i]<<std::endl
1510 <<
" gamma_["<<i<<
"] = " <<
gamma_[i]<<std::endl
1511 <<
" beta_["<<i<<
"] = " <<
beta_[i]<<std::endl
1512 <<
" psi_["<<i<<
"] = " <<
psi_[i]<<std::endl;
1515 Xyce::dout() << Xyce::section_divider << std::endl << std::endl << std::endl;
1521 comm->pack( &
alphas_ , 1, buf, bsize, pos );
1522 comm->pack( &
alpha0_ , 1, buf, bsize, pos );
1523 comm->pack( &
cj_ , 1, buf, bsize, pos );
1524 comm->pack( &
ck_ , 1, buf, bsize, pos );
1525 comm->pack( &
usedStep_ , 1, buf, bsize, pos );
1526 comm->pack( &
Ek_ , 1, buf, bsize, pos );
1527 comm->pack( &
Ekm1_ , 1, buf, bsize, pos );
1528 comm->pack( &
Ekm2_ , 1, buf, bsize, pos );
1529 comm->pack( &
Ekp1_ , 1, buf, bsize, pos );
1530 comm->pack( &
Est_ , 1, buf, bsize, pos );
1531 comm->pack( &
Tk_ , 1, buf, bsize, pos );
1532 comm->pack( &
Tkm1_ , 1, buf, bsize, pos );
1533 comm->pack( &
Tkm2_ , 1, buf, bsize, pos );
1534 comm->pack( &
Tkp1_ , 1, buf, bsize, pos );
1535 comm->pack( &
h0_safety_ , 1, buf, bsize, pos );
1538 comm->pack( &
h_max_inv_ , 1, buf, bsize, pos );
1541 comm->pack( &
r_factor_ , 1, buf, bsize, pos );
1542 comm->pack( &
r_safety_ , 1, buf, bsize, pos );
1543 comm->pack( &
r_fudge_ , 1, buf, bsize, pos );
1544 comm->pack( &
r_min_ , 1, buf, bsize, pos );
1545 comm->pack( &
r_max_ , 1, buf, bsize, pos );
1547 comm->pack( &
r_hincr_ , 1, buf, bsize, pos );
1550 for (
int i=0;i<6;++i)
1552 comm->pack( &
alpha_[i], 1, buf, bsize, pos );
1553 comm->pack( &
sigma_[i], 1, buf, bsize, pos );
1554 comm->pack( &
gamma_[i], 1, buf, bsize, pos );
1555 comm->pack( &
beta_[i], 1, buf, bsize, pos );
1556 comm->pack( &
psi_[i], 1, buf, bsize, pos );
1561 comm->pack ( &
oldOrder_, 1, buf, bsize, pos);
1562 comm->pack ( &
maxOrder_, 1, buf, bsize, pos);
1563 comm->pack ( &
minOrder_, 1, buf, bsize, pos);
1564 comm->pack ( &
usedOrder_, 1, buf, bsize, pos);
1566 comm->pack ( &
nef_, 1, buf, bsize, pos);
1567 comm->pack ( &
nscsco_, 1, buf, bsize, pos);
1568 comm->pack ( &
newOrder_, 1, buf, bsize, pos);
1573 comm->pack ( &iP, 1, buf, bsize, pos);
1577 std::ostringstream ost;
1578 ost.width(24);ost.precision(16);ost.setf(std::ios::scientific);
1587 ost <<
Ekm1_ <<
" ";
1588 ost <<
Ekm2_ <<
" ";
1589 ost <<
Ekp1_ <<
" ";
1592 ost <<
Tkm1_ <<
" ";
1593 ost <<
Tkm2_ <<
" ";
1594 ost <<
Tkp1_ <<
" ";
1610 for (
int i=0;i<6;++i)
1615 ost <<
beta_[i]<<
" " ;
1616 ost <<
psi_[i]<<
" " ;
1635 std::string data( ost.str() );
1636 for(
unsigned int i = 0; i < data.length(); ++i ) buf[pos+i] = data[i];
1639 buf[pos+data.length()] =
'\0';
1641 if (DEBUG_RESTART) {
1642 std::string outputString(buf);
1644 Xyce::dout() <<
"StepErrorControlDAE UNPACKED output buffer:" << std::endl
1645 << outputString << std::endl;
1673 double & initial_time)
1685 comm->unpack(buf, bsize, pos, &
lastTime, 1);
1687 comm->unpack(buf, bsize, pos, &
nextTime, 1);
1696 comm->unpack(buf, bsize, pos, &flag, 1);
1700 comm->unpack(buf, bsize, pos, &
tolAimFac_, 1);
1709 BreakPointSet::iterator iterSD;
1710 BreakPointSet::iterator firstSD = tmpSet.begin();
1711 BreakPointSet::iterator lastSD = tmpSet.end();
1712 for (iterSD = firstSD; iterSD != lastSD; ++iterSD)
1717 if (iterSD->bptype() == Xyce::Util::BreakPoint::PAUSE)
1725 comm->unpack(buf, bsize, pos, &size, 1);
1727 for (
int i = 0; i < size; ++i)
1729 comm->unpack(buf, bsize, pos, &val, 1);
1730 comm->unpack(buf, bsize, pos, &bptype, 1);
1733 Util::BreakPoint TmpBP(val, bptype);
1735 if (TmpBP.bptype() == Xyce::Util::BreakPoint::PAUSE)
1743 comm->unpack(buf, bsize, pos, &im, 1);
1745 comm->unpack(buf, bsize, pos, &im, 1);
1747 comm->unpack(buf, bsize, pos, &im, 1);
1749 comm->unpack(buf, bsize, pos, &im, 1);
1751 comm->unpack(buf, bsize, pos, &im, 1);
1756 std::string str1(buf);
1757 int length = str1.size() - pos;
1758 std::string str2(str1,pos,length);
1760 std::istringstream ist( str2 );
1807 BreakPointSet::iterator iterSD;
1808 BreakPointSet::iterator firstSD = tmpSet.begin();
1809 BreakPointSet::iterator lastSD = tmpSet.end();
1810 for (iterSD = firstSD; iterSD != lastSD; ++iterSD)
1815 if (iterSD->bptype() == Xyce::Util::BreakPoint::PAUSE)
1825 for(
int i = 0; i < size; ++i )
1829 if (val > currentTime)
1831 Util::BreakPoint TmpBP(val, bptype);
1833 if (TmpBP.bptype() == Xyce::Util::BreakPoint::PAUSE)
1858 << Xyce::section_divider << std::endl
1866 <<
"lastTime: " <<
lastTime << std::endl
1868 <<
"nextTime: " <<
nextTime << std::endl
1872 for (BreakPointSet::iterator iterSD =
breakPoints_.begin();
1875 Xyce::dout() << iterSD->value() <<
" " << iterSD->bptype() << std::endl;
1877 Xyce::dout() << std::endl
1882 << Xyce::section_divider << std::endl << std::endl;
1889 comm->unpack(buf, bsize, pos, &
alphas_ , 1);
1890 comm->unpack(buf, bsize, pos, &
alpha0_ , 1);
1891 comm->unpack(buf, bsize, pos, &
cj_ , 1);
1892 comm->unpack(buf, bsize, pos, &
ck_ , 1);
1893 comm->unpack(buf, bsize, pos, &
usedStep_ , 1);
1894 comm->unpack(buf, bsize, pos, &
Ek_ , 1);
1895 comm->unpack(buf, bsize, pos, &
Ekm1_ , 1);
1896 comm->unpack(buf, bsize, pos, &
Ekm2_ , 1);
1897 comm->unpack(buf, bsize, pos, &
Ekp1_ , 1);
1898 comm->unpack(buf, bsize, pos, &
Est_ , 1);
1899 comm->unpack(buf, bsize, pos, &
Tk_ , 1);
1900 comm->unpack(buf, bsize, pos, &
Tkm1_ , 1);
1901 comm->unpack(buf, bsize, pos, &
Tkm2_ , 1);
1902 comm->unpack(buf, bsize, pos, &
Tkp1_ , 1);
1903 comm->unpack(buf, bsize, pos, &
h0_safety_ , 1);
1906 comm->unpack(buf, bsize, pos, &
h_max_inv_ , 1);
1909 comm->unpack(buf, bsize, pos, &
r_factor_ , 1);
1910 comm->unpack(buf, bsize, pos, &
r_safety_ , 1);
1911 comm->unpack(buf, bsize, pos, &
r_fudge_ , 1);
1912 comm->unpack(buf, bsize, pos, &
r_min_ , 1);
1913 comm->unpack(buf, bsize, pos, &
r_max_ , 1);
1915 comm->unpack(buf, bsize, pos, &
r_hincr_ , 1);
1918 for (
int i=0;i<6;++i)
1920 comm->unpack(buf, bsize, pos, &
alpha_[i], 1);
1921 comm->unpack(buf, bsize, pos, &
sigma_[i], 1);
1922 comm->unpack(buf, bsize, pos, &
gamma_[i], 1);
1923 comm->unpack(buf, bsize, pos, &
beta_[i], 1);
1924 comm->unpack(buf, bsize, pos, &
psi_[i], 1);
1929 comm->unpack(buf, bsize, pos, &
oldOrder_, 1);
1930 comm->unpack(buf, bsize, pos, &
maxOrder_, 1);
1931 comm->unpack(buf, bsize, pos, &
minOrder_, 1);
1932 comm->unpack(buf, bsize, pos, &
usedOrder_, 1);
1934 comm->unpack(buf, bsize, pos, &
nef_, 1);
1935 comm->unpack(buf, bsize, pos, &
nscsco_, 1);
1936 comm->unpack(buf, bsize, pos, &
newOrder_, 1);
1941 comm->unpack (buf, bsize, pos, &iP, 1);
1949 std::string str1(buf);
1950 int length = str1.size() - pos;
1951 std::string str2(str1,pos,length);
1953 std::istringstream ist( str2 );
1988 for (
int i=0;i<6;++i)
2019 Xyce::dout() <<
"TIA Restart Data RESTORE (DAE)! " <<
netlistFilename_ <<
"\n"
2020 << Xyce::section_divider << std::endl<<std::endl
2021 <<
"alphas_ = " <<
alphas_<<std::endl
2022 <<
"alpha0_ = " <<
alpha0_<<std::endl
2023 <<
"cj_ = " <<
cj_<<std::endl
2024 <<
"ck_ = " <<
ck_<<std::endl
2025 <<
"usedStep_ = " <<
usedStep_<<std::endl
2026 <<
"Ek_ = " <<
Ek_<<std::endl
2027 <<
"Ekm1_ = " <<
Ekm1_<<std::endl
2028 <<
"Ekm2_ = " <<
Ekm2_<<std::endl
2029 <<
"Ekp1_ = " <<
Ekp1_<<std::endl
2030 <<
"Est_ = " <<
Est_<<std::endl
2031 <<
"Tk_ = " <<
Tk_<<std::endl
2032 <<
"Tkm1_ = " <<
Tkm1_<<std::endl
2033 <<
"Tkm2_ = " <<
Tkm2_<<std::endl
2034 <<
"Tkp1_ = " <<
Tkp1_<<std::endl
2041 <<
"r_factor_ = " <<
r_factor_<<std::endl
2042 <<
"r_safety_ = " <<
r_safety_<<std::endl
2043 <<
"r_fudge_ = " <<
r_fudge_<<std::endl
2044 <<
"r_min_ = " <<
r_min_<<std::endl
2045 <<
"r_max_ = " <<
r_max_<<std::endl
2047 <<
"r_hincr_ = " <<
r_hincr_<<std::endl;
2049 for (
int i=0;i<6;++i)
2051 Xyce::dout() <<
" alpha_["<<i<<
"] = " <<
alpha_[i]<<std::endl
2052 <<
" sigma_["<<i<<
"] = " <<
sigma_[i]<<std::endl
2053 <<
" gamma_["<<i<<
"] = " <<
gamma_[i]<<std::endl
2054 <<
" beta_["<<i<<
"] = " <<
beta_[i]<<std::endl
2055 <<
" psi_["<<i<<
"] = " <<
psi_[i]<<std::endl;
2058 Xyce::dout() << Xyce::section_divider << std::endl << std::endl << std::endl;
2074 Parallel::Machine comm,
2076 bool breakpoints_enabled,
2077 double initial_time,
2078 bool min_time_steps_breakpoint_given,
2079 double min_time_steps_breakpoint)
2081 updateStopTime(comm, breakpoints_enabled, initial_time, min_time_steps_breakpoint_given, min_time_steps_breakpoint);
2114 Xyce::ios_flags_saver flagsave(os);
2117 <<
"Current,Next,Step: "
2118 << std::setw(DEBUG_TIME ? 14 : 16) << std::setprecision(Xyce::DEBUG_TIME ? 7 : 9)
2141 if (DEBUG_TIME && isActive(Diag::TIME_STEP))
2143 Xyce::dout() <<
"StepErrorControl::isPauseTime\n";
2144 Xyce::dout() <<
"currentPauseBP.value = " <<
currentPauseBP->value () << std::endl;
2145 Xyce::dout() <<
"final Time = " <<
finalTime << std::endl;
2146 Xyce::dout() <<
"current Time = " <<
currentTime << std::endl;
2163 os <<
"\n\n-----------------------------------------" << std::endl
2164 <<
"\tStepErrorControl:\n"
2168 <<
"\t\tlastTimeStep = " << sec.
lastTimeStep << std::endl
2169 <<
"\t\tminTimeStep = " << sec.
minTimeStep << std::endl
2170 <<
"\t\tmaxTimeStep = " << sec.
maxTimeStep << std::endl
2172 <<
"\t\tlastTime = " << sec.
lastTime << std::endl
2173 <<
"\t\tcurrentTime = " << sec.
currentTime << std::endl
2174 <<
"\t\tnextTime = " << sec.
nextTime << std::endl
2175 <<
"\t\tstopTime = " << sec.
stopTime << std::endl
2176 <<
"\t\tinitialTime = " << sec.
initialTime << std::endl
2177 <<
"\t\tfinalTime = " << sec.
finalTime << std::endl
2179 <<
"\t\tBreak Points:" << std::endl;
2184 os << Xyce::section_divider << std::endl
Loader::Loader & getLoader()
bool initializeBreakPoints(double start_time, double initial_time, double final_time)
BreakPointSet breakPoints_
virtual bool getInnerLoopErrorSums(std::vector< TimeIntg::TwoLevelError > &tleVec)
double restartTimeStepScale_
BreakPointSet::iterator currentPauseBP
int newtonConvergenceStatus
double initialTimeStep
User specified initial time step.
double newtonStepReduction_
bool dumpRestartData(char *buf, int bsize, int &pos, N_PDS_Comm *comm, bool pack)
std::vector< double > sigma_
Pure virtual class to augment a linear system.
int nIterations
Number of newton iterations.
void updateTwoLevelTimeInfo(Parallel::Machine comm, const TimeIntInfo &tiInfo, bool breakpoints_enabled, double initial_time, bool min_time_steps_breakpoint_given, double min_time_steps_breakpoint)
Util::BreakPointLess breakPointLess_
int errorAnalysisOption
Error analysis option.
double finalTime
End time for simulation.
bool updateMaxTimeStep(Parallel::Machine comm, const TIAParams &tia_params, double suggestedMaxTimeStep=0.0)
void updatePauseTime(Util::BreakPoint breakpoint, double initial_time)
double nextTimeStep
Step error control next time step.
bool resetAll(const TIAParams &tia_params)
bool setFromTIAParams(const TIAParams &tia_params)
double maxTimeStep
User specified maximum time step.
double minTimeStep
User specified minimum time step.
double lastAttemptedTimeStep
bool constantTimeStepFlag
Constant time step integration flag.
bool getBeginningIntegrationFlag() const
WorkingIntegrationMethod & wimPtr_
Analysis manager.
void setIntegrationMethod(int im)
std::vector< TwoLevelError > innerErrorInfoVec
double nextTime
Step error control next time.
std::set< Util::BreakPoint, Util::BreakPointLess > BreakPointSet
unsigned int breakPointRestartStep
void updateStopTime(Parallel::Machine comm, bool breakpoints_enabled, double initial_time, bool min_time_steps_breakpoint_given, double min_time_steps_breakpoint)
void setStepNumber(int step)
void setBeginningIntegrationFlag(bool bif)
double findNextStopTimeDeprecated(Parallel::Machine comm, bool breakpoints_enabled)
void setTimeStep(double newTimeStep)
double currentTimeStepRatio
bool restoreRestartData(char *buf, int bsize, int &pos, N_PDS_Comm *comm, bool pack, double &initial_time)
virtual double getMaxTimeStepSize()
StepErrorControl(const std::string &netlist_filename, Analysis::AnalysisManager &analysis_manager, WorkingIntegrationMethod &working_integration_method, const TIAParams &tia_params)
std::ostream & operator<<(std::ostream &os, const StepErrorControl &sec)
int getIntegrationMethod()
double restartTimeStepScale
Time step is scaled coming out of a breakpoint (StepErrorControl)
void setTranStepNumber(int step)
void setBreakPoint(const Util::BreakPoint &breakpoint, double initial_time)
void simulationPaused(double initial_time)
double minStepPrecisionFac_
Analysis::AnalysisManager & analysisManager_
void outputTimeInfo(std::ostream &os)
double pauseTime
Time step value at which to "pause" the simulation.
std::vector< double > beta_
int getStepNumber() const
AnalysisManager & analysisManager_
double initialOutputTime
Time at which output starts (StepErrorControl)
int numberSuccessiveFailures
bool pauseSetAtZero
Flag used to indicate that a pause was specifically set at time zero and thus should not be ignored...
double getEstOverTol() const
std::vector< double > psi_
double initialTime
Beginning time for the time integrator (StepErrorControl, integrators access from StepErrorControl) ...
double currentTimeStepSum
bool previousCallStepSuccessful
int getRestartDataSize(bool pack)
void printBreakPoints(std::ostream &os) const
void integrationStepReport(std::ostream &os, bool step_attempt_status, bool sAStatus, bool testedError, const TIAParams &tia_params)
bool updateBreakPoints(double initial_time)
TimeIntg::DataStore * getDataStore()
void evaluateStepError(const TIAParams &tia_params)
bool useDeviceTimeStepMaxFlag
True if devices impose a time step maximum.
const std::string netlistFilename_
Working integration method.
void terseIntegrationStepReport(std::ostream &os, bool step_attempt_status, bool sAStatus, bool testedError, const TIAParams &tia_params)
bool getBlockAnalysisFlag() const
Return true if primary analysis is HB or MPDE.
virtual ~StepErrorControl()
std::vector< double > alpha_
virtual bool getBreakPoints(std::vector< Util::BreakPoint > &breakPointTimes) const
std::vector< double > gamma_
double computeErrorEstimate() const
int currentOrder
Time integrator order.