38 #include <Xyce_config.h>
43 #include <N_ERH_Message.h>
57 : tiaParams(anaManagerPtr->tiaParams),
58 beginningIntegration(true),
62 totalNumberSuccessfulStepsTaken_(0),
63 totalNumberSuccessStepsThisParameter_(0),
64 totalNumberFailedStepsAttempted_(0),
65 totalNumberJacobiansEvaluated_(0),
66 totalNumberIterationMatrixFactorizations_(0),
67 totalNumberLinearSolves_(0),
68 totalNumberFailedLinearSolves_(0),
69 totalNumberLinearIters_(0),
70 totalNumberResidualEvaluations_(0),
71 totalNonlinearConvergenceFailures_(0),
72 totalLinearSolutionTime_(0.0),
73 totalResidualLoadTime_(0.0),
74 totalJacobianLoadTime_(0.0),
75 doubleDCOPFlag_(false),
79 commandLine_(anaManagerPtr->getCommandLine())
156 double pinterval = 1.0;
157 double pcount = 0.0, pstart, pstop, pstep;
162 for (
int iparam=0;iparam<(int)sweepParamVec.size();++iparam)
164 tmp =
loaderRCPtr_->getParamAndReduce(sweepParamVec[iparam].name);
168 #ifdef Xyce_DEBUG_ANALYSIS
171 Xyce::dout() << std::endl << std::endl
172 << Xyce::subsection_divider << std::endl
173 <<
"AnalysisManager::setupSweepLoop" << std::endl;
178 for (
int iparam=0;iparam<(int)sweepParamVec.size();++iparam)
180 #ifdef Xyce_DEBUG_ANALYSIS
183 Xyce::dout() <<
"name = " << sweepParamVec[iparam].name << std::endl;
187 sweepParamVec[iparam].interval =
static_cast<int> (pinterval);
192 if (sweepParamVec[iparam].type==
"LIN")
194 pstart = sweepParamVec[iparam].startVal;
195 pstop = sweepParamVec[iparam].stopVal;
196 pstep = sweepParamVec[iparam].stepVal;
209 pcount = floor(((pstop - pstart)/pstep));
215 if ( fabs(pstop-(pstart+(pcount+1.0)*pstep)) < 2.0*N_UTL_MachineDependentParams::MachinePrecision())
233 sweepParamVec[iparam].maxStep =
static_cast<int>(pcount);
234 #ifdef Xyce_DEBUG_ANALYSIS
237 Xyce::dout() <<
"pstart = " << pstart << std::endl;
238 Xyce::dout() <<
"pstop = " << pstop << std::endl;
239 Xyce::dout() <<
"pstep = " << pstep << std::endl;
240 Xyce::dout() <<
"pstop-pstart/pstep = " << ((pstop - pstart)/pstep) << std::endl;
241 Xyce::dout() <<
"floor ()= " << floor(((pstop - pstart)/pstep)+1.0) << std::endl;
242 Xyce::dout() <<
"pcount = " << pcount << std::endl;
243 Xyce::dout() <<
"maxStep = " << sweepParamVec[iparam].maxStep << std::endl;
247 else if(sweepParamVec[iparam].type==
"DEC")
249 double numSteps =
static_cast<double>(sweepParamVec[iparam].numSteps);
251 double stepMult = exp(log(10.0)/numSteps);
252 sweepParamVec[iparam].stepMult = stepMult;
254 pstart = sweepParamVec[iparam].startVal;
255 pstop = sweepParamVec[iparam].stopVal;
256 pcount = floor(fabs(log10(pstart) - log10(pstop)) * numSteps + 1);
257 sweepParamVec[iparam].maxStep =
static_cast<int>(pcount);
259 else if(sweepParamVec[iparam].type==
"OCT")
261 double numSteps =
static_cast<double>(sweepParamVec[iparam].numSteps);
263 double stepMult = exp(log(2.0)/numSteps);
270 sweepParamVec[iparam].stepMult = stepMult;
271 pstart = sweepParamVec[iparam].startVal;
272 pstop = sweepParamVec[iparam].stopVal;
273 pcount = floor(fabs(log(pstart) - log(pstop))/ln2 * numSteps + 1);
274 sweepParamVec[iparam].maxStep =
static_cast<int>(pcount);
276 else if(sweepParamVec[iparam].type==
"LIST")
278 pcount = sweepParamVec[iparam].valList.size();
279 sweepParamVec[iparam].maxStep = sweepParamVec[iparam].valList.size();
283 Report::UserError0() <<
" Unsupported STEP type";
287 #ifdef Xyce_DEBUG_ANALYSIS
290 Xyce::dout() <<
"parameter = " << sweepParamVec[iparam].name << std::endl;
291 Xyce::dout() <<
"pcount = " << pcount << std::endl;
292 Xyce::dout() <<
"pinterval = " << pinterval << std::endl;
299 return static_cast<int> (pinterval);
311 (
int loopIter, std::vector<SweepParam> & sweepParamVec)
313 std::vector<SweepParam>::iterator iterParam;
314 std::vector<SweepParam>::iterator firstParam = sweepParamVec.begin();
315 std::vector<SweepParam>::iterator lastParam = sweepParamVec.end ();
316 bool resetFlag=
false;
319 for (iterParam=firstParam; iterParam != lastParam;++iterParam)
321 iterParam->updateCurrentVal (loopIter);
322 resetFlag = resetFlag || iterParam->getSweepResetFlag();
323 loaderRCPtr_->setParam (iterParam->name, iterParam->currentVal);
328 anaManagerRCPtr_->setSweepSourceResetFlag(resetFlag);
398 for (i=0 ; i<j ; ++i)
405 for (i=0 ; i<j ; ++i)
426 bool bsuccess =
true;
427 int t1, t2, indI = 0, indD = 0;
428 if (start == 0 && finish == 0)
439 lout() <<
"\tNumber Successful Steps Taken:\t\t" <<
saveTimeI[t2][indI]-
saveTimeI[t1][indI] << std::endl;
442 lout() <<
"\tNumber Failed Steps Attempted:\t\t" <<
saveTimeI[t2][indI]-
saveTimeI[t1][indI] << std::endl;
445 lout() <<
"\tNumber Jacobians Evaluated:\t\t" <<
saveTimeI[t2][indI]-
saveTimeI[t1][indI] << std::endl;
448 lout() <<
"\tNumber Iteration Matrix Factorizations:\t" <<
saveTimeI[t2][indI]-
saveTimeI[t1][indI] << std::endl;
451 lout() <<
"\tNumber Linear Solves:\t\t\t" <<
saveTimeI[t2][indI]-
saveTimeI[t1][indI] << std::endl;
454 lout() <<
"\tNumber Failed Linear Solves:\t\t" <<
saveTimeI[t2][indI]-
saveTimeI[t1][indI] << std::endl;
459 lout() <<
"\tNumber Linear Solver Iterations:\t" <<
saveTimeI[t2][indI]-
saveTimeI[t1][indI] << std::endl;
463 lout() <<
"\tNumber Residual Evaluations:\t\t" <<
saveTimeI[t2][indI]-
saveTimeI[t1][indI] << std::endl;
466 lout() <<
"\tNumber Nonlinear Convergence Failures:\t" <<
saveTimeI[t2][indI]-
saveTimeI[t1][indI] << std::endl;
471 lout() <<
"\tTotal Residual Load Time:\t\t" <<
saveTimeD[t2][indD]-
saveTimeD[t1][indD] <<
" seconds" << std::endl;
474 lout() <<
"\tTotal Jacobian Load Time:\t\t" <<
saveTimeD[t2][indD]-
saveTimeD[t1][indD] <<
" seconds" << std::endl;
477 lout() <<
"\tTotal Linear Solution Time:\t\t" <<
saveTimeD[t2][indD]-
saveTimeD[t1][indD] <<
" seconds" << std::endl;
485 if (
secRCPtr_->newtonConvergenceStatus <= 0)