Xyce  6.1
N_TIA_TIAParams.C
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 // Copyright Notice
3 //
4 // Copyright 2002 Sandia Corporation. Under the terms
5 // of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S.
6 // Government retains certain rights in this software.
7 //
8 // Xyce(TM) Parallel Electrical Simulator
9 // Copyright (C) 2002-2015 Sandia Corporation
10 //
11 // This program is free software: you can redistribute it and/or modify
12 // it under the terms of the GNU General Public License as published by
13 // the Free Software Foundation, either version 3 of the License, or
14 // (at your option) any later version.
15 //
16 // This program is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // GNU General Public License for more details.
20 //
21 // You should have received a copy of the GNU General Public License
22 // along with this program. If not, see <http://www.gnu.org/licenses/>.
23 //-----------------------------------------------------------------------------
24 
25 //-----------------------------------------------------------------------------
26 // Filename : $RCSfile: N_TIA_TIAParams.C,v $
27 //
28 // Purpose : This file implements the class associated with all user
29 // specified parameters which relate to the time integration
30 // algorithms and problem definition.
31 //
32 // Special Notes :
33 //
34 // Creator : Buddy Watts
35 //
36 // Creation Date : 6/1/00
37 //
38 // Revision Information:
39 // ---------------------
40 //
41 // Revision Number: $Revision: 1.154 $
42 //
43 // Revision Date : $Date: 2015/09/28 22:28:21 $
44 //
45 // Current Owner : $Author: erkeite $
46 //-----------------------------------------------------------------------------
47 
48 #include <Xyce_config.h>
49 
50 #include <iostream>
51 
52 #include <N_NLS_fwd.h>
53 
54 #include <N_TIA_TIAParams.h>
55 #include <N_IO_CmdParse.h>
56 #include <N_IO_PkgOptionsMgr.h>
57 
58 #include <N_ERH_ErrorMgr.h>
59 #include <N_UTL_Diagnostic.h>
60 #include <N_UTL_ExtendedString.h>
61 #include <N_UTL_FeatureTest.h>
62 
63 namespace Xyce {
64 namespace TimeIntg {
65 
67  const IO::CmdParse & command_line)
68 {
69  return command_line.getArgumentIntValue("-maxord", 5);
70 }
71 
72 
73 //-----------------------------------------------------------------------------
74 // Function : TIAParams::TIAParams
75 // Purpose : constructor
76 // Special Notes :
77 // Scope : public
78 // Creator : Buddy Watts, SNL
79 // Creation Date : 6/01/00
80 //-----------------------------------------------------------------------------
81 
83  : initialOutputTime(0.0),
84  initialOutputTimeGiven(false),
85  initialTime(0.0),
86  finalTime(0.0),
87  initialTimeStep(1.0e-10),
88  maxTimeStep(1.0e+99),
89  maxTimeStepGiven(false),
90  minTimeStep(0.0),
91  minTimeStepGiven(false),
92  constantTimeStepFlag(false),
93  useDeviceTimeStepMaxFlag(true),
94  newBPStepping(true),
95  minTimeStepsBP(10),
96  minTimeStepsBPGiven(false),
97  newLte(1),
98  errorAnalysisOption(LOCAL_TRUNCATED_ESTIMATES),
99  NLmin(3),
100  NLmax(8),
101  delmax(1.0e+99),
102  delmaxGiven(false),
103  errorAnalysisOptionResetCount(0),
104  timestepsReversal(false),
105  testFirstStep(false),
106  relErrorTol(1.0e-3),
107  absErrorTol(1.0e-6),
108  relErrorTolGiven(false),
109  errTolAcceptance(1.0),
110  bpEnable(true),
111  restartTimeStepScale(0.005),
112  jacLimitFlag(false),
113  jacLimit(1.0e+17),
114  maxOrder(5),
115  minOrder(1),
116  interpOutputFlag(true),
117  minTimeStepRecoveryCounter(0)
118 {}
119 
120 //-----------------------------------------------------------------------------
121 // Function : TIAParams::TIAParams
122 // Purpose : destructor
123 // Special Notes :
124 // Scope : public
125 // Creator : Buddy Watts, SNL
126 // Creation Date : 6/01/00
127 //-----------------------------------------------------------------------------
129 {}
130 
131 //-----------------------------------------------------------------------------
132 // Function : TIAParams::printParams
133 // Purpose :
134 // Special Notes :
135 // Scope : public
136 // Creator : Eric Keiter, 9233.
137 // Creation Date : 7/12/01
138 //-----------------------------------------------------------------------------
139 void TIAParams::printParams(std::ostream &os, int analysis) const
140 {
141  os << "\n" << std::endl;
142  os << Xyce::section_divider << std::endl;
143  os << "\n***** Time Integration solver options:\n" << std::endl;
144 
145  if (analysis == Xyce::Nonlinear::TRANSIENT)
146  {
147  os << "\tAnalysis:\t\t\tTRANSIENT" << std::endl
148  << "\tInitial Time (sec):\t\t" << initialTime << std::endl
149  << "\tFinal Time (sec):\t\t" << finalTime << std::endl
150  << "\tStarting Time Step(sec):\t" << initialTimeStep << std::endl
151  << "\tRestart Time Step Scale:\t" << restartTimeStepScale << std::endl
152  << "\tError Analysis option:\t" << errorAnalysisOption << std::endl
153  << "\tInitial Output Time:\t" << initialOutputTime << std::endl
154  // << "\tTime Integration method:\t" << integrationMethod << std::endl
155 
156  << (constantTimeStepFlag ? "\tUsing Constant Step Size" : "\tUsing Variable Step Size") << std::endl
157  << (useDeviceTimeStepMaxFlag ? "\tUsing Device specified maximum stepsize" : "\tNOT using Device specified maximum stepsize") << std::endl;
158  // << (nlNearConvFlag ? "\tNL Near Convergence Flag is ON" : "\tNL Near Convergence Flag is OFF") << std::endl
159  // << (passNLStall ? "\tNL Pass Non-linear Stalls is ON" : "\tNL Pass Non-linear Stalls is OFF") << std::endl;
160  }
161  else
162  {
163  os << "\tAnalysis:\t\t\tDC SWEEP" << std::endl;
164  }
165 
166  os << "\tabsErrorTol:\t\t\t" << absErrorTol << std::endl
167  << "\trelErrorTol:\t\t\t" << relErrorTol << std::endl
168  << "\tMaximum Order:\t\t\t" << maxOrder << std::endl
169  << "\tMinimum Order:\t\t\t" << minOrder << std::endl
170  << "\tInterpolated Output Flag:\t\t " << (interpOutputFlag ? "true": "false") << std::endl;
171 
172  // << "\tConductance Test Flag:\t\t" << (condTestFlag ? "true": "false") << std::endl;
173 
174  // if (condTestDeviceNames.empty())
175  // {
176  // os << "\tConductance Test Device Name List is:\t\tEMPTY" << std::endl;
177  // }
178  // else
179  // {
180  // os << "\tConductance Test Device Name List contains: " << std::endl;
181  // for (std::list< std::string >::iterator it = condTestDeviceNames.begin(); it != condTestDeviceNames.end(); ++it)
182  // {
183  // os << " \"" << *it << "\"";
184  // }
185  // }
186  os << Xyce::section_divider << std::endl;
187 }
188 
189 //-----------------------------------------------------------------------------
190 // Function : TIAParams::operator=
191 // Purpose : "=" operator.
192 // Special Notes :
193 // Scope : public
194 // Creator : Eric R. Keiter, SNL, Computational Sciences
195 // Creation Date : 12/17/05
196 //-----------------------------------------------------------------------------
198  : initialOutputTime(right.initialOutputTime),
199  initialOutputTimeGiven(right.initialOutputTimeGiven),
200  initialTime(right.initialTime),
201  finalTime(right.finalTime),
202  initialTimeStep(right.initialTimeStep),
203  maxTimeStep(right.maxTimeStep),
204  maxTimeStepGiven(right.maxTimeStepGiven),
205  minTimeStep(right.minTimeStep),
206  minTimeStepGiven(right.minTimeStepGiven),
207  constantTimeStepFlag(right.constantTimeStepFlag),
208  useDeviceTimeStepMaxFlag(right.useDeviceTimeStepMaxFlag),
209  errorAnalysisOption(right.errorAnalysisOption),
210  errorAnalysisOptionResetCount(right.errorAnalysisOptionResetCount),
211  bpEnable(right.bpEnable),
212  restartTimeStepScale(right.restartTimeStepScale),
213  relErrorTol(right.relErrorTol),
214  absErrorTol(right.absErrorTol),
215  errTolAcceptance(right.errTolAcceptance),
216  jacLimitFlag(right.jacLimitFlag),
217  jacLimit(right.jacLimit),
218  maxOrder(right.maxOrder),
219  minOrder(right.minOrder),
220  interpOutputFlag(right.interpOutputFlag)
221 {}
222 
223 //-----------------------------------------------------------------------------
224 // Function : TIAParams::operator=
225 // Purpose : "=" operator.
226 // Special Notes :
227 // Scope : public
228 // Creator : Eric R. Keiter, SNL, Computational Sciences
229 // Creation Date : 12/17/05
230 //-----------------------------------------------------------------------------
232 {
233  if (this != &right)
234  {
237  initialTime = right.initialTime;
238  finalTime = right.finalTime;
240  maxTimeStep = right.maxTimeStep;
242  minTimeStep = right.minTimeStep;
248  bpEnable = right.bpEnable;
250  relErrorTol = right.relErrorTol;
251  absErrorTol = right.absErrorTol;
253  jacLimitFlag = right.jacLimitFlag;
254  jacLimit = right.jacLimit;
255  maxOrder = right.maxOrder;
256  minOrder = right.minOrder;
258  }
259 
260  return *this;
261 }
262 
263 void
265  int max_order)
266 {
267  if (max_order < 1)
268  max_order = 1;
269  else if (max_order > 5)
270  max_order = 5;
271 
272  maxOrder = max_order;
273 }
274 
275 //-----------------------------------------------------------------------------
276 // Function : setTimeIntegratorOptions
277 // Purpose :
278 // Special Notes : These are from '.options timeint'
279 // Scope : public
280 // Creator : Eric R. Keiter, SNL, Parallel Computational Sciences
281 // Creation Date : 04/18/02
282 //-----------------------------------------------------------------------------
284  const Util::Param & param)
285 {
286  bool value_set =
287  Util::setValue(param, "USEDEVICEMAX", useDeviceTimeStepMaxFlag)
288  || setValue(param, "RELTOL", relErrorTol, relErrorTolGiven)
289  || setValue(param, "ABSTOL", absErrorTol)
290  || setValue(param, "BPENABLE", bpEnable)
291  || setValue(param, "RESTARTSTEPSCALE", restartTimeStepScale)
292  || setValue(param, "MINTIMESTEPSBP", minTimeStepsBP, minTimeStepsBPGiven)
293  || setValue(param, "JACLIMITFLAG", jacLimitFlag)
294  || setValue(param, "JACLIMIT", jacLimit)
295  || setValue(param, "MAXORD", maxOrder)
296  || setValue(param, "MINORD", minOrder)
297  || setValue(param, "TIMESTEPSREVERSAL", timestepsReversal)
298  || setValue(param, "TESTFIRSTSTEP", testFirstStep)
299  || setValue(param, "DELMAX", delmax, delmaxGiven)
300  || setValue(param, "NLMIN", NLmin)
301  || setValue(param, "NLMAX", NLmax)
302  || setValue(param, "NEWLTE", newLte)
303  || setValue(param, "NEWBPSTEPPING", newBPStepping)
304  || setValue(param, "INTERPOUTPUT", interpOutputFlag)
305  || setValue(param, "DTMIN", minTimeStep, minTimeStepGiven)
306  || setValue(param, "MINTIMESTEPRECOVERY", minTimeStepRecoveryCounter)
307  || setValue(param, "CONSTSTEP", constantTimeStepFlag)
308  || setValue(param, "ERROPTION", errorAnalysisOption);
309 
310  if (value_set)
311  ;
312  else
313  {
314  return false;
315  }
316 
317  if (NLmin > NLmax)
318  {
319  Report::UserError() << ".options timeint NLMIN = " << NLmin << " > " << NLmax << " = NLMAX!";
320  }
321 
322  if (NLmin > NLmax)
323  {
324  Report::UserError() << ".options timeint NLMIN = " << NLmin << " > " << NLmax << " = NLMAX!";
325  }
326 
327  if (newLte < 0 || newLte > 3)
328  Report::UserError() << "Unsupported NEWLTE type";
329 
330  // tscoffe/tmei 12/7/07: If error option = 1 (NO LTE) then make sure minTimeStepBP is enabled.
332  {
333  minTimeStepsBPGiven = true;
334  }
335 
336  return true;
337 }
338 
339 
340 //-----------------------------------------------------------------------------
341 // Function : setAnalysisOptions
342 // Purpose :
343 // Special Notes : These are from '.options timeint'
344 // Scope : public
345 // Creator : Eric R. Keiter, SNL, Parallel Computational Sciences
346 // Creation Date : 04/18/02
347 //-----------------------------------------------------------------------------
349  const Util::Param & param)
350 {
351  bool value_set =
353  || Util::setValue(param, "TSTOP", finalTime)
354  || Util::setValue(param, "TSTEP", initialTimeStep)
355  || Util::setValue(param, "DTMAX", maxTimeStep, maxTimeStepGiven);
356 
357  if (value_set)
358  ;
359  else
360  {
361  return false;
362  }
363 
364  if (DEBUG_ANALYSIS && isActive(Diag::TIME_PARAMETERS))
365  {
366  dout() << "setting maxTimeStep = " << maxTimeStep << std::endl;
367  }
368 
369  return true;
370 }
371 
372 void
374  IO::PkgOptionsMgr &options_manager)
375 {
376  {
377  Util::ParamMap &parameters = options_manager.addOptionsMetadataMap("TIMEINT");
378 
379  parameters.insert(Util::ParamMap::value_type("METHOD", Util::Param("METHOD", 1)));
380  if (DEBUG_ANALYSIS)
381  parameters.insert(Util::ParamMap::value_type("CONSTSTEP", Util::Param("CONSTSTEP", 0)));
382  parameters.insert(Util::ParamMap::value_type("USEDEVICEMAX", Util::Param("USEDEVICEMAX", 1)));
383  parameters.insert(Util::ParamMap::value_type("RELTOL", Util::Param("RELTOL", 1.0E-2)));
384  parameters.insert(Util::ParamMap::value_type("ABSTOL", Util::Param("ABSTOL", 1.0E-6)));
385  parameters.insert(Util::ParamMap::value_type("RESTARTSTEPSCALE", Util::Param("RESTARTSTEPSCALE", .005)));
386 // parameters.insert(Util::ParamMap::value_type("NLNEARCONV", Util::Param("NLNEARCONV", 1)));
387  parameters.insert(Util::ParamMap::value_type("NLNEARCONV", Util::Param("NLNEARCONV", 0)));
388  parameters.insert(Util::ParamMap::value_type("NLSMALLUPDATE", Util::Param("NLSMALLUPDATE", 1)));
389  parameters.insert(Util::ParamMap::value_type("DOUBLEDCOP", Util::Param("DOUBLEDCOP", "")));
390  parameters.insert(Util::ParamMap::value_type("RESETTRANNLS", Util::Param("RESETTRANNLS", 1)));
391  parameters.insert(Util::ParamMap::value_type("BPENABLE", Util::Param("BPENABLE", 1)));
392  parameters.insert(Util::ParamMap::value_type("EXITTIME", Util::Param("EXITTIME", 0.0)));
393  parameters.insert(Util::ParamMap::value_type("EXITSTEP", Util::Param("EXITSTEP", 0)));
394  parameters.insert(Util::ParamMap::value_type("ERROPTION", Util::Param("ERROPTION", 0)));
395  parameters.insert(Util::ParamMap::value_type("DEBUGLEVEL", Util::Param("DEBUGLEVEL", 0)));
396  parameters.insert(Util::ParamMap::value_type("JACLIMITFLAG", Util::Param("JACLIMITFLAG", 0)));
397  parameters.insert(Util::ParamMap::value_type("JACLIMIT", Util::Param("JACLIMIT", 1.0e17)));
398  parameters.insert(Util::ParamMap::value_type("DAESTATEDERIV", Util::Param("DAESTATEDERIV", 0)));
399  parameters.insert(Util::ParamMap::value_type("TESTFIRSTSTEP", Util::Param("TESTFIRSTSTEP", 0)));
400  parameters.insert(Util::ParamMap::value_type("DTMIN", Util::Param("DTMIN", 0.0)));
401  parameters.insert(Util::ParamMap::value_type("NEWBPSTEPPING", Util::Param("NEWBPSTEPPING", 0)));
402  parameters.insert(Util::ParamMap::value_type("MINTIMESTEPSBP", Util::Param("MINTIMESTEPSBP", 10)));
403  parameters.insert(Util::ParamMap::value_type("NEWLTE", Util::Param("NEWLTE", 1)));
404  parameters.insert(Util::ParamMap::value_type("MAXORD", Util::Param("MAXORD", 5)));
405  parameters.insert(Util::ParamMap::value_type("MINORD", Util::Param("MINORD", 1)));
406  parameters.insert(Util::ParamMap::value_type("OUTPUTINTERPMPDE", Util::Param("OUTPUTINTERPMPDE", 1)));
407  parameters.insert(Util::ParamMap::value_type("INTERPOUTPUT", Util::Param("INTERPOUTPUT", 1)));
408  parameters.insert(Util::ParamMap::value_type("CONDTEST", Util::Param("CONDTEST", 0)));
409  parameters.insert(Util::ParamMap::value_type("CONDTESTDEVICENAME", Util::Param("CONDTESTDEVICENAME", "dev_name")));
410  parameters.insert(Util::ParamMap::value_type("ISOCONDTEST", Util::Param("ISOCONDTEST", 0)));
411  parameters.insert(Util::ParamMap::value_type("ISOCONDTESTDEVICENAME", Util::Param("ISOCONDTESTDEVICENAME", "dev_name")));
412  parameters.insert(Util::ParamMap::value_type("PASSNLSTALL", Util::Param("PASSNLSTALL", false)));
413  parameters.insert(Util::ParamMap::value_type("NLMIN", Util::Param("NLMIN", 3)));
414  parameters.insert(Util::ParamMap::value_type("NLMAX", Util::Param("NLMAX", 8)));
415  parameters.insert(Util::ParamMap::value_type("DELMAX", Util::Param("DELMAX", 1.0e+99)));
416  parameters.insert(Util::ParamMap::value_type("TIMESTEPSREVERSAL", Util::Param("TIMESTEPSREVERSAL", false)));
417  parameters.insert(Util::ParamMap::value_type("MINTIMESTEPRECOVERY", Util::Param("MINTIMESTEPRECOVERY", 0)));
418  parameters.insert(Util::ParamMap::value_type("HISTORYTRACKINGDEPTH", Util::Param("HISTORYTRACKINGDEPTH", 50)));
419  }
420 }
421 
422 } // namespace TimeIntg
423 } // namespace Xyce
bool setAnalysisOption(const Util::Param &param)
double initialTimeStep
User specified initial time step.
bool setTimeIntegratorOption(const Util::Param &param)
Pure virtual class to augment a linear system.
int errorAnalysisOptionResetCount
Iteration count down to reset errorAnalysisOption to LOCAL_TRUNCATED_ESTIMATES.
int errorAnalysisOption
Error analysis option.
double finalTime
End time for simulation.
void setValue(ParameterBase &entity, const Descriptor &descriptor, const T &value)
Sets the value of the parameter.
Definition: N_DEV_Pars.h:1281
double maxTimeStep
User specified maximum time step.
void setMaxOrder(int max_order)
double minTimeStep
User specified minimum time step.
bool constantTimeStepFlag
Constant time step integration flag.
int minTimeStepsBP
User specified mininum number of steps between breakpoints.
bool bpEnable
Enable breakpoints flag.
double restartTimeStepScale
Time step is scaled coming out of a breakpoint (StepErrorControl)
void printParams(std::ostream &os, int analysis) const
int maxOrder(const IO::CmdParse &command_line)
double initialOutputTime
Time at which output starts (StepErrorControl)
double initialTime
Beginning time for the time integrator (StepErrorControl, integrators access from StepErrorControl) ...
bool useDeviceTimeStepMaxFlag
True if devices impose a time step maximum.
TIAParams & operator=(const TIAParams &right)
static void populateMetadata(IO::PkgOptionsMgr &options_manager)