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>
64 #include <N_UTL_BreakPoint.h>
65 #include <N_UTL_Diagnostic.h>
66 #include <N_UTL_FeatureTest.h>
67 #include <N_UTL_Functors.h>
68 #include <N_UTL_MachDepParams.h>
69 #include <N_UTL_SaveIOSState.h>
83 const std::string & netlist_filename,
88 wimPtr_(working_integration_method),
89 netlistFilename_(netlist_filename),
90 startingTimeStep(1.0e-10),
91 currentTimeStep(1.0e-10),
92 lastAttemptedTimeStep(1.0e-10),
93 lastTimeStep(1.0e-10),
96 maxTimeStepUser(1.0e+99),
98 savedTimeStep(1.0e-10),
105 currentTimeStepRatio(0.0),
106 currentTimeStepSum(0.0),
108 pauseSetAtZero(false),
109 lastTimeStepRatio(0.0),
110 lastTimeStepSum(0.0),
111 newtonConvergenceStatus(-1),
113 numberSuccessiveFailures(0),
114 stepAttemptStatus(true),
115 previousCallStepSuccessful(false),
117 TimeStepLimitedbyBP(false),
118 minStepPrecisionFac_(10.0),
119 newtonStepReduction_(0.25),
120 restartTimeStepScale_(0.005),
157 h0_max_factor_(0.005),
161 Tkm1_Tk_safety_(2.0),
162 Tkp1_Tk_safety_(0.5),
172 breakPointLess_(Util::BreakPoint::defaultTolerance_),
173 breakPoints_(breakPointLess_),
174 currentPauseBP(breakPoints_.end())
301 if (DEBUG_TIME && isActive(Diag::TIME_BREAKPOINTS))
303 Xyce::dout() <<
" after resetAll:" << std::endl;
305 Xyce::dout() <<
" currentPauseBP = " <<
currentPauseBP->value() << std::endl
306 << Xyce::section_divider << std::endl;
368 Parallel::Machine comm,
369 bool breakpoints_enabled,
371 bool min_time_steps_breakpoint_given,
372 double min_time_steps_breakpoint)
375 double diffStopTime = 0.0;
377 if (breakpoints_enabled)
388 if (itBP->bptype() == Xyce::Util::BreakPoint::PAUSE)
398 diffStopTime = fabs(stopTime-oldStopTime);
405 stopTime = itBP->value();
408 Parallel::AllReduce(comm, MPI_MIN, &stopTime, 1);
418 if (min_time_steps_breakpoint_given && (min_time_steps_breakpoint > 0) )
425 if (DEBUG_TIME && isActive(Diag::TIME_STEP))
427 Xyce::dout() << std::endl
428 <<
" stopTime = " <<
stopTime << std::endl
429 <<
" pauseTime = " <<
pauseTime << std::endl
431 <<
" oldStopTime = " << oldStopTime << std::endl
432 <<
" finalTime = " <<
finalTime << std::endl
435 << Xyce::section_divider << std::endl;
452 Parallel::Machine comm,
453 bool breakpoints_enabled)
457 if (breakpoints_enabled)
468 Parallel::AllReduce(comm, MPI_MIN, &nextTime, 1);
491 bool sAStatus(
false);
492 bool errorOptionStatus(
true);
493 bool testTimeIntegrationError(
false);
515 testTimeIntegrationError =
true;
519 if (!step_attempt_status)
521 testTimeIntegrationError =
false;
525 if (testTimeIntegrationError)
544 errorOptionStatus =
true;
546 errorOptionStatus =
false;
551 Xyce::dout() <<
"ERROROPTION=1: DOREJECTSTEP = ";
554 Xyce::dout() <<
"1" << std::endl;
558 Xyce::dout() <<
"0" << std::endl;
567 if (DEBUG_TIME && isActive(Diag::TIME_ERROR))
569 Xyce::dout() <<
"Trying to skip time integrator error checks: " <<
currentTimeStep
570 <<
" newton status " << step_attempt_status << std::endl;
580 step_attempt_status = step_attempt_status && errorOptionStatus;
582 step_attempt_status = step_attempt_status && sAStatus;
586 if (DEBUG_TIME && isActive(Diag::TIME_ERROR))
588 integrationStepReport(Xyce::dout(), step_attempt_status, sAStatus, testTimeIntegrationError, tia_params);
590 else if (VERBOSE_TIME)
611 bool step_attempt_status,
617 <<
" STEP STATUS: " << (step_attempt_status ?
" success" :
" fail")
632 if (isActive(Diag::TIME_PARAMETERS))
634 os <<
"\n estOverTol = " <<
estOverTol_ << std::endl
637 <<
"\nSTEP ATTEMPT STATUS:" << std::endl
638 <<
"NOTE:" << std::endl;
644 os <<
" We are running in variable stepsize mode " << std::endl
645 <<
" and we have NOT just passed a breakpoint. As such " << std::endl
646 <<
" for an integration step to succeed the " << std::endl
647 <<
" nonlinear solver must succeed AND the predictor" << std::endl
648 <<
" and corrector need to be close within a tolerance." << std::endl;
652 os <<
"ADDENDUM: This is with erroption=1 so predictor-corrector is ignored for step error control." << std::endl;
657 os <<
" We are either running constant stepsize " << std::endl
658 <<
" or we just passed a breakpoint. As such " << std::endl
659 <<
" the only criteria we use in accepting/rejecting" << std::endl
660 <<
" an integration step is the nonlinear solver" << std::endl
661 <<
" success/failure." << std::endl;
664 if (step_attempt_status)
666 os <<
"\n This has been a successful step:" << std::endl;
670 os <<
"\n This has NOT been a successful step:" << std::endl;
688 os <<
" - predictor vs. corrector analysis succeeded." << std::endl;
692 os <<
" - predictor vs. corrector analysis failed." << std::endl;
695 os <<
" (compare estOverTol with error tolerance above.)" << std::endl;
699 os <<
"If we had been using it << " << std::endl;
703 os <<
" - predictor vs. corrector analysis would have succeeded." << std::endl;
707 os <<
" - predictor vs. corrector analysis would have failed." << std::endl;
710 os <<
" (compare estOverTol with error tolerance above.)" << std::endl;
715 os <<
" predictor vs. corrector was not tested" << std::endl;
718 os << Xyce::section_divider << std::endl;
732 double initial_output_time,
736 bool bsuccess =
true;
751 setBreakPoint(Util::BreakPoint(final_time, Xyce::Util::BreakPoint::PAUSE), initial_time);
777 bool bsuccess =
true;
779 if (DEBUG_TIME && isActive(Diag::TIME_BREAKPOINTS))
781 Xyce::dout() << std::endl
782 << Xyce::section_divider << std::endl
783 <<
" StepErrorControl::updateBreakPoints. time = " <<
currentTime << std::endl
787 std::vector<Util::BreakPoint> tmpBP;
793 std::vector<Util::BreakPoint>::iterator iter;
794 std::vector<Util::BreakPoint>::iterator first = tmpBP.begin();
795 std::vector<Util::BreakPoint>::iterator last = tmpBP.end();
798 BreakPointSet::iterator itBP;
799 BreakPointSet::iterator itBP_2;
804 for (iter=first; iter!=last; ++iter)
812 if (DEBUG_TIME &&isActive(Diag::TIME_BREAKPOINTS))
816 Xyce::dout() <<
netlistFilename_ <<
" breakPoints_ vector container, before any removals:" << std::endl;
819 for (itBP = firstBP; itBP != lastBP; ++i, ++itBP)
823 Xyce::dout() << i <<
" " << itBP->value() << std::endl;
827 Xyce::dout() << i <<
" " << itBP->value() <<
" diff=" << (itBP->value()-itBP_2->value()) << std::endl;
832 Xyce::dout() <<
"" << std::endl;
860 if (DEBUG_TIME && isActive(Diag::TIME_BREAKPOINTS))
862 Xyce::dout() <<
" bpTol = " << bpTol << std::endl;
863 Xyce::dout() <<
" Must now eliminate new duplicates " << std::endl;
866 bool doneRemove =
false;
873 for (icount = 0, itBP=firstBP, itBP_2=firstBP;
877 double diff = (itBP->value() - itBP_2->value());
881 if (fabs(diff) < bpTol)
884 if (itBP->bptype() == Xyce::Util::BreakPoint::SIMPLE &&
885 itBP_2->bptype() == Xyce::Util::BreakPoint::SIMPLE)
897 Xyce::Util::BreakPoint::Type overridingType = itBP->bptype();
898 double minTime=std::min(itBP->value(),itBP_2->value());
903 if (itBP_2->bptype() != Xyce::Util::BreakPoint::SIMPLE)
905 overridingType = itBP_2->bptype();
909 Util::BreakPoint tmpBP(minTime, overridingType);
914 if (DEBUG_TIME && isActive(Diag::TIME_BREAKPOINTS))
915 Xyce::dout() <<
" Purging breakpoints, overriding with breakpoint of type " << tmpBP.bptype();
929 if (DEBUG_TIME && isActive(Diag::TIME_BREAKPOINTS))
933 Xyce::dout() <<
" breakPoints_ vector container after:" << std::endl;
936 for (itBP=firstBP;itBP!=lastBP;++i,++itBP)
940 Xyce::dout() << i <<
" " << itBP->value() <<
" type=" << itBP->bptype() << std::endl;
944 Xyce::dout() << i <<
" " << itBP->value() <<
" type=" << itBP->bptype() <<
" diff=" << (itBP->value()-itBP_2->value()) << std::endl;
950 Xyce::dout() << std::endl
951 << Xyce::section_divider << std::endl;
968 Parallel::Machine comm,
971 double suggestedMaxTimeStep)
973 bool bsuccess =
true;
975 if (DEBUG_TIME && isActive(Diag::TIME_STEP))
977 Xyce::dout() << Xyce::section_divider << std::endl
978 <<
" StepErrorControl::updateMaxTimeStep" << std::endl;
981 double maxDevStep = 1.0e+99;
998 if( suggestedMaxTimeStep > 0.0 )
1008 if (maxDevStep > 0.0)
1018 Parallel::AllReduce(comm, MPI_MIN, &
maxTimeStep, 1);
1020 if (DEBUG_TIME && isActive(Diag::TIME_STEP))
1024 Xyce::dout() <<
" User did not specify a maximum time step." << std::endl;
1028 Xyce::dout() <<
" User specified a maximum time step. = " <<
maxTimeStepUser << std::endl;
1031 Xyce::dout() <<
" maxDevStep = " << maxDevStep << std::endl
1033 << Xyce::section_divider << std::endl;
1038 const std::string msg =
"Maximum Time step is invalid!\n";
1039 N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::DEV_FATAL_0, msg);
1055 bool bsuccess =
true;
1071 const Util::BreakPoint & breakpoint,
1072 double initial_time)
1074 if (breakpoint.bptype() == Xyce::Util::BreakPoint::SIMPLE)
1080 if (DEBUG_TIME && isActive(Diag::TIME_BREAKPOINTS))
1082 Xyce::dout() <<
"In setBreakPoint, got non-simple breakpoint of type "
1083 << breakpoint.bptype() <<
" at time " << breakpoint.value() << std::endl;
1121 Util::BreakPoint breakpoint,
1122 double initial_time)
1134 if ((breakpoint.bptype() > 0) && (breakpoint.value() == 0.0))
1153 if (DEBUG_TIME && isActive(Diag::TIME_BREAKPOINTS))
1157 <<
" encountered breakpoint " << breakpoint.value() <<
" current time is "
1176 double initial_time)
1193 BreakPointSet::const_iterator itBP;
1194 BreakPointSet::const_iterator itBP2;
1195 BreakPointSet::const_iterator firstBP =
breakPoints_.begin();
1196 BreakPointSet::const_iterator lastBP =
breakPoints_.end();
1201 for (i=0, itBP=firstBP;itBP!=lastBP;++i,++itBP)
1204 sprintf(tmp,
"%4d %16.8e type=%d",i,itBP->value(),itBP->bptype());
1206 sprintf(tmp,
"%4d %16.8e type=%d diff=%16.8e", i, itBP->value(),
1207 itBP->bptype(),(itBP->value()-itBP2->value()));
1209 os << std::string(tmp);
1238 int numdoubles = 21;
1240 int count =
sizeof(double)*numdoubles;
1241 count +=
sizeof(int)*numints;
1254 int baseClassSize = count;
1260 totalSize = baseClassSize;
1261 totalSize +=
sizeof(double) * numdoubles;
1262 totalSize +=
sizeof(int) * numints;
1267 totalSize = baseClassSize + 24*(numdoubles+numints);
1304 for(
int i = pos; i < (newPos); ++i) buf[i] =
' ';
1310 << Xyce::section_divider << std::endl
1318 <<
"lastTime: " <<
lastTime << std::endl
1320 <<
"nextTime: " <<
nextTime << std::endl
1326 Xyce::dout() << iterSD->value() <<
" ";
1328 Xyce::dout() << std::endl
1333 << Xyce::section_divider << std::endl << std::endl;
1345 comm->pack( &
lastTime, 1, buf, bsize, pos );
1347 comm->pack( &
nextTime, 1, buf, bsize, pos );
1356 comm->pack( &flag, 1, buf, bsize, pos );
1359 comm->pack( &
tolAimFac_, 1, buf, bsize, pos );
1364 BreakPointSet::iterator bpStart =
breakPoints_.begin();
1366 comm->pack( &size, 1, buf, bsize, pos );
1370 for( BreakPointSet::iterator iterSD = bpStart;
1371 iterSD != bpEnd; ++iterSD)
1373 val=iterSD->value();
1374 bptype=iterSD->bptype();
1375 if (!(bptype == Xyce::Util::BreakPoint::PAUSE && val ==
finalTime))
1377 comm->pack( &(val), 1, buf, bsize, pos );
1378 comm->pack( &(bptype), 1, buf, bsize, pos );
1382 comm->pack( &im, 1, buf, bsize, pos );
1384 comm->pack( &sN, 1, buf, bsize, pos );
1386 comm->pack( &tSN, 1, buf, bsize, pos );
1388 comm->pack( &bPRS, 1, buf, bsize, pos );
1390 comm->pack( &beginFlag, 1, buf, bsize, pos );
1397 int startIndex = pos;
1400 for(
int i = startIndex; i < (startIndex+count); ++i) buf[i] =
' ';
1402 std::ostringstream ost;
1403 ost.width(24);ost.precision(16);ost.setf(std::ios::scientific);
1432 BreakPointSet::iterator bpStart =
breakPoints_.begin();
1434 for( BreakPointSet::iterator iterSD = bpStart;
1435 iterSD != bpEnd; ++iterSD )
1437 if (!(iterSD->bptype() == Xyce::Util::BreakPoint::PAUSE && iterSD->value() ==
finalTime))
1439 ost << iterSD->value() <<
" ";
1440 ost << iterSD->bptype() <<
" ";
1452 ost << beginFlag <<
" ";
1454 std::string data( ost.str() );
1455 for(
unsigned int i = 0; i < data.length(); ++i ) buf[startIndex+i] = data[i];
1460 buf[startIndex+data.length()] =
'\0';
1461 pos += data.length();
1465 std::string outputString(buf);
1467 Xyce::dout() <<
"StepErrorControl UNPACKED output buffer:" << std::endl
1468 << outputString << std::endl;
1474 Xyce::dout() <<
"TIA Restart Data DUMP (DAE)! " <<
netlistFilename_ <<
"\n"
1475 << Xyce::section_divider << std::endl<<std::endl
1476 <<
"alphas_ = " <<
alphas_<<std::endl
1477 <<
"alpha0_ = " <<
alpha0_<<std::endl
1478 <<
"cj_ = " <<
cj_<<std::endl
1479 <<
"ck_ = " <<
ck_<<std::endl
1480 <<
"usedStep_ = " <<
usedStep_<<std::endl
1481 <<
"Ek_ = " <<
Ek_<<std::endl
1482 <<
"Ekm1_ = " <<
Ekm1_<<std::endl
1483 <<
"Ekm2_ = " <<
Ekm2_<<std::endl
1484 <<
"Ekp1_ = " <<
Ekp1_<<std::endl
1485 <<
"Est_ = " <<
Est_<<std::endl
1486 <<
"Tk_ = " <<
Tk_<<std::endl
1487 <<
"Tkm1_ = " <<
Tkm1_<<std::endl
1488 <<
"Tkm2_ = " <<
Tkm2_<<std::endl
1489 <<
"Tkp1_ = " <<
Tkp1_<<std::endl
1496 <<
"r_factor_ = " <<
r_factor_<<std::endl
1497 <<
"r_safety_ = " <<
r_safety_<<std::endl
1498 <<
"r_fudge_ = " <<
r_fudge_<<std::endl
1499 <<
"r_min_ = " <<
r_min_<<std::endl
1500 <<
"r_max_ = " <<
r_max_<<std::endl
1502 <<
"r_hincr_ = " <<
r_hincr_<<std::endl;
1504 for (
int i=0;i<6;++i)
1506 Xyce::dout() <<
" alpha_["<<i<<
"] = " <<
alpha_[i]<<std::endl
1507 <<
" sigma_["<<i<<
"] = " <<
sigma_[i]<<std::endl
1508 <<
" gamma_["<<i<<
"] = " <<
gamma_[i]<<std::endl
1509 <<
" beta_["<<i<<
"] = " <<
beta_[i]<<std::endl
1510 <<
" psi_["<<i<<
"] = " <<
psi_[i]<<std::endl;
1513 Xyce::dout() << Xyce::section_divider << std::endl << std::endl << std::endl;
1519 comm->pack( &
alphas_ , 1, buf, bsize, pos );
1520 comm->pack( &
alpha0_ , 1, buf, bsize, pos );
1521 comm->pack( &
cj_ , 1, buf, bsize, pos );
1522 comm->pack( &
ck_ , 1, buf, bsize, pos );
1523 comm->pack( &
usedStep_ , 1, buf, bsize, pos );
1524 comm->pack( &
Ek_ , 1, buf, bsize, pos );
1525 comm->pack( &
Ekm1_ , 1, buf, bsize, pos );
1526 comm->pack( &
Ekm2_ , 1, buf, bsize, pos );
1527 comm->pack( &
Ekp1_ , 1, buf, bsize, pos );
1528 comm->pack( &
Est_ , 1, buf, bsize, pos );
1529 comm->pack( &
Tk_ , 1, buf, bsize, pos );
1530 comm->pack( &
Tkm1_ , 1, buf, bsize, pos );
1531 comm->pack( &
Tkm2_ , 1, buf, bsize, pos );
1532 comm->pack( &
Tkp1_ , 1, buf, bsize, pos );
1533 comm->pack( &
h0_safety_ , 1, buf, bsize, pos );
1536 comm->pack( &
h_max_inv_ , 1, buf, bsize, pos );
1539 comm->pack( &
r_factor_ , 1, buf, bsize, pos );
1540 comm->pack( &
r_safety_ , 1, buf, bsize, pos );
1541 comm->pack( &
r_fudge_ , 1, buf, bsize, pos );
1542 comm->pack( &
r_min_ , 1, buf, bsize, pos );
1543 comm->pack( &
r_max_ , 1, buf, bsize, pos );
1545 comm->pack( &
r_hincr_ , 1, buf, bsize, pos );
1548 for (
int i=0;i<6;++i)
1550 comm->pack( &
alpha_[i], 1, buf, bsize, pos );
1551 comm->pack( &
sigma_[i], 1, buf, bsize, pos );
1552 comm->pack( &
gamma_[i], 1, buf, bsize, pos );
1553 comm->pack( &
beta_[i], 1, buf, bsize, pos );
1554 comm->pack( &
psi_[i], 1, buf, bsize, pos );
1559 comm->pack ( &
oldOrder_, 1, buf, bsize, pos);
1560 comm->pack ( &
maxOrder_, 1, buf, bsize, pos);
1561 comm->pack ( &
minOrder_, 1, buf, bsize, pos);
1562 comm->pack ( &
usedOrder_, 1, buf, bsize, pos);
1564 comm->pack ( &
nef_, 1, buf, bsize, pos);
1565 comm->pack ( &
nscsco_, 1, buf, bsize, pos);
1566 comm->pack ( &
newOrder_, 1, buf, bsize, pos);
1571 comm->pack ( &iP, 1, buf, bsize, pos);
1575 std::ostringstream ost;
1576 ost.width(24);ost.precision(16);ost.setf(std::ios::scientific);
1585 ost <<
Ekm1_ <<
" ";
1586 ost <<
Ekm2_ <<
" ";
1587 ost <<
Ekp1_ <<
" ";
1590 ost <<
Tkm1_ <<
" ";
1591 ost <<
Tkm2_ <<
" ";
1592 ost <<
Tkp1_ <<
" ";
1608 for (
int i=0;i<6;++i)
1613 ost <<
beta_[i]<<
" " ;
1614 ost <<
psi_[i]<<
" " ;
1633 std::string data( ost.str() );
1634 for(
unsigned int i = 0; i < data.length(); ++i ) buf[pos+i] = data[i];
1637 buf[pos+data.length()] =
'\0';
1639 if (DEBUG_RESTART) {
1640 std::string outputString(buf);
1642 Xyce::dout() <<
"StepErrorControlDAE UNPACKED output buffer:" << std::endl
1643 << outputString << std::endl;
1671 double & initial_time)
1683 comm->unpack(buf, bsize, pos, &
lastTime, 1);
1685 comm->unpack(buf, bsize, pos, &
nextTime, 1);
1694 comm->unpack(buf, bsize, pos, &flag, 1);
1698 comm->unpack(buf, bsize, pos, &
tolAimFac_, 1);
1707 BreakPointSet::iterator iterSD;
1708 BreakPointSet::iterator firstSD = tmpSet.begin();
1709 BreakPointSet::iterator lastSD = tmpSet.end();
1710 for (iterSD = firstSD; iterSD != lastSD; ++iterSD)
1715 if (iterSD->bptype() == Xyce::Util::BreakPoint::PAUSE)
1723 comm->unpack(buf, bsize, pos, &size, 1);
1725 for (
int i = 0; i < size; ++i)
1727 comm->unpack(buf, bsize, pos, &val, 1);
1728 comm->unpack(buf, bsize, pos, &bptype, 1);
1731 Util::BreakPoint TmpBP(val, bptype);
1733 if (TmpBP.bptype() == Xyce::Util::BreakPoint::PAUSE)
1741 comm->unpack(buf, bsize, pos, &im, 1);
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);
1754 std::string str1(buf);
1755 int length = str1.size() - pos;
1756 std::string str2(str1,pos,length);
1758 std::istringstream ist( str2 );
1805 BreakPointSet::iterator iterSD;
1806 BreakPointSet::iterator firstSD = tmpSet.begin();
1807 BreakPointSet::iterator lastSD = tmpSet.end();
1808 for (iterSD = firstSD; iterSD != lastSD; ++iterSD)
1813 if (iterSD->bptype() == Xyce::Util::BreakPoint::PAUSE)
1823 for(
int i = 0; i < size; ++i )
1827 if (val > currentTime)
1829 Util::BreakPoint TmpBP(val, bptype);
1831 if (TmpBP.bptype() == Xyce::Util::BreakPoint::PAUSE)
1856 << Xyce::section_divider << std::endl
1864 <<
"lastTime: " <<
lastTime << std::endl
1866 <<
"nextTime: " <<
nextTime << std::endl
1870 for (BreakPointSet::iterator iterSD =
breakPoints_.begin();
1873 Xyce::dout() << iterSD->value() <<
" " << iterSD->bptype() << std::endl;
1875 Xyce::dout() << std::endl
1880 << Xyce::section_divider << std::endl << std::endl;
1887 comm->unpack(buf, bsize, pos, &
alphas_ , 1);
1888 comm->unpack(buf, bsize, pos, &
alpha0_ , 1);
1889 comm->unpack(buf, bsize, pos, &
cj_ , 1);
1890 comm->unpack(buf, bsize, pos, &
ck_ , 1);
1891 comm->unpack(buf, bsize, pos, &
usedStep_ , 1);
1892 comm->unpack(buf, bsize, pos, &
Ek_ , 1);
1893 comm->unpack(buf, bsize, pos, &
Ekm1_ , 1);
1894 comm->unpack(buf, bsize, pos, &
Ekm2_ , 1);
1895 comm->unpack(buf, bsize, pos, &
Ekp1_ , 1);
1896 comm->unpack(buf, bsize, pos, &
Est_ , 1);
1897 comm->unpack(buf, bsize, pos, &
Tk_ , 1);
1898 comm->unpack(buf, bsize, pos, &
Tkm1_ , 1);
1899 comm->unpack(buf, bsize, pos, &
Tkm2_ , 1);
1900 comm->unpack(buf, bsize, pos, &
Tkp1_ , 1);
1901 comm->unpack(buf, bsize, pos, &
h0_safety_ , 1);
1904 comm->unpack(buf, bsize, pos, &
h_max_inv_ , 1);
1907 comm->unpack(buf, bsize, pos, &
r_factor_ , 1);
1908 comm->unpack(buf, bsize, pos, &
r_safety_ , 1);
1909 comm->unpack(buf, bsize, pos, &
r_fudge_ , 1);
1910 comm->unpack(buf, bsize, pos, &
r_min_ , 1);
1911 comm->unpack(buf, bsize, pos, &
r_max_ , 1);
1913 comm->unpack(buf, bsize, pos, &
r_hincr_ , 1);
1916 for (
int i=0;i<6;++i)
1918 comm->unpack(buf, bsize, pos, &
alpha_[i], 1);
1919 comm->unpack(buf, bsize, pos, &
sigma_[i], 1);
1920 comm->unpack(buf, bsize, pos, &
gamma_[i], 1);
1921 comm->unpack(buf, bsize, pos, &
beta_[i], 1);
1922 comm->unpack(buf, bsize, pos, &
psi_[i], 1);
1927 comm->unpack(buf, bsize, pos, &
oldOrder_, 1);
1928 comm->unpack(buf, bsize, pos, &
maxOrder_, 1);
1929 comm->unpack(buf, bsize, pos, &
minOrder_, 1);
1930 comm->unpack(buf, bsize, pos, &
usedOrder_, 1);
1932 comm->unpack(buf, bsize, pos, &
nef_, 1);
1933 comm->unpack(buf, bsize, pos, &
nscsco_, 1);
1934 comm->unpack(buf, bsize, pos, &
newOrder_, 1);
1939 comm->unpack (buf, bsize, pos, &iP, 1);
1947 std::string str1(buf);
1948 int length = str1.size() - pos;
1949 std::string str2(str1,pos,length);
1951 std::istringstream ist( str2 );
1986 for (
int i=0;i<6;++i)
2017 Xyce::dout() <<
"TIA Restart Data RESTORE (DAE)! " <<
netlistFilename_ <<
"\n"
2018 << Xyce::section_divider << std::endl<<std::endl
2019 <<
"alphas_ = " <<
alphas_<<std::endl
2020 <<
"alpha0_ = " <<
alpha0_<<std::endl
2021 <<
"cj_ = " <<
cj_<<std::endl
2022 <<
"ck_ = " <<
ck_<<std::endl
2023 <<
"usedStep_ = " <<
usedStep_<<std::endl
2024 <<
"Ek_ = " <<
Ek_<<std::endl
2025 <<
"Ekm1_ = " <<
Ekm1_<<std::endl
2026 <<
"Ekm2_ = " <<
Ekm2_<<std::endl
2027 <<
"Ekp1_ = " <<
Ekp1_<<std::endl
2028 <<
"Est_ = " <<
Est_<<std::endl
2029 <<
"Tk_ = " <<
Tk_<<std::endl
2030 <<
"Tkm1_ = " <<
Tkm1_<<std::endl
2031 <<
"Tkm2_ = " <<
Tkm2_<<std::endl
2032 <<
"Tkp1_ = " <<
Tkp1_<<std::endl
2039 <<
"r_factor_ = " <<
r_factor_<<std::endl
2040 <<
"r_safety_ = " <<
r_safety_<<std::endl
2041 <<
"r_fudge_ = " <<
r_fudge_<<std::endl
2042 <<
"r_min_ = " <<
r_min_<<std::endl
2043 <<
"r_max_ = " <<
r_max_<<std::endl
2045 <<
"r_hincr_ = " <<
r_hincr_<<std::endl;
2047 for (
int i=0;i<6;++i)
2049 Xyce::dout() <<
" alpha_["<<i<<
"] = " <<
alpha_[i]<<std::endl
2050 <<
" sigma_["<<i<<
"] = " <<
sigma_[i]<<std::endl
2051 <<
" gamma_["<<i<<
"] = " <<
gamma_[i]<<std::endl
2052 <<
" beta_["<<i<<
"] = " <<
beta_[i]<<std::endl
2053 <<
" psi_["<<i<<
"] = " <<
psi_[i]<<std::endl;
2056 Xyce::dout() << Xyce::section_divider << std::endl << std::endl << std::endl;
2072 Parallel::Machine comm,
2073 double tiInfonextTimeStep,
2074 double tiInfonextTime,
2075 int tiInfocurrentOrder,
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);
2094 double newTimeStep = tiInfonextTimeStep;
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
bool initializeBreakPoints(double start_time, double initial_time, double final_time)
BreakPointSet breakPoints_
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_
void evaluateStepError(const Loader::Loader &loader, const TIAParams &tia_params)
Pure virtual class to augment a linear system.
int nIterations
Number of newton iterations.
Util::BreakPointLess breakPointLess_
int errorAnalysisOption
Error analysis option.
double finalTime
End time for simulation.
void updatePauseTime(Util::BreakPoint breakpoint, double initial_time)
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
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)
void updateTwoLevelTimeInfo(Parallel::Machine comm, double nextTimeStep, double nextTime, int currentOrder, bool breakpoints_enabled, double initial_time, bool min_time_steps_breakpoint_given, double min_time_steps_breakpoint)
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)
TimeIntg::DataStore * getDataStore()
bool useDeviceTimeStepMaxFlag
True if devices impose a time step maximum.
const std::string netlistFilename_
Working integration method.
bool updateMaxTimeStep(Parallel::Machine comm, Loader::Loader &loader, const TIAParams &tia_params, double suggestedMaxTimeStep=0.0)
void terseIntegrationStepReport(std::ostream &os, bool step_attempt_status, bool sAStatus, bool testedError, const TIAParams &tia_params)
virtual bool getInnerLoopErrorSums(std::vector< TimeIntg::TwoLevelError > &tleVec) const
bool getBlockAnalysisFlag() const
Return true if primary analysis is HB or MPDE.
virtual ~StepErrorControl()
bool updateBreakPoints(const Loader::Loader &loader, double initial_time)
std::vector< double > alpha_
virtual bool getBreakPoints(std::vector< Util::BreakPoint > &breakPointTimes) const
std::vector< double > gamma_
double computeErrorEstimate() const