38 #include <Xyce_config.h>
43 #include <N_ERH_Message.h>
47 #include <N_PDS_Comm.h>
51 #include <N_UTL_FeatureTest.h>
52 #include <N_UTL_MachDepParams.h>
53 #include <N_UTL_OptionBlock.h>
59 : successfulStepsTaken_(0),
60 successStepsThisParameter_(0),
61 failedStepsAttempted_(0),
62 jacobiansEvaluated_(0),
63 iterationMatrixFactorizations_(0),
65 failedLinearSolves_(0),
67 residualEvaluations_(0),
68 nonlinearConvergenceFailures_(0),
69 linearSolutionTime_(0.0),
70 residualLoadTime_(0.0),
71 jacobianLoadTime_(0.0)
98 json << Util::JSON::open
103 << Util::nameValuePair(
"linearSolves", s.
linearSolves_) << Util::JSON::sep
105 << Util::nameValuePair(
"linearIters", s.
linearIters_) << Util::JSON::sep
108 << Util::nameValuePair(
"residualLoadTime", s.
residualLoadTime_) << Util::JSON::sep
109 << Util::nameValuePair(
"jacobianLoadTime", s.
jacobianLoadTime_) << Util::JSON::sep
111 << Util::JSON::close;
126 beginningIntegration(true),
127 baseIntegrationMethod_(TimeIntg::NoTimeIntegration::type),
131 doubleDCOPFlag_(false),
136 saveStatCountsVector_(),
154 Stats::StatTop _analysis(
name_);
162 Stats::StatTop _analysis(
name_);
171 Stats::StatTop _analysis(
name_);
293 bool bsuccess =
true;
295 if (t1 == 0 && t2 == 0)
358 for (std::vector<SweepParam>::iterator it = begin; it != end; ++it)
365 if (DEBUG_ANALYSIS && debug_level > 0)
367 Xyce::dout() << std::endl << std::endl
368 << Xyce::subsection_divider << std::endl
369 <<
"AnalysisManager::setupSweepLoop" << std::endl;
372 double pinterval = 1.0;
373 double pcount = 0.0, pstart, pstop, pstep;
376 for (std::vector<SweepParam>::iterator it = begin; it != end; ++it)
380 if (DEBUG_ANALYSIS && debug_level > 0)
382 Xyce::dout() <<
"name = " << sweep_param.
name << std::endl;
386 sweep_param.
interval =
static_cast<int> (pinterval);
390 if (sweep_param.
type==
"LIN")
407 pcount = floor(((pstop - pstart)/pstep));
413 if ( fabs(pstop-(pstart+(pcount+1.0)*pstep)) < 2.0*Util::MachineDependentParams::MachinePrecision())
431 sweep_param.
maxStep =
static_cast<int>(pcount);
433 if (DEBUG_ANALYSIS && debug_level > 0)
435 Xyce::dout() <<
"pstart = " << pstart << std::endl;
436 Xyce::dout() <<
"pstop = " << pstop << std::endl;
437 Xyce::dout() <<
"pstep = " << pstep << std::endl;
438 Xyce::dout() <<
"pstop-pstart/pstep = " << ((pstop - pstart)/pstep) << std::endl;
439 Xyce::dout() <<
"floor ()= " << floor(((pstop - pstart)/pstep)+1.0) << std::endl;
440 Xyce::dout() <<
"pcount = " << pcount << std::endl;
441 Xyce::dout() <<
"maxStep = " << sweep_param.
maxStep << std::endl;
444 else if(sweep_param.
type==
"DEC")
446 double numSteps =
static_cast<double>(sweep_param.
numSteps);
448 double stepMult = exp(log(10.0)/numSteps);
453 pcount = floor(fabs(log10(pstart) - log10(pstop)) * numSteps + 1);
454 sweep_param.
maxStep =
static_cast<int>(pcount);
456 else if(sweep_param.
type==
"OCT")
458 double numSteps =
static_cast<double>(sweep_param.
numSteps);
460 double stepMult = exp(log(2.0)/numSteps);
470 pcount = floor(fabs(log(pstart) - log(pstop))/ln2 * numSteps + 1);
471 sweep_param.
maxStep =
static_cast<int>(pcount);
473 else if(sweep_param.
type==
"LIST")
475 pcount = sweep_param.
valList.size();
480 Report::UserError0() <<
" Unsupported STEP type";
484 if (DEBUG_ANALYSIS && debug_level > 0)
486 Xyce::dout() <<
"parameter = " << sweep_param.
name << std::endl;
487 Xyce::dout() <<
"pcount = " << pcount << std::endl;
488 Xyce::dout() <<
"pinterval = " << pinterval << std::endl;
494 return static_cast<int>(pinterval);
507 bool resetFlag =
false;
510 for (std::vector<SweepParam>::iterator it = begin; it != end; ++it)
512 (*it).updateCurrentVal(step_count);
513 resetFlag = resetFlag || (*it).getSweepResetFlag();
514 loader.
setParam ((*it).name, (*it).currentVal);
517 Xyce::dout() <<
"Updating parameter " << (*it).name <<
" to " << (*it).currentVal << std::endl;
529 if (newton_convergence_status <= 0) {
554 const Util::Param & param)
556 if (param.uTag() ==
"DOUBLEDCOPSTEP")
560 else if (param.uTag() ==
"FIRSTDCOPSTEP")
568 else if (param.uTag() ==
"LASTDCOPSTEP")
unsigned int successStepsThisParameter_
unsigned int successfulStepsTaken_
Number of consecutive successful time-integration steps.
bool beginningIntegration
unsigned int tranStepNumber
virtual bool doProcessSuccessfulStep()=0
Pure virtual class to augment a linear system.
unsigned int iterationMatrixFactorizations_
bool updateSweepParams(Loader::Loader &loader, int step_count, std::vector< SweepParam >::iterator begin, std::vector< SweepParam >::iterator end, bool overrideOriginal=false)
int doubleDCOPStep_
current step in the DCOP loop.
virtual int getNumLinearSolves()
bool resetForStepAnalysis()
unsigned int stepNumber
Time-integration step number counter.
double linearSolutionTime_
unsigned int linearSolves_
void gatherStepStatistics(StatCounts &stats, Nonlinear::NonLinearSolver &nonlinear_solver, int newton_convergence_status)
virtual double getTotalLinearSolveTime()
Util::JSON & operator<<(Util::JSON &json, const StatCounts &s)
virtual bool doHandlePredictor()=0
virtual int getDoubleDCOPStep() const
virtual double getTotalResidualLoadTime()
unsigned int failedStepsAttempted_
Total number of failed time-integration steps.
StatCounts & operator+=(const StatCounts &stats)
bool setDCOPOption(const Util::Param ¶m)
std::vector< double > valList
virtual unsigned int getTotalNumLinearIters()
virtual int getNumJacobianLoads()
bool processSuccessfulStep()
virtual bool setParam(std::string &name, double val, bool overrideOriginal=false)=0
void setSweepSourceResetFlag(bool ssrf)
virtual bool doProcessFailedStep()=0
virtual bool printLoopInfo(int start, int finish)
StatCounts operator-(const StatCounts &s0, const StatCounts &s1)
unsigned int jacobiansEvaluated_
virtual double getTotalJacobianLoadTime()
unsigned int linearIters_
bool getDoubleDCOPEnabled() const
bool firstDoubleDCOPStep()
unsigned int failedLinearSolves_
virtual double getParamAndReduce(const std::string &name) const =0
virtual bool doLoopProcess()=0
virtual int getNumFailedLinearSolves()
AnalysisBase(AnalysisManager &analysis_manager, const char *name)
virtual int getNumJacobianFactorizations()
unsigned int nonlinearConvergenceFailures_
unsigned int residualEvaluations_
std::vector< StatCounts > saveStatCountsVector_
int setupSweepLoop(Loader::Loader &loader, std::vector< SweepParam >::iterator begin, std::vector< SweepParam >::iterator end)
virtual int getNumResidualLoads()
virtual bool doFinish()=0