Xyce  6.1
N_DEV_DeviceOptions.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_DEV_DeviceOptions.C,v $
27 //
28 // Purpose :
29 //
30 // Special Notes :
31 //
32 // Creator : Eric R. Keiter, SNL, Parallel Computational Sciences
33 //
34 // Creation Date : 07/06/01
35 //
36 // Revision Information:
37 // ---------------------
38 //
39 // Revision Number: $Revision: 1.98.2.1 $
40 //
41 // Revision Date : $Date: 2015/04/02 18:20:09 $
42 //
43 // Current Owner : $Author: tvrusso $
44 //-----------------------------------------------------------------------------
45 
46 #include <Xyce_config.h>
47 
48 #include <iostream>
49 
50 #ifdef HAVE_CLIMITS
51 #include <climits>
52 #else
53 #include <limits.h>
54 #endif
55 
56 
57 #include <N_DEV_Const.h>
58 #include <N_DEV_DeviceOptions.h>
59 #include <N_ERH_ErrorMgr.h>
60 #include <N_IO_CmdParse.h>
61 #include <N_UTL_Diagnostic.h>
62 #include <N_UTL_FeatureTest.h>
63 #include <N_UTL_OptionBlock.h>
64 #include <N_UTL_MachDepParams.h>
65 
66 namespace Xyce {
67 namespace Device {
68 
69 //-----------------------------------------------------------------------------
70 // Function : DeviceOptions::DeviceOptions
71 // Purpose : constructor
72 //
73 // Special Notes : The are initialized to default values, but are reset
74 // in the setupDefaultOptions function. Confusing I know,
75 // but I had a reason for doing this, I think.
76 //
77 // Consider setupDefaultOptions function to be the
78 // ultimate authority.
79 //
80 // Scope : public
81 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
82 // Creation Date : 4/01/02
83 //-----------------------------------------------------------------------------
85  : defad (0.0e+0), // MOS drain diffusion area.
86  defas (0.0e+0), // MOS source diffusion area.
87  defl (1.0e-4), // MOS channel length.
88  defw (1.0e-4), // MOS channel width.
89  abstol(1.0e-12), // absolute current error tol.
90  reltol(1.0e-4), // relative current error tol.
91  chgtol(1.0e-12), // absolute charge error tol.
92  gmin (1.0e-12), // minimum allowed conductance.
93  gmin_orig (1.0e-12), // minimum allowed conductance, final
94  gmin_init (1.0e-02), // minimum allowed conductance, initial
95  gmin_scalar(1.0e10),
96  gmax (1.0e20), // maximum allowed conductance.
97  testJac_relTol(0.01), // reltol for num. jacobian diagnostic
98  testJac_absTol(1.0e-8), // abstol for num. jacobian diagnostic.
99  testJac_SqrtEta(1.0e-8), // dx = numJacSqrtEta * (1.0 + fabs(soln[i]));
100  deviceSens_dp(1.0e-8), // similar to eta, but for numerical device sensitivities
101  tnom (CONSTREFTEMP),
102  temp(Util::Param("TEMP", CONSTREFTEMP)),
103  scale_src (0.0),
104  numericalJacobianFlag (false),
105  testJacobianFlag (false),
106  testJacStartStep(0),
107  testJacStopStep(Util::MachineDependentParams::IntMax()),
108  testJacWarn (false),
109  testJacDeviceName(""),
110  testJacDeviceNameGiven( false ),
111  voltageLimiterFlag (true),
112  lambertWFlag (0),
113  icMultiplier (10000.0),
114  defaultMaxTimeStep (1.0e99),
115  vdsScaleMin(0.3),
116  vgstConst(4.5),
117  numGainScaleBlocks(1),
118  staggerGainScale(false),
119  randomizeVgstConst(false),
120  length0(5.0e-6), // used in mosfet "size" homotopy
121  width0(200.0e-6), // used in mosfet "size" homotopy
122  tox0(6.0e-8), // used in mosfet "size" homotopy
123  minRes(0.0),
124  minCap(0.0),
125  exp_order(100.0),
126  zeroResistanceTol(1.0e-100),
127  checkForZeroResistance(true),
128  debugMinTimestep (0),
129  debugMaxTimestep (Util::MachineDependentParams::IntMax()), // later, this should be MAX_INT
130  debugMinTime (0),
131  debugMaxTime (Util::MachineDependentParams::DoubleMax()),
132  verboseLevel (0),
133 #ifndef Xyce_NEW_EXCESS_PHASE
134  newExcessPhase (false),
135  defaultNewExcessPhase (false),
136 #else
137  newExcessPhase (true),
138  defaultNewExcessPhase (true),
139 #endif
140  excessPhaseScalar1 (1.0),
141  excessPhaseScalar2 (1.0),
142  randomSeed (0),
143  tryToCompact (false),
144  calculateAllLeadCurrents (false),
145  newMeyerFlag(false)
146 {}
147 
148 //-----------------------------------------------------------------------------
149 // Function : DeviceOptions::~DeviceOptions
150 // Purpose : destructor
151 // Special Notes :
152 // Scope : public
153 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
154 // Creation Date : 4/01/02
155 //-----------------------------------------------------------------------------
157 {}
158 
159 //-----------------------------------------------------------------------------
160 // Function : DeviceOptions::registerOptions
161 // Purpose :
162 // Special Notes :
163 // Scope : public
164 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
165 // Creation Date : 5/24/00
166 //-----------------------------------------------------------------------------
167 bool DeviceOptions::registerOptions(const Util::OptionBlock & OB)
168 {
169  Util::ParamList::const_iterator iter = OB.begin();
170  Util::ParamList::const_iterator end = OB.end();
171 
172  for ( ; iter != end; ++iter)
173  {
174  std::string tag(iter->uTag());
175 
176  if (tag == "DEFAD") defad = iter->getImmutableValue<double>();
177  else if (tag == "DEFAS") defas = iter->getImmutableValue<double>();
178  else if (tag == "DEFL") defl = iter->getImmutableValue<double>();
179  else if (tag == "DEFW") defw = iter->getImmutableValue<double>();
180  else if (tag == "ABSTOL") abstol = iter->getImmutableValue<double>();
181  else if (tag == "RELTOL") reltol = iter->getImmutableValue<double>();
182  else if (tag == "CHGTOL") chgtol = iter->getImmutableValue<double>();
183  else if (tag == "GMIN") gmin = iter->getImmutableValue<double>();
184  else if (tag == "GMINSCALAR") gmin_scalar = iter->getImmutableValue<double>();
185  else if (tag == "GMAX") gmax = iter->getImmutableValue<double>();
186  else if (tag == "TJRELTOL") testJac_relTol = iter->getImmutableValue<double>();
187  else if (tag == "TJABSTOL") testJac_absTol = iter->getImmutableValue<double>();
188  else if (tag == "TJSQRTETA") testJac_SqrtEta = iter->getImmutableValue<double>();
189  else if (tag == "SENSDP") deviceSens_dp = iter->getImmutableValue<double>();
190  else if (tag == "TNOM") tnom = iter->getImmutableValue<double>()+CONSTCtoK;
191  else if (tag == "TEMP")
192  {
193  temp = *iter;
194  if ( !iter->isTimeDependent() ) temp.setVal(iter->getImmutableValue<double>()+CONSTCtoK);
195  else { temp.setVal( iter->stringValue() ); temp.setTimeDependent( true ); }
196  }
197  else if (tag == "SCALESRC") scale_src = iter->getImmutableValue<double>();
198  else if (tag == "NUMJAC")
199  numericalJacobianFlag = static_cast<bool>(iter->getImmutableValue<int>());
200  else if (tag == "TESTJAC")
201  testJacobianFlag = static_cast<bool>(iter->getImmutableValue<int>());
202  else if (tag == "TESTJACSTARTSTEP")
203  testJacStartStep = iter->getImmutableValue<int>();
204  else if (tag == "TESTJACSTOPSTEP")
205  testJacStopStep = iter->getImmutableValue<int>();
206  else if (tag == "TESTJACWARN")
207  testJacWarn = static_cast<bool> (iter->getImmutableValue<int>());
208  else if (tag == "TESTJACDEVICENAME")
209  {
210  testJacDeviceName = iter->stringValue();
211  testJacDeviceNameGiven = true;
212  }
213  else if (tag == "VOLTLIM")
214  voltageLimiterFlag = static_cast<bool>(iter->getImmutableValue<int>());
215  else if (tag == "LAMBERTW") lambertWFlag = static_cast<int>(iter->getImmutableValue<int>());
216  else if (tag == "ICFAC" ) icMultiplier = iter->getImmutableValue<double>();
217  else if (tag == "MAXTIMESTEP" ) defaultMaxTimeStep = iter->getImmutableValue<double>();
218 
219  else if (tag == "VDSSCALEMIN" ) vdsScaleMin = iter->getImmutableValue<double>();
220  else if (tag == "VGSTCONST" ) vgstConst = iter->getImmutableValue<double>();
221  else if (tag == "NUMGAINSCALEBLOCKS" )
222  numGainScaleBlocks = static_cast<int>(iter->getImmutableValue<int>());
223  else if (tag == "STAGGERGAINSCALE")
224  staggerGainScale = static_cast<bool>(iter->getImmutableValue<int>());
225  else if (tag == "RANDOMIZEVGSTCONST")
226  randomizeVgstConst = static_cast<bool>(iter->getImmutableValue<int>());
227  else if (tag == "LENGTH0" ) length0 = iter->getImmutableValue<double>();
228  else if (tag == "WIDTH0" ) width0 = iter->getImmutableValue<double>();
229  else if (tag == "TOX0" ) tox0 = iter->getImmutableValue<double>();
230  else if (tag == "MINRES" ) minRes = iter->getImmutableValue<double>();
231  else if (tag == "MINCAP" ) minCap = iter->getImmutableValue<double>();
232  else if (tag == "NEWMEYER" )
233  newMeyerFlag = iter->getImmutableValue<bool>();
234  else if (tag == "SENSDEBUGLEVEL")
235  {
236  setSensitivityDebugLevel(iter->getImmutableValue<int>());
237  }
238  else if (tag == "DEBUGLEVEL")
239  {
240  setDeviceDebugLevel(iter->getImmutableValue<int>());
241  }
242  else if (tag == "VERBOSELEVEL")
243  {
244  verboseLevel = (iter->getImmutableValue<int>());
245  }
246  else if (tag == "DEBUGMINTIMESTEP")
247  {
248  debugMinTimestep = (iter->getImmutableValue<int>());
249  }
250  else if (tag == "DEBUGMAXTIMESTEP")
251  {
252  debugMaxTimestep = (iter->getImmutableValue<int>());
253  }
254  else if (tag == "DEBUGMINTIME")
255  {
256  debugMinTime = (iter->getImmutableValue<double>());
257  }
258  else if (tag == "DEBUGMAXTIME")
259  {
260  debugMaxTime = (iter->getImmutableValue<double>());
261  }
262  else if (tag == "NEWEXCESSPHASE")
263  {
264  newExcessPhase = static_cast<bool> (iter->getImmutableValue<int>());
265  }
266  else if (tag == "EXCESSPHASESCALAR1")
267  {
268  excessPhaseScalar1 = (iter->getImmutableValue<double>());
269  }
270  else if (tag == "EXCESSPHASESCALAR2")
271  {
272  excessPhaseScalar2 = (iter->getImmutableValue<double>());
273  }
274  else if (tag == "ZERORESISTANCETOL")
275  {
276  zeroResistanceTol = (iter->getImmutableValue<double>());
277  }
278  else if (tag == "CHECKFORZERORESISTANCE")
279  {
280  checkForZeroResistance = (iter->getImmutableValue<bool>());
281  }
282  else if (tag == "RANDOMSEED" )
283  {
284  randomSeed = (iter->getImmutableValue<long>());
285  }
286  else if (tag == "TRYTOCOMPACT")
287  {
288  tryToCompact = static_cast<bool> (iter->getImmutableValue<int>());
289  }
290  else if (tag == "CALCULATEALLLEADCURRENTS")
291  {
292  calculateAllLeadCurrents = (iter->getImmutableValue<bool>());
293  }
294  else
295  {
296  Report::UserError0() << tag << " is not a recognized device package option.";
297  }
298  }
299 
300  gmin_orig = gmin;
301  gmin_init = gmin*gmin_scalar; // by default, 10 orders of magnitude larger.
302 
303  if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS))
304  dout() << *this << std::endl;
305 
306 // applyCmdLineOptions (commandLine);
307 
308  return true;
309 }
310 
311 //-----------------------------------------------------------------------------
312 // Function : DeviceOptions::setupDefaultOptions
313 // Purpose :
314 // Special Notes :
315 // Scope : public
316 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
317 // Creation Date : 7/13/00
318 //-----------------------------------------------------------------------------
319 bool
321  const IO::CmdParse & command_line)
322 {
323  defad = 0.0e+0; // MOS drain diffusion area.
324  defas = 0.0e+0; // MOS source diffusion area.
325  defl = 1.0e-4; // MOS channel length.
326  defw = 1.0e-4; // MOS channel width.
327  abstol= 1.0e-12; // absolute current error tol.
328  reltol = 1.0e-4; // relative current error tol.
329  chgtol= 1.0e-12; // absolute charge error tol.
330  gmin = 1.0e-12; // minimum allowed conductance.
331  gmin_orig = 1.0e-12; // minimum allowed conductance, reference
332  gmin_init = 1.0e-02; // minimum allowed conductance, initial
333  gmin_scalar = 1.0e10;
334  gmax = 1.0e20; // maximum allowed conductance.
335 
336  testJac_relTol = 0.01; // reltol for num. jacobian diagnostic
337  testJac_absTol = 1.0e-8; // abstol for num. jacobian diagnostic.
338  testJac_SqrtEta = 1.0e-8; // dx = numJacSqrtEta * (1.0 + fabs(soln[i]));
339  deviceSens_dp = 1.0e-8; // similar to eta, but for numerical device sensitivities
340 
341  tnom = CONSTREFTEMP; // nominal temp. for device params.
342  temp = Util::Param("TEMP",CONSTREFTEMP); // operating temp. of ckt.
343 
344  scale_src = 0;
345 
346  numericalJacobianFlag = false;
347  testJacobianFlag = false;
348  testJacStartStep = 0;
349  testJacStopStep = Util::MachineDependentParams::IntMax();
350  testJacWarn = false;
351  voltageLimiterFlag = true;
352  lambertWFlag = 0;
353 
354  newMeyerFlag = false;
355 
356  icMultiplier = 10000.0;
357 
358  defaultMaxTimeStep = 1.0e99;
359 
360  setSensitivityDebugLevel(0);
361  setDeviceDebugLevel(1);
363  debugMaxTimestep=Util::MachineDependentParams::IntMax();
364  debugMinTime=0;
365  debugMaxTime=Util::MachineDependentParams::DoubleMax();
366  verboseLevel = 0;
367 
368  newExcessPhase = defaultNewExcessPhase; // true if MPDE, false otherwise.
369  excessPhaseScalar1 = 1.0;
370  excessPhaseScalar2 = 1.0;
371 
372  if( command_line.getArgumentValue( "-dva" ) == "off" )
373  {
374  lout() << "Warning: -dva is no longer a recognized option.\n" << std::endl;
375  }
376 
377  if( command_line.getArgumentValue( "-dma" ) == "off" )
378  {
379  lout() << "Warning: -dma is no longer a recognized option.\n" << std::endl;
380  }
381 
382  return true;
383 
384 }
385 
386 //-----------------------------------------------------------------------------
387 // Function : DeviceOptions::applyCmdLineOptions
388 // Purpose :
389 // Special Notes :
390 // Scope : public
391 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
392 // Creation Date : 5/24/05
393 //-----------------------------------------------------------------------------
394 bool
396  const IO::CmdParse & command_line)
397 {
398  if (DEBUG_DEVICE) {
399  IO::setSensitivityDebugLevel(command_line, 0);
400  IO::setDeviceDebugLevel(command_line, 1);
401  }
402 
403  if (command_line.argExists("-jacobian_test"))
404  {
405  testJacobianFlag = true;
406  }
407 
408  return true;
409 }
410 
411 //-----------------------------------------------------------------------------
412 // Function : DeviceOptions::operator<<
413 // Purpose : "<<" operator
414 // Special Notes :
415 // Scope : public
416 // Creator : Eric R. Keiter, SNL, Parallel Computational Sciences
417 // Creation Date : 5/23/05
418 //-----------------------------------------------------------------------------
419 std::ostream & operator<<(std::ostream & os, const DeviceOptions & devOp)
420 {
421  os << "\n\n-----------------------------------------" << std::endl
422  << "\tDevice Options:\n"
423  << "\t\tdefad = " << devOp.defad << "\n"
424  << "\t\tdefas = " << devOp.defas << "\n"
425  << "\t\tdefl = " << devOp.defl << "\n"
426  << "\t\tdefw = " << devOp.defw << "\n"
427  << "\t\tabstol = " << devOp.abstol << "\n"
428  << "\t\treltol = " << devOp.reltol << "\n"
429  << "\t\tchgtol = " << devOp.chgtol << "\n"
430  << "\t\tgmin = " << devOp.gmin << "\n"
431  << "\t\tgmin_orig = " << devOp.gmin_orig << "\n"
432  << "\t\tgmin_init = " << devOp.gmin_init << "\n"
433  << "\t\tgmin_scalar = " << devOp.gmin_scalar << "\n"
434  << "\t\tgmax = " << devOp.gmax << "\n"
435  << "\t\ttnom = " << devOp.tnom << "\n"
436  << "\t\tscale_src = " << devOp.scale_src << "\n"
437  << "\t\tnumericalJacobianFlag = " << devOp.numericalJacobianFlag << "\n"
438  << "\t\ttestJacobianFlag = " << devOp.testJacobianFlag << "\n"
439  << "\t\ttestJacStartStep = " << devOp.testJacStartStep << "\n"
440  << "\t\ttestJacStopStep = " << devOp.testJacStopStep << "\n"
441  << "\t\ttestJacWarn = " << devOp.testJacWarn << "\n"
442  << "\t\ttestJacDeviceName = " << devOp.testJacDeviceName << "\n"
443 
444  << "\t\ttestJac_relTol = " << devOp.testJac_relTol << "\n"
445  << "\t\ttestJac_absTol = " << devOp.testJac_absTol << "\n"
446  << "\t\ttestJac_SqrtEta = " << devOp.testJac_SqrtEta << "\n"
447  << "\t\tdeviceSens_dp = " << devOp.deviceSens_dp << "\n"
448 
449  << "\t\tvoltageLimiterFlag = " << devOp.voltageLimiterFlag << "\n"
450  << "\t\tlambertWFlag = " << devOp.lambertWFlag << "\n"
451  << "\t\ticMultiplier = " << devOp.icMultiplier << "\n"
452  << "\t\tdefaultMaxTimeStep = " << devOp.defaultMaxTimeStep << "\n"
453  << "\t\tvdsScaleMin = " << devOp.vdsScaleMin << "\n"
454  << "\t\tvgstConst = " << devOp.vgstConst << "\n"
455  << "\t\tnumGainScaleBlocks = " << devOp.numGainScaleBlocks << "\n"
456  << "\t\tstaggerGainScale = " << devOp.staggerGainScale << "\n"
457  << "\t\trandomizeVgstConst = " << devOp.randomizeVgstConst << "\n"
458  << "\t\tlength0 = " << devOp.length0 << "\n"
459  << "\t\twidth0 = " << devOp.width0 << "\n"
460  << "\t\ttox0 = " << devOp.tox0 << "\n"
461  << "\t\tminres = " << devOp.minRes << "\n"
462  << "\t\tmincap = " << devOp.minCap << "\n"
463  << "\t\tdebugMinTimestep = " << devOp.debugMinTimestep << "\n"
464  << "\t\tdebugMaxTimestep = " << devOp.debugMaxTimestep << "\n"
465  << "\t\tdebugMinTime = " << devOp.debugMinTime << "\n"
466  << "\t\tdebugMaxTime = " << devOp.debugMaxTime << "\n"
467  << "\t\tverboseLevel = " << devOp.verboseLevel << "\n"
468  << "\t\tnewExcessPhase = " << devOp.newExcessPhase << "\n"
469  << "\t\tdefaultNewExcessPhase = " << devOp.defaultNewExcessPhase << "\n"
470  << "\t\texcessPhaseScalar1 = " << devOp.excessPhaseScalar1 << "\n"
471  << "\t\texcessPhaseScalar2 = " << devOp.excessPhaseScalar2 << "\n"
472  << "\t\tnewMeyerFlag = " << devOp.newMeyerFlag << "\n"
473  << Xyce::section_divider
474  << std::endl;
475 
476  return os;
477 }
478 
479 } // namespace Device
480 } // namespace Xyce
bool setupDefaultOptions(const IO::CmdParse &command_line)
#define CONSTCtoK
Definition: N_DEV_Const.h:52
#define CONSTREFTEMP
Definition: N_DEV_Const.h:56
Pure virtual class to augment a linear system.
bool applyCmdLineOptions(const IO::CmdParse &command_line)
bool registerOptions(const Util::OptionBlock &OB)
std::ostream & operator<<(std::ostream &os, const Configuration &configuration)
Definition: N_DEV_Dump.C:134