39 #include <Xyce_config.h>
45 #include <N_ERH_ErrorMgr.h>
47 #include <N_UTL_FeatureTest.h>
48 #include <N_UTL_MachDepParams.h>
49 #include <N_UTL_Math.h>
50 #include <N_UTL_Param.h>
95 else if (
type ==
"DEC" ||
type ==
"OCT")
100 else if (
type ==
"LIST")
103 int index = (localStepNumber < size)?localStepNumber:(size-1);
109 Report::DevelFatal0().in(
"SweepParam::updateCurrentVal") <<
"Unsupported type specified";
113 Xyce::dout() << std::endl
114 << Xyce::subsection_divider << std::endl
115 <<
"updateCurrentVal" << std::endl
116 <<
" name = " <<
name << std::endl
117 <<
" stepNumberArg = " << stepNumberArg<< std::endl
118 <<
" interval = " <<
interval << std::endl
120 <<
" localStepNumber = " << localStepNumber << std::endl
121 <<
" inum = " << inum << std::endl
123 <<
" currentVal = " <<
currentVal << std::endl
124 << Xyce::subsection_divider << std::endl;
140 os <<
"\tname = " << sp.
name
160 Xyce::dout() << std::endl << section_divider << std::endl
161 <<
"parseSweepParam" << std::endl;
163 for (Util::ParamList::const_iterator it = first, end = last; it != end; ++it)
165 Xyce::dout() << (*it).uTag() <<
"\t";
166 if ((*it).uTag() ==
"PARAM" || (*it).uTag() ==
"TYPE")
168 Xyce::dout() << (*it).stringValue();
172 Xyce::dout() << (*it).getImmutableValue<
double>();
174 Xyce::dout() << std::endl;
180 Util::ParamList::const_iterator it_param = last;
181 for (Util::ParamList::const_iterator it = first, end = last; it != end; ++it)
183 if ((*it).uTag() ==
"TYPE")
185 sweep_param.
type = (*it).stringValue();
187 else if ((*it).uTag() ==
"PARAM")
190 sweep_param.
name = (*it).stringValue();
194 if (it_param != last)
196 if (sweep_param.
type ==
"LIN")
198 sweep_param.
startVal = (*++it_param).getImmutableValue<double>();
199 sweep_param.
stopVal = (*++it_param).getImmutableValue<double>();
200 sweep_param.
stepVal = (*++it_param).getImmutableValue<double>();
202 else if (sweep_param.
type ==
"DEC" || sweep_param.
type ==
"OCT")
204 sweep_param.
startVal = (*++it_param).getImmutableValue<double>();
205 sweep_param.
stopVal = (*++it_param).getImmutableValue<double>();
206 sweep_param.
numSteps = (*++it_param).getImmutableValue<int>();
208 else if (sweep_param.
type ==
"LIST")
210 for (Util::ParamList::const_iterator it = ++it_param, end = last; it != end; ++it)
212 sweep_param.
valList.push_back((*it).getImmutableValue<
double>());
217 Report::DevelFatal().in(
"parseSweepParam") <<
"Unsupported DC type";
236 for (std::vector<SweepParam>::iterator it = begin; it != end; ++it)
243 double pinterval = 1.0;
244 double pcount = 0.0, pstart, pstop, pstep;
247 for (std::vector<SweepParam>::iterator it = begin; it != end; ++it)
252 sweep_param.
interval =
static_cast<int> (pinterval);
256 if (sweep_param.
type==
"LIN")
273 pcount = floor(((pstop - pstart)/pstep));
279 if ( fabs(pstop-(pstart+(pcount+1.0)*pstep)) < 2.0*Util::MachineDependentParams::MachinePrecision())
297 sweep_param.
maxStep =
static_cast<int>(pcount);
299 else if(sweep_param.
type==
"DEC")
301 double numSteps =
static_cast<double>(sweep_param.
numSteps);
303 double stepMult = exp(log(10.0)/numSteps);
308 pcount = floor(fabs(log10(pstart) - log10(pstop)) * numSteps + 1);
309 sweep_param.
maxStep =
static_cast<int>(pcount);
311 else if(sweep_param.
type==
"OCT")
313 double numSteps =
static_cast<double>(sweep_param.
numSteps);
315 double stepMult = exp(log(2.0)/numSteps);
325 pcount = floor(fabs(log(pstart) - log(pstop))/ln2 * numSteps + 1);
326 sweep_param.
maxStep =
static_cast<int>(pcount);
328 else if(sweep_param.
type==
"LIST")
330 pcount = sweep_param.
valList.size();
335 Report::UserError0() <<
" Unsupported STEP type";
342 return static_cast<int>(pinterval);
358 for (std::vector<SweepParam>::iterator it = begin; it != end; ++it)
360 (*it).updateCurrentVal(step_count);
361 reset = reset || (*it).getSweepResetFlag();
362 loader.
setParam((*it).name, (*it).currentVal, overrideOriginal);
365 Xyce::dout() <<
"Updating parameter " << (*it).name <<
" to " << (*it).currentVal << std::endl;
int setupSweepLoop(Parallel::Machine comm, Loader::Loader &loader, std::vector< SweepParam >::iterator begin, std::vector< SweepParam >::iterator end)
bool updateCurrentVal(int stepNumber)
Pure virtual class to augment a linear system.
bool updateSweepParams(Loader::Loader &loader, int step_count, std::vector< SweepParam >::iterator begin, std::vector< SweepParam >::iterator end, bool overrideOriginal)
Util::JSON & operator<<(Util::JSON &json, const StatCounts &s)
std::vector< double > valList
virtual bool setParam(std::string &name, double val, bool overrideOriginal=false)=0
SweepParam parseSweepParams(Util::ParamList::const_iterator first, Util::ParamList::const_iterator last)
Populate the sweep params from the parameter list.
virtual double getParamAndReduce(Parallel::Machine comm, const std::string &name) const =0