38 #include <Xyce_config.h>
44 #include <N_ERH_Message.h>
47 #include <N_UTL_OptionBlock.h>
48 #include <N_LOA_NonlinearEquationLoader.h>
54 : successfulStepsTaken_(0),
55 successStepsThisParameter_(0),
56 failedStepsAttempted_(0),
57 jacobiansEvaluated_(0),
58 iterationMatrixFactorizations_(0),
60 failedLinearSolves_(0),
62 residualEvaluations_(0),
63 nonlinearConvergenceFailures_(0),
64 linearSolutionTime_(0.0),
65 residualLoadTime_(0.0),
66 jacobianLoadTime_(0.0)
93 json << Util::JSON::open
98 << Util::nameValuePair(
"linearSolves", s.
linearSolves_) << Util::JSON::sep
100 << Util::nameValuePair(
"linearIters", s.
linearIters_) << Util::JSON::sep
103 << Util::nameValuePair(
"residualLoadTime", s.
residualLoadTime_) << Util::JSON::sep
104 << Util::nameValuePair(
"jacobianLoadTime", s.
jacobianLoadTime_) << Util::JSON::sep
106 << Util::JSON::close;
121 linearSystem_(*analysis_manager.getLinearSystem()),
122 loader_(analysis_manager.getLoader()),
123 nonlinearEquationLoader_(*analysis_manager.getNonlinearEquationLoader()),
124 nonlinearSolverManager_(*analysis_manager.getNonlinearSolverManager()),
125 outputManagerAdapter_(analysis_manager.getOutputManagerAdapter()),
126 stepErrorControl_(analysis_manager.getStepErrorControl()),
127 workingIntgMethod_(analysis_manager.getWorkingIntgMethod()),
128 tiaParams_(analysis_manager.getTIAParams()),
129 beginningIntegration(true),
133 doubleDCOPFlag_(false),
137 saveStatCountsVector_(),
243 bool bsuccess =
true;
245 if (t1 == 0 && t2 == 0)
322 int setupSweepLoop(N_LOA_Loader &loader,
int debug_level, std::vector<SweepParam>::iterator begin, std::vector<SweepParam>::iterator end)
326 for (std::vector<SweepParam>::iterator it = begin; it != end; ++it)
330 loader.getParamAndReduce(sweep_param.
name);
333 #ifdef Xyce_DEBUG_ANALYSIS
336 Xyce::dout() << std::endl << std::endl
337 << Xyce::subsection_divider << std::endl
338 <<
"AnalysisManager::setupSweepLoop" << std::endl;
342 double pinterval = 1.0;
343 double pcount = 0.0, pstart, pstop, pstep;
346 for (std::vector<SweepParam>::iterator it = begin; it != end; ++it)
350 #ifdef Xyce_DEBUG_ANALYSIS
353 Xyce::dout() <<
"name = " << sweep_param.
name << std::endl;
357 sweep_param.
interval =
static_cast<int> (pinterval);
362 if (sweep_param.
type==
"LIN")
379 pcount = floor(((pstop - pstart)/pstep));
385 if ( fabs(pstop-(pstart+(pcount+1.0)*pstep)) < 2.0*Util::MachineDependentParams::MachinePrecision())
403 sweep_param.
maxStep =
static_cast<int>(pcount);
404 #ifdef Xyce_DEBUG_ANALYSIS
407 Xyce::dout() <<
"pstart = " << pstart << std::endl;
408 Xyce::dout() <<
"pstop = " << pstop << std::endl;
409 Xyce::dout() <<
"pstep = " << pstep << std::endl;
410 Xyce::dout() <<
"pstop-pstart/pstep = " << ((pstop - pstart)/pstep) << std::endl;
411 Xyce::dout() <<
"floor ()= " << floor(((pstop - pstart)/pstep)+1.0) << std::endl;
412 Xyce::dout() <<
"pcount = " << pcount << std::endl;
413 Xyce::dout() <<
"maxStep = " << sweep_param.
maxStep << std::endl;
417 else if(sweep_param.
type==
"DEC")
419 double numSteps =
static_cast<double>(sweep_param.
numSteps);
421 double stepMult = exp(log(10.0)/numSteps);
426 pcount = floor(fabs(log10(pstart) - log10(pstop)) * numSteps + 1);
427 sweep_param.
maxStep =
static_cast<int>(pcount);
429 else if(sweep_param.
type==
"OCT")
431 double numSteps =
static_cast<double>(sweep_param.
numSteps);
433 double stepMult = exp(log(2.0)/numSteps);
443 pcount = floor(fabs(log(pstart) - log(pstop))/ln2 * numSteps + 1);
444 sweep_param.
maxStep =
static_cast<int>(pcount);
446 else if(sweep_param.
type==
"LIST")
448 pcount = sweep_param.
valList.size();
453 Report::UserError0() <<
" Unsupported STEP type";
457 #ifdef Xyce_DEBUG_ANALYSIS
460 Xyce::dout() <<
"parameter = " << sweep_param.
name << std::endl;
461 Xyce::dout() <<
"pcount = " << pcount << std::endl;
462 Xyce::dout() <<
"pinterval = " << pinterval << std::endl;
469 return static_cast<int>(pinterval);
480 bool updateSweepParams(N_LOA_Loader &loader,
AnalysisManager &analysis_manager,
int step_count, std::vector<SweepParam>::iterator begin, std::vector<SweepParam>::iterator end)
482 bool resetFlag =
false;
485 for (std::vector<SweepParam>::iterator it = begin; it != end; ++it)
487 (*it).updateCurrentVal(step_count);
488 resetFlag = resetFlag || (*it).getSweepResetFlag();
489 loader.setParam ((*it).name, (*it).currentVal);