40 #include <Xyce_config.h>
44 #include <N_UTL_Misc.h>
63 #include <N_UTL_fwd.h>
87 #include <N_ERH_ErrorMgr.h>
89 #include <N_LAS_System.h>
90 #include <N_LAS_LAFactory.h>
91 #include <N_LAS_Vector.h>
92 #include <N_LAS_Matrix.h>
96 #include <N_LOA_Loader.h>
98 #include <N_PDS_Manager.h>
99 #include <N_PDS_Comm.h>
101 #include <N_UTL_OptionBlock.h>
102 #include <N_UTL_Timer.h>
103 #include <N_UTL_BreakPoint.h>
105 #include <N_IO_OutputMgr.h>
108 #include <N_IO_RestartMgr.h>
110 #include <N_IO_CmdParse.h>
112 #include <N_MPDE_Manager.h>
128 calledBeforeTwoLevelTran_(false),
129 breakPointRestartStep(0),
131 anaIntPtr(anaIntPtr_tmp,false),
133 analysisParamsRegistered(false),
136 oldPercentComplete(0.0),
138 switchIntegrator_(false),
139 initializeAllFlag_(false),
141 stepLoopFlag_(false),
142 stepLoopInitialized_(false),
143 dcLoopInitialized_(false),
145 daeStateDerivFlag_(true),
146 initializeSolvers_mixedSignal_(false),
148 sweepSourceResetFlag_(true),
150 solverStartTime_(0.0),
151 dakotaRunFlag_(false),
152 dakotaIterationNumber_(0),
154 saveTimeGiven_(false),
156 savedAlready_(false),
157 dcopRestartFlag_(false),
158 dotOpSpecified_(false),
159 initialOutputInterval_(0.0),
160 nextOutputTime_(0.0),
161 initialRestartInterval_(0.0),
162 nextRestartSaveTime_(0.0),
163 blockAnalysisFlag_(false),
175 atoi(
commandLine_.getArgumentValue(
"-maxord" ).c_str() );
355 Report::DevelFatal0().in(
"AnalysisManager::initializeAll")
356 <<
"Register LAS system first.";
363 #ifdef Xyce_DEBUG_ANALYSIS
366 Xyce::dout() <<
"AnalysisManager::initializeAll. " ;
471 Report::UserError0() <<
"No analysis statement in the netlist";
497 Report::DevelFatal0().in(
"AnalysisManager::run")
498 <<
"Call the initializeAll function first";
503 Report::UserError0() <<
"No analysis statement in the netlist";
510 std::vector<char> varTypes;
518 #ifdef Xyce_VERBOSE_TIME
522 #ifndef Xyce_NO_MASKED_WRMS_NORMS
555 Report::safeBarrier(
pdsMgrPtr->getPDSComm()->comm());
626 Report::UserError0() <<
"Unknown type of analysis";
638 Report::DevelFatal0().in(
"AnalysisManager::initializeAll")
639 <<
"Unable to allocate analysis type";
739 Xyce::dout() <<
"Calling SAVE outputs!" <<std::endl;
757 #ifdef Xyce_DEBUG_RESTART
758 Xyce::dout() <<
"TESTING FOR RESTART SAVE" << std::endl
759 << Xyce::subsection_divider << std::endl
760 <<
"secPtr_->currentTime: " <<
secPtr_->currentTime << std::endl
765 Xyce::dout() <<
"First restart interval: " <<
restartIntervals_[0].first << std::endl;
769 Xyce::dout() <<
"restartIntervals_ is empty" << std::endl;
783 while (nextRestartSaveTime_ <= secPtr_->currentTime)
791 while (nextRestartSaveTime_ <= secPtr_->currentTime)
803 std::pair<double, double> currInterval, nextInterval;
805 for (
int i = 0; i < size; ++i)
816 int step = static_cast <
int> ((
secPtr_->currentTime-currInterval.first) /
817 currInterval.second);
820 if (nextInterval.first && (nextInterval.first!=currInterval.first)
828 #ifdef Xyce_DEBUG_RESTART
830 <<
"restart flag: " << flag << std::endl
831 << Xyce::subsection_divider << std::endl;
849 double partDT =
wimPtr->partialTimeDeriv();
855 #ifdef Xyce_DEBUG_ANALYSIS
858 Xyce::dout() <<
"AnalysisManager::partialTimeDerivative.";
881 return N_UTL_BreakPoint::getBPTol();
894 N_UTL_BreakPoint::setBPTol(bptol);
908 std::vector< std::pair<double,double> > intPairs;
909 restartPtr->getRestartIntervals(initInt, intPairs);
927 std::vector< std::pair<double,double> > intPairs;
944 const N_UTL_OptionBlock & paramsBlock)
965 (
const N_UTL_OptionBlock & paramsBlock)
967 analysisParamsRegistered =
true;
974 bool foundMatch =
false;
975 std::vector<N_UTL_OptionBlock>::iterator paramsBlockVecItr = dcParamsBlockVec.begin();
976 std::vector<N_UTL_OptionBlock>::iterator paramsBlockVecEnd = dcParamsBlockVec.end();
977 while( paramsBlockVecItr != paramsBlockVecEnd )
979 if( paramsBlockVecItr->compareParamLists( paramsBlock ) )
991 *paramsBlockVecItr = paramsBlock;
996 dcParamsBlockVec.push_back (paramsBlock);
1010 const N_UTL_OptionBlock & paramsBlock)
1026 const N_UTL_OptionBlock & paramsBlock)
1033 bool foundMatch =
false;
1034 std::vector<N_UTL_OptionBlock>::iterator paramsBlockVecItr =
stepParamsBlockVec.begin();
1035 std::vector<N_UTL_OptionBlock>::iterator paramsBlockVecEnd =
stepParamsBlockVec.end();
1036 while( paramsBlockVecItr != paramsBlockVecEnd )
1038 if( paramsBlockVecItr->compareParamLists( paramsBlock ) )
1044 paramsBlockVecItr++;
1050 *paramsBlockVecItr = paramsBlock;
1071 const N_UTL_OptionBlock & OB)
1073 #ifdef Xyce_DEBUG_ANALYSIS
1076 Xyce::dout() <<
"In AnalysisManager::setSaveOptions" << std::endl;
1082 std::list<N_UTL_Param>::const_iterator iterPL = OB.getParams().begin();
1083 std::list<N_UTL_Param>::const_iterator iterPL_end = OB.getParams().end();
1085 while (iterPL != iterPL_end)
1087 #ifdef Xyce_DEBUG_IO
1088 Xyce::dout() <<
"iterPL->tag = " << iterPL->tag() << std::endl;
1090 if (iterPL->tag() ==
"TYPE")
1094 else if (iterPL->tag() ==
"FILE")
1098 else if (iterPL->tag() ==
"TIME")
1100 saveTime_ = iterPL->getImmutableValue<
double>();
1103 else if (iterPL->tag() ==
"LEVEL")
1130 (
const N_UTL_OptionBlock & paramsBlock)
1132 analysisParamsRegistered =
true;
1134 acParamsBlock = paramsBlock;
1148 (
const N_UTL_OptionBlock & paramsBlock)
1150 analysisParamsRegistered =
true;
1152 morParamsBlock = paramsBlock;
1166 std::list<N_UTL_Param>::const_iterator it_tpL;
1167 std::list<N_UTL_Param>::const_iterator first = OB.getParams().begin();
1168 std::list<N_UTL_Param>::const_iterator last = OB.getParams().end();
1170 for (it_tpL = first; it_tpL != last; ++it_tpL)
1172 if (it_tpL->uTag()==
"METHOD")
1174 ExtendedString stringVal ( it_tpL->stringValue() );
1175 stringVal.toUpper();
1178 else if (it_tpL->uTag()==
"SAVEREDSYS")
1182 else if (it_tpL->uTag()==
"COMPORIGTF")
1186 else if (it_tpL->uTag()==
"COMPREDTF")
1190 else if (it_tpL->uTag()==
"COMPTYPE")
1192 ExtendedString stringVal ( it_tpL->stringValue() );
1193 stringVal.toUpper();
1196 else if (it_tpL->uTag()==
"COMPNP")
1200 else if (it_tpL->uTag()==
"COMPFSTART")
1204 else if (it_tpL->uTag()==
"COMPFSTOP")
1208 else if (it_tpL->uTag()==
"EXPPOINT")
1212 else if (it_tpL->uTag()==
"SCALETYPE")
1216 else if (it_tpL->uTag()==
"SCALEFACTOR")
1220 else if (it_tpL->uTag()==
"SCALEFACTOR1")
1224 else if (it_tpL->uTag()==
"SPARSIFICATIONTYPE")
1230 Report::UserError0() << it_tpL->uTag() <<
" is not a recognized model-order reduction option.";
1260 std::list<N_UTL_Param>::const_iterator iterPL = OB.getParams().begin();
1261 std::list<N_UTL_Param>::const_iterator iterPL_end = OB.getParams().end();
1263 while (iterPL != iterPL_end)
1265 #ifdef Xyce_DEBUG_IO
1266 Xyce::dout() <<
"iterPL->tag = " << iterPL->tag() << std::endl;
1269 if (iterPL->tag() ==
"INPUT")
1273 else if (iterPL->tag() ==
"OUTPUT")
1277 else if (iterPL->tag() ==
"TIME")
1279 saveTime_ = iterPL->getImmutableValue<
double>();
1305 std::list<N_UTL_Param>::const_iterator it_tpL;
1306 std::list<N_UTL_Param>::const_iterator first = OB.getParams().begin();
1307 std::list<N_UTL_Param>::const_iterator last = OB.getParams().end();
1309 for (it_tpL = first; it_tpL != last; ++it_tpL)
1311 if (it_tpL->uTag()==
"METHOD")
1315 if (it_tpL->isInteger())
1320 ExtendedString stringVal ( it_tpL->stringValue() );
1321 stringVal.toUpper();
1323 if (stringVal ==
"TRAP" || stringVal ==
"TRAPEZOIDAL")
1325 else if (stringVal ==
"BDF")
1327 else if (stringVal ==
"GEAR")
1331 Report::UserError0() <<
"Unsupported transient method type";
1336 #ifdef Xyce_DEBUG_ANALYSIS
1337 else if (it_tpL->uTag()==
"CONSTSTEP")
1340 =
static_cast<bool> (it_tpL->getImmutableValue<
int>());
1343 else if (it_tpL->uTag()==
"USEDEVICEMAX")
1347 else if (it_tpL->uTag()==
"RELTOL")
1352 else if (it_tpL->uTag()==
"ABSTOL")
1356 else if (it_tpL->uTag()==
"DOUBLEDCOPSTEP")
1360 else if (it_tpL->uTag()==
"FIRSTDCOPSTEP")
1364 else if (it_tpL->uTag()==
"LASTDCOPSTEP")
1368 else if (it_tpL->uTag()==
"BPENABLE" )
1372 else if (it_tpL->uTag()==
"RESTARTSTEPSCALE" )
1376 else if (it_tpL->uTag()==
"EXITTIME" )
1380 else if (it_tpL->uTag()==
"EXITSTEP" )
1384 else if (it_tpL->uTag() ==
"MINTIMESTEPSBP")
1389 else if (it_tpL->uTag()==
"ERROPTION" )
1401 else if (it_tpL->uTag()==
"NLNEARCONV" )
1405 else if (it_tpL->uTag()==
"NLSMALLUPDATE" )
1409 else if (it_tpL->uTag()==
"JACLIMITFLAG" )
1413 else if (it_tpL->uTag()==
"JACLIMIT" )
1417 else if (it_tpL->uTag()==
"DAESTATEDERIV" )
1421 else if (it_tpL->uTag()==
"MAXORD" )
1425 else if (it_tpL->uTag()==
"MINORD" )
1429 else if (it_tpL->uTag()==
"TIMESTEPSREVERSAL" )
1433 else if (it_tpL->uTag()==
"TESTFIRSTSTEP" )
1437 else if (it_tpL->uTag()==
"DELMAX" )
1443 else if (it_tpL->uTag()==
"NLMIN" )
1447 else if (it_tpL->uTag()==
"NLMAX" )
1451 else if (it_tpL->uTag()==
"OUTPUTINTERPMPDE")
1455 else if (it_tpL->uTag()==
"NEWLTE")
1459 else if (it_tpL->uTag()==
"NEWBPSTEPPING")
1463 else if (it_tpL->uTag()==
"INTERPOUTPUT")
1467 else if (it_tpL->uTag()==
"CONDTEST")
1471 else if (it_tpL->uTag()==
"CONDTESTDEVICENAME")
1475 else if (it_tpL->uTag() ==
"DTMIN")
1480 else if (it_tpL->uTag() ==
"PASSNLSTALL")
1484 else if (it_tpL->uTag() ==
"FASTTESTS")
1488 else if (it_tpL->uTag() ==
"MINTIMESTEPRECOVERY")
1492 else if (it_tpL->uTag()==
"VOLTZEROTOL" )
1496 else if (it_tpL->uTag()==
"CURRZEROTOL" )
1500 else if (it_tpL->uTag()==
"DEBUGLEVEL" )
1502 #ifdef Xyce_DEBUG_TIME
1515 else if (it_tpL->uTag()==
"HISTORYTRACKINGDEPTH" )
1521 Report::UserError() << it_tpL->uTag() <<
" is not a recognized time integration option";
1540 atoi(
commandLine_.getArgumentValue(
"-maxord" ).c_str() );
1570 bool bsuccess =
mpdeMgrPtr_->setMPDEAnalysisParams(OB);
1605 std::list<N_UTL_Param>::const_iterator it_tpL;
1606 std::list<N_UTL_Param>::const_iterator first = OB.getParams().begin();
1607 std::list<N_UTL_Param>::const_iterator last = OB.getParams().end();
1609 for (it_tpL = first; it_tpL != last; ++it_tpL)
1611 if (it_tpL->uTag() ==
"FREQ")
1621 Report::UserError() <<
"Frequency of oscillation " <<
tiaParams.
freqs[0] <<
" is less than or equal to zero, invalid .HB specification";
1626 dout() << section_divider << std::endl
1627 <<
"HB transient simulation parameters"
1728 bool bsuccess =
true;
1747 (
const std::vector<std::string> & paramNames,
1748 const std::vector<double> & paramVals,
1749 N_LAS_Vector * solnVecPtr )
1751 bool bsuccess =
true;
1753 #ifdef Xyce_DEBUG_ANALYSIS
1754 std::string netListFile = commandLine_.getArgumentValue(
"netlist");
1755 Xyce::dout() <<
"\n " << netListFile;
1756 Xyce::dout() <<
" AnalysisManager::completeHomotopyStep " << std::endl;
1760 bool bs1 = tiaDataStore_->updateStateDataArrays (); bsuccess = bsuccess && bs1;
1761 tiaDataStore_->setConstantHistory();
1762 tiaDataStore_->equateTmpVectors();
1765 loaderPtr->homotopyStepSuccess (paramNames,paramVals);
1768 outputMgrAdapterRCPtr_->outputHomotopy( paramNames, paramVals, *solnVecPtr );
1784 bool bsuccess =
true;
1786 #ifdef Xyce_DEBUG_ANALYSIS
1787 std::string netListFile =
commandLine_.getArgumentValue(
"netlist");
1788 Xyce::dout() <<
"\n " << netListFile;
1789 Xyce::dout() <<
" AnalysisManager::failHomotopyStep " << std::endl;
1814 bool bsuccess =
true;
1816 bsuccess = bsuccess && bs1;
1834 Report::DevelFatal0().in(
"AnalysisManager::setupMPDEMgr_") <<
"Registration function failed";
1861 N_LAS_Vector * SolVectorPtr,
1862 N_LAS_Vector * CurrSolVectorPtr,
1863 N_LAS_Vector * LastSolVectorPtr,
1864 N_LAS_Vector * StaVectorPtr,
1865 N_LAS_Vector * CurrStaVectorPtr,
1866 N_LAS_Vector * LastStaVectorPtr,
1867 N_LAS_Vector * StaDerivVectorPtr,
1868 N_LAS_Vector * StoVectorPtr,
1869 N_LAS_Vector * CurrStoVectorPtr,
1870 N_LAS_Vector * LastStoVectorPtr,
1871 N_LAS_Vector * stoLeadCurrQCompVectorPtr,
1872 N_LAS_Vector * QVectorPtr,
1873 N_LAS_Vector * FVectorPtr,
1874 N_LAS_Vector * dFdxdVpVectorPtr,
1875 N_LAS_Vector * dQdxdVpVectorPtr,
1876 N_LAS_Matrix * dQdxMatrixPtr,
1877 N_LAS_Matrix * dFdxMatrixPtr
1881 bool bsuccess =
loaderPtr->loadDAEVectors(
1892 stoLeadCurrQCompVectorPtr,
1899 bsuccess = bsuccess &&
loaderPtr->loadDAEMatrices(
1919 N_LAS_Vector * SolVectorPtr,
1920 N_LAS_Vector * StaVectorPtr,
1921 N_LAS_Vector * StoVectorPtr
2068 Report::DevelFatal0().in(
"AnalysisManager::simulationComplete") <<
"Called for non-transient run, not currently valid";
2168 return (stepNum <= 0);
2233 return secPtr_->startingTimeStep;
2356 return secPtr_->currentTimeStep;
2383 wimPtr->obtainCorrectorDeriv();
2410 const std::list<index_pair> & solGIDList,
2411 const std::list<index_pair> & staGIDList)
2414 wimPtr->updateDerivsBlock (solGIDList, staGIDList);
2456 return secPtr_->restartDataSize( pack );
2468 (
char * buf,
int bsize,
int & pos, N_PDS_Comm * comm,
bool pack)
2470 return secPtr_->dumpRestartData(buf, bsize, pos, comm, pack);
2482 (
char * buf,
int bsize,
int & pos, N_PDS_Comm * comm,
bool pack)
2484 return secPtr_->restoreRestartData(buf, bsize, pos, comm, pack);
2496 std::vector<double> & varData )
2510 std::vector<double> & varData )
2524 std::vector<double> & varData )
2539 return wimPtr->getOrder();
2552 return wimPtr->getNumberOfSteps();
2565 return wimPtr->getUsedOrder();
2578 return wimPtr->getNscsco();
2590 const std::vector<double> & varData )
2604 const std::vector<double> & varData )
2618 const std::vector<double> & varData )
2635 if (!Teuchos::is_null(
secPtr_))
2730 N_IO_RestartMgr * restartPtr_tmp)
2838 secPtr_->setBreakPoint(N_UTL_BreakPoint(pauseTime, Util::PAUSE_BREAKPOINT));