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.145.2.2 $
42 //
43 // Revision Date : $Date: 2015/04/02 18:20:18 $
44 //
45 // Current Owner : $Author: tvrusso $
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 
57 #include <N_ERH_ErrorMgr.h>
58 #include <N_UTL_Diagnostic.h>
59 #include <N_UTL_ExtendedString.h>
60 #include <N_UTL_FeatureTest.h>
61 
62 namespace Xyce {
63 namespace TimeIntg {
64 
65 int
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(true),
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 //-----------------------------------------------------------------------------
283 bool
285  const Util::Param & param)
286 {
287  if (DEBUG_ANALYSIS && param.uTag() == "CONSTSTEP")
288  {
289  constantTimeStepFlag = static_cast<bool> (param.getImmutableValue<int>());
290  }
291  else if (param.uTag() == "USEDEVICEMAX")
292  {
293  useDeviceTimeStepMaxFlag = static_cast<bool> (param.getImmutableValue<int>());
294  }
295  else if (param.uTag() == "RELTOL")
296  {
297  relErrorTol = param.getImmutableValue<double>();
298  relErrorTolGiven = true;
299  }
300  else if (param.uTag() == "ABSTOL")
301  {
302  absErrorTol = param.getImmutableValue<double>();
303  }
304  else if (param.uTag() == "BPENABLE" )
305  {
306  bpEnable = static_cast<bool> (param.getImmutableValue<int>());
307  }
308  else if (param.uTag() == "RESTARTSTEPSCALE" )
309  {
310  restartTimeStepScale = param.getImmutableValue<double>();
311  }
312  else if (param.uTag() == "MINTIMESTEPSBP")
313  {
314  minTimeStepsBP = param.getImmutableValue<int>();
315  minTimeStepsBPGiven = true;
316  }
317  else if (param.uTag() == "ERROPTION" )
318  {
319  errorAnalysisOption = param.getImmutableValue<int>();
320  // tscoffe/tmei 12/7/07: If error option = 1 (NO LTE) then make sure minTimeStepBP is enabled.
322  {
323  if (!minTimeStepsBPGiven)
324  {
325  minTimeStepsBPGiven = true;
326  }
327  }
328  }
329  else if (param.uTag() == "JACLIMITFLAG" )
330  {
331  jacLimitFlag= static_cast<bool> (param.getImmutableValue<int>());
332  }
333  else if (param.uTag() == "JACLIMIT" )
334  {
335  jacLimit = param.getImmutableValue<double>();
336  }
337  else if (param.uTag() == "MAXORD" )
338  {
339  maxOrder = param.getImmutableValue<int>();
340  }
341  else if (param.uTag() == "MINORD" )
342  {
343  minOrder = param.getImmutableValue<int>();
344  }
345  else if (param.uTag() == "TIMESTEPSREVERSAL" )
346  {
347  timestepsReversal = param.getImmutableValue<bool>();
348  }
349  else if (param.uTag() == "TESTFIRSTSTEP" )
350  {
351  testFirstStep = static_cast<bool> (param.getImmutableValue<int>());
352  }
353  else if (param.uTag() == "DELMAX" )
354  {
355  delmax = param.getImmutableValue<double>();
356  delmaxGiven = true;
357  }
358  else if (param.uTag() == "NLMIN" )
359  {
360  NLmin = param.getImmutableValue<int>();
361  if (NLmin > NLmax)
362  {
363  Report::UserError() << ".options timeint NLMIN = " << NLmin << " > " << NLmax << " = NLMAX!";
364  }
365  }
366  else if (param.uTag() == "NLMAX" )
367  {
368  NLmax = param.getImmutableValue<int>();
369  if (NLmin > NLmax)
370  {
371  Report::UserError() << ".options timeint NLMIN = " << NLmin << " > " << NLmax << " = NLMAX!";
372  }
373  }
374  else if (param.uTag() == "NEWLTE")
375  {
376  newLte = param.getImmutableValue<double>();
377 
378  if (newLte && !relErrorTolGiven)
379  relErrorTol = 1.0e-3;
380  }
381  else if (param.uTag() == "NEWBPSTEPPING")
382  {
383  newBPStepping = param.getImmutableValue<double>();
384  }
385  else if (param.uTag() == "INTERPOUTPUT")
386  {
387  interpOutputFlag = static_cast<bool> (param.getImmutableValue<int>());
388  }
389  else if (param.uTag() == "DTMIN")
390  {
391  minTimeStep = param.getImmutableValue<double>();
392  minTimeStepGiven = true;
393  }
394  else if (param.uTag() == "MINTIMESTEPRECOVERY")
395  {
396  minTimeStepRecoveryCounter = param.getImmutableValue<int>();
397  }
398  else
399  {
400  return false;
401  }
402 
403  return true;
404 }
405 
406 
407 //-----------------------------------------------------------------------------
408 // Function : setAnalysisOptions
409 // Purpose :
410 // Special Notes : These are from '.options timeint'
411 // Scope : public
412 // Creator : Eric R. Keiter, SNL, Parallel Computational Sciences
413 // Creation Date : 04/18/02
414 //-----------------------------------------------------------------------------
415 bool
417  const Util::Param & param)
418 {
419  if (param.uTag() == "TSTART")
420  {
421  initialOutputTime = param.getImmutableValue<double>();
422  initialOutputTimeGiven = true;
423  }
424  else if (param.uTag() == "TSTOP")
425  {
426  finalTime = param.getImmutableValue<double>();
427  }
428  else if (param.uTag() == "TSTEP")
429  {
430  initialTimeStep = param.getImmutableValue<double>();
431  }
432  else if (param.uTag() == "DTMAX")
433  {
434  maxTimeStep = param.getImmutableValue<double>();
435  maxTimeStepGiven = true;
436  if (DEBUG_ANALYSIS && isActive(Diag::TIME_PARAMETERS))
437  {
438  dout() << "setting maxTimeStep = " << maxTimeStep << std::endl;
439  }
440  }
441  else
442  {
443  return false;
444  }
445 
446  return true;
447 }
448 
449 } // namespace TimeIntg
450 } // 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.
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)