Xyce  6.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
N_NLS_NOX_ParameterSet.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-2014 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_NLS_NOX_ParameterSet.C,v $
27 //
28 // Purpose : Interface to Xyce vectors for NOX.
29 //
30 // Special Notes :
31 //
32 // Creator : Tammy Kolda, NLS, 8950
33 //
34 // Creation Date : 01/31/02
35 //
36 // Revision Information:
37 // ---------------------
38 //
39 // Revision Number: $Revision: 1.100 $
40 //
41 // Revision Date : $Date: 2014/02/24 23:49:25 $
42 //
43 // Current Owner : $Author: tvrusso $
44 //-------------------------------------------------------------------------
45 
46 #include <Xyce_config.h>
47 
48 
49 
50 // ---------- Standard Includes ----------
51 
52 #include <N_UTL_Misc.h>
53 
54 #include<list>
55 
56 // ---------- Xyce Includes ----------
57 
58 #ifndef HAVE_CONFIG_H
59 #define HAVE_CONFIG_H
60 #endif
61 
62 #include "N_NLS_NOX_Interface.h"
63 #include "N_NLS_NOX_XyceTests.h"
64 #include "N_NLS_NOX_FastTests.h"
70 #include "N_ERH_ErrorMgr.h"
71 #include "N_UTL_Param.h"
72 #include "N_PDS_fwd.h"
73 #include "N_UTL_OptionBlock.h"
74 #include "LOCA.H"
75 #include "N_NLS_ReturnCodes.h"
76 #include "N_LOA_Loader.h"
77 
78 // The following are needed to build AugmentLinSys strategies
85 #include "N_LAS_Builder.h"
86 #include "N_LAS_System.h"
87 #include "N_LAS_QueryUtil.h"
88 #include "Epetra_MapColoring.h"
89 
90 using namespace N_NLS_NOX;
91 
92 //-----------------------------------------------------------------------------
93 // Function : ParameterSet::ParameterSet
94 // Purpose : constructor
95 // Special Notes :
96 // Scope : public
97 // Creator :
98 // Creation Date :
99 //-----------------------------------------------------------------------------
101  allParams_(Teuchos::rcp(new Teuchos::ParameterList)),
102  noxParams_(allParams_->sublist("NOX")),
103  locaParams_(allParams_->sublist("LOCA")),
104  debugParams_(allParams_->sublist("DEBUG")),
105  comboPtr_(Teuchos::rcp(new NOX::StatusTest::Combo(NOX::StatusTest::Combo::OR))),
106  isParamsSet_(false),
107  isStatusTestsSet_(false),
108  mode_(mode),
109  noxSolver(0),
110  voltageListType_(VLT_None),
111  gstepping_minimum_conductance_(0.0),
112  savedLocaOptions_(false),
113  debugLevel_(0),
114  debugMinTimeStep_(0),
115  debugMaxTimeStep_(N_UTL_MachineDependentParams::IntMax()),
116  debugMinTime_(0.0),
117  debugMaxTime_(N_UTL_MachineDependentParams::DoubleMax()),
118  screenOutputFlag_(false),
119  voltageScaleFactor_(1.0)
120 {
121  // Add the main status test to the list of tests to delete in dtor
122  tests_.push_back(comboPtr_);
123 
124  // Default printing options
125 #ifdef Xyce_VERBOSE_NOX
126  noxParams_.sublist("Printing")
127  .set("Output Information",
128  NOX::Utils::Error +
129  NOX::Utils::Warning +
130  NOX::Utils::OuterIteration +
131  NOX::Utils::OuterIterationStatusTest +
132  NOX::Utils::InnerIteration +
133  NOX::Utils::Details +
134  NOX::Utils::StepperIteration +
135  NOX::Utils::StepperDetails +
136  NOX::Utils::Parameters
137  );
138 
139 #else
140 #ifdef Xyce_VERBOSE_NONLINEAR
141  noxParams_.sublist("Printing")
142  .set("Output Information",
143  NOX::Utils::Error+
144  NOX::Utils::Warning +
145  NOX::Utils::OuterIteration +
146  NOX::Utils::StepperIteration
147  );
148 #else
149  noxParams_.sublist("Printing")
150  .set("Output Information", NOX::Utils::Error);
151 #endif
152 #endif
153 
154  // Defaults that are mode dependent
155  switch (mode_)
156  {
157  case TRANSIENT:
158  // These values correspond to N_NLS_DampedNewton.C; see the constructor
159  statusTestParams_.set("ABSTOL", 1.0e-6);
160  statusTestParams_.set("RELTOL", 1.0e-2);
161  statusTestParams_.set("DELTAXTOL", 0.33);
162  statusTestParams_.set("RHSTOL", 1.0e-2);
163  statusTestParams_.set("MAXSTEP", 20);
164  noxParams_.set("Nonlinear Solver", "Line Search Based");
165  noxParams_.sublist("Line Search").set("Method", "Full Step");
166  //noxParams_.sublist("Line Search").set("Method", "Polynomial");
167  //noxParams_.sublist("Line Search").sublist("Polynomial")
168  // .set("Max Iters", 2);
169  //noxParams_.sublist("Line Search").sublist("Polynomial")
170  // .set("Interpolation Type", "Quadratic");
171  //noxParams_.sublist("Direction").sublist("Newton")
172  //.sublist("Linear Solver").set("Tolerance", 1.0e-9);
173  break;
174  case HB_MODE:
175  // These values correspond to N_NLS_DampedNewton.C; see the constructor
176  statusTestParams_.set("ABSTOL", 1.0e-9);
177  statusTestParams_.set("RELTOL", 1.0e-3);
178  statusTestParams_.set("DELTAXTOL", 1.0);
179  statusTestParams_.set("RHSTOL", 1.0e-4);
180  statusTestParams_.set("MAXSTEP", 200);
181  noxParams_.set("Nonlinear Solver", "Line Search Based");
182  noxParams_.sublist("Line Search").set("Method", "Full Step");
183  //noxParams_.sublist("Line Search").set("Method", "Polynomial");
184  //noxParams_.sublist("Line Search").sublist("Polynomial")
185  // .set("Max Iters", 2);
186  //noxParams_.sublist("Line Search").sublist("Polynomial")
187  // .set("Interpolation Type", "Quadratic");
188  //noxParams_.sublist("Direction").sublist("Newton")
189  //.sublist("Linear Solver").set("Tolerance", 1.0e-9);
190  break;
191  default:
192  statusTestParams_.set("ABSTOL", 1.0e-12);
193  statusTestParams_.set("RELTOL", 1.0e-3);
194  statusTestParams_.set("DELTAXTOL", 1.0);
195  statusTestParams_.set("RHSTOL", 1.0e-6);
196  statusTestParams_.set("MAXSTEP", 200);
197  noxParams_.set("Nonlinear Solver", "Line Search Based");
198  noxParams_.sublist("Line Search").set("Method", "Full Step");
199  noxParams_.sublist("Direction").sublist("Newton")
200  .sublist("Linear Solver").set("Tolerance", 1.0e-12);
201  break;
202  }
203 
204  // Parameters that should always be set
205  noxParams_.sublist("Line Search").sublist("Polynomial")
206  .set("Recovery Step Type", "Last Computed Step");
207 
208 
209  // Set default loca options in case this is a loca run.
210  Teuchos::ParameterList& stepperList = locaParams_.sublist("Stepper");
211  Teuchos::ParameterList& predictorList = locaParams_.sublist("Predictor");
212  Teuchos::ParameterList& stepSizeList = locaParams_.sublist("Step Size");
213 
214  stepperList.set("Continuation Method", "Natural");
215  stepperList.set("Skip df/dp", true);
216  predictorList.set("Method", "Tangent");
217 }
218 
219 //-----------------------------------------------------------------------------
220 // Function : ParameterSet::~ParameterSet
221 // Purpose :
222 // Special Notes :
223 // Scope : public
224 // Creator :
225 // Creation Date :
226 //-----------------------------------------------------------------------------
228 {
229 }
230 
231 //-----------------------------------------------------------------------------
232 // Function : ParameterSet::setOptions
233 // Purpose :
234 // Special Notes :
235 // Scope : public
236 // Creator :
237 // Creation Date :
238 //-----------------------------------------------------------------------------
239 bool ParameterSet::setOptions(const N_UTL_OptionBlock& OB)
240 {
241  // Parse the option block
242  bool parseok = parseOptionBlock_(OB);
243  if (!parseok)
244  {
245  return false;
246  }
247 
248  isParamsSet_ = true;
249  return true;
250 }
251 
252 //-----------------------------------------------------------------------------
253 // Function : ParameterSet::setOutputOptions
254 // Purpose : Set output for parallel runs
255 // Special Notes :
256 // Scope : public
257 // Creator :
258 // Creation Date :
259 //-----------------------------------------------------------------------------
260 bool ParameterSet::setOutputOptions(int myPID, int outputProcess)
261 {
262  noxParams_.sublist("Printing").set("MyPID", myPID);
263  noxParams_.sublist("Printing").set("Output Processor",
264  outputProcess);
265  locaParams_.sublist("Utilities").set("MyPID", myPID);
266  locaParams_.sublist("Utilities").set("Output Processor",
267  outputProcess);
268  return true;
269 }
270 
271 //-----------------------------------------------------------------------------
272 // Function : ParameterSet::createStatusTests
273 // Purpose :
274 // Special Notes :
275 // Scope : public
276 // Creator :
277 // Creation Date :
278 //-----------------------------------------------------------------------------
279 bool ParameterSet::createStatusTests(N_LAS_Vector** currSolVectorPtrPtr,
280  N_LOA_Loader& loader, std::vector<char> & varTypeVec
281 #ifdef Xyce_NLS_MASKED_WRMS_NORMS
282  , bool nonTrivialDeviceMaskFlag, N_LAS_Vector * maskVectorPtr)
283 #else
284  )
285 #endif
286 
287 {
288  /*
289  // Test 1 - Make sure the residual isn't too small, hardwired tolerances
290 
291  // Test 1a - Max Norm F is less than machine precision
292  NOX::StatusTest::NormF* test1a =
293  new NOX::StatusTest::NormF(N_UTL_MachineDependentParams::MachineEpsilon(),
294  NOX::Abstract::Vector::MaxNorm,
295  NOX::StatusTest::NormF::Unscaled);
296  tests_.push_back(test1a);
297 
298  // Test 1b - Max Norm F is less than requested tolerance
299  NOX::StatusTest::NormF* test1b =
300  new NOX::StatusTest::NormF(statusTestParams_.get("RHSTOL", 1.0e-6),
301  NOX::Abstract::Vector::MaxNorm,
302  NOX::StatusTest::NormF::Unscaled);
303  tests_.push_back(test1b);
304 
305  NOX::StatusTest::Combo* test1 =
306  new NOX::StatusTest::Combo(NOX::StatusTest::Combo::AND, *test1a, *test1b);
307  tests_.push_back(test1);
308  comboPtr_->addStatusTest(*test1);
309 
310 
311  // Test 2 - Normal convergence based on rhs residual (2a) and
312  // update norm (2b).
313 
314  // Test 2a - Max Residual
315  NOX::StatusTest::NormF* test2a =
316  new NOX::StatusTest::NormF(statusTestParams_.get("RHSTOL", 1.0e-6),
317  NOX::Abstract::Vector::MaxNorm,
318  NOX::StatusTest::NormF::Unscaled);
319  tests_.push_back(test2a);
320 
321  // Test 2b - weighted update
322  bool isTransient = false;
323  if (mode_ == TRANSIENT)
324  isTransient = true;
325  */
326  /*
327  N_NLS_NOX::WeightedUpdateTest* test2b =
328  new N_NLS_NOX::WeightedUpdateTest(currSolVectorPtrPtr,
329  statusTestParams_.get("ABSTOL", 1.0e-12),
330  statusTestParams_.get("RELTOL", 1.0e-3),
331  statusTestParams_.get("DELTAXTOL", 1.0),
332  isTransient);
333  tests_.push_back(test2b);
334  */
335  /*
336  //RPP Hack for test2b to get Homotopy to work
337  NOX::StatusTest::NormF* test2b =
338  new NOX::StatusTest::NormF(statusTestParams_.get("RHSTOL", 1.0e-6),
339  NOX::Abstract::Vector::MaxNorm,
340  NOX::StatusTest::NormF::Unscaled);
341  tests_.push_back(test2b);
342 
343 
344  NOX::StatusTest::Combo* test2 =
345  new NOX::StatusTest::Combo(NOX::StatusTest::Combo::AND, *test2a, *test2b);
346  tests_.push_back(test2);
347  comboPtr_->addStatusTest(*test2);
348 
349  // Test 3 - Near Convergence - Hit max iterations but residual
350  // and convergence rate indicate we may be near a converged solution.
351  // Therefore, let the time stepper decide whether or not the step is ok.
352  // Transient mode ONLY!
353  NOX::StatusTest::Generic* test3 = 0;
354  if (mode_ == TRANSIENT)
355  {
356  test3 = new N_NLS_NOX::NearConvergenceTest(statusTestParams_.get("MAXSTEP", 200), 1.0);
357  tests_.push_back(test3);
358  comboPtr_->addStatusTest(*test3);
359  }
360  */
361  /*
362  // Test 4 - Update is too small
363  N_NLS_NOX::UpdateTooSmallTest* test4 =
364  new N_NLS_NOX::UpdateTooSmallTest(*test2b, 1.0e-6);
365  tests_.push_back(test4);
366  comboPtr_->addStatusTest(*test4);
367  */
368  /*
369  // Test 5 - Max nonlinear iterations (if transient, this will be checked
370  // in the NearConvergence test (#3)
371  if (mode_ != TRANSIENT)
372  {
373  NOX::StatusTest::MaxIters* test5 =
374  new NOX::StatusTest::MaxIters(statusTestParams_.get("MAXSTEP", 200));
375  tests_.push_back(test5);
376  comboPtr_->addStatusTest(*test5);
377  }
378 
379  // Test 6 - update is too big
380  N_NLS_NOX::LargeUpdateTest* test6 =
381  new N_NLS_NOX::LargeUpdateTest(0.5*N_UTL_MachineDependentParams::DoubleMax());
382  tests_.push_back(test6);
383  comboPtr_->addStatusTest(*test6);
384 
385  // Test 7 - Stall in the convergence rate. Transient mode ONLY!
386  if (mode_ == TRANSIENT)
387  {
388  N_NLS_NOX::Stagnation* test7 = new N_NLS_NOX::Stagnation(50);
389  tests_.push_back(test7);
390  comboPtr_->addStatusTest(*test7);
391  }
392 
393  */
394 
395  // RPP: moving inside allTests so we don't have to dynamic cast
396  // NaN/Inf check on the residual vector 2-norm
397  //NOX::StatusTest::FiniteValue* fvTest = new NOX::StatusTest::FiniteValue;
398  //tests_.push_back(fvTest);
399  //comboPtr_->addStatusTest(*fvTest);
400 
401  // Tests All - replaces tests 1-7
402  bool isTransient = false;
403  if (mode_ == TRANSIENT)
404  {
405  isTransient = true;
406  }
407 
408  // make the correct testing object
409  Teuchos::RefCountPtr<N_NLS_NOX::XyceTests> allTests;
410  if( statusTestParams_.get("FASTTESTS",false) )
411  {
412  // make the FastTests object
413  allTests = Teuchos::rcp(new N_NLS_NOX::FastTests(isTransient,
414  statusTestParams_.get("RHSTOL", 1.0e-6),
415  N_UTL_MachineDependentParams::MachineEpsilon(),
416  currSolVectorPtrPtr,
417  statusTestParams_.get("ABSTOL", 1.0e-12),
418  statusTestParams_.get("RELTOL", 1.0e-3),
419  statusTestParams_.get("DELTAXTOL", 1.0),
420  statusTestParams_.get("MAXSTEP", 200),
421  0.9,
422  1.0,
423  0.5*N_UTL_MachineDependentParams::DoubleMax(),
424  1.0e-3,
425  5,
426  statusTestParams_.get("ENFORCEDEVICECONV", 1),
427  statusTestParams_.get("SMALLUPDATETOL", 1.0e-6),
428  &loader,
429  varTypeVec,
430  statusTestParams_.get("VOLTZEROTOL", 1.0e-6),
431  statusTestParams_.get("CURRZEROTOL", 1.0e-6)
432  #ifdef Xyce_NLS_MASKED_WRMS_NORMS
433  , nonTrivialDeviceMaskFlag, maskVectorPtr
434  #endif
435  ));
436  }
437  else
438  {
439  // here we make the default XyceTests object
440  allTests = Teuchos::rcp(new N_NLS_NOX::XyceTests(isTransient,
441  statusTestParams_.get("RHSTOL", 1.0e-6),
442  N_UTL_MachineDependentParams::MachineEpsilon(),
443  currSolVectorPtrPtr,
444  statusTestParams_.get("ABSTOL", 1.0e-12),
445  statusTestParams_.get("RELTOL", 1.0e-3),
446  statusTestParams_.get("DELTAXTOL", 1.0),
447  statusTestParams_.get("MAXSTEP", 200),
448  0.9,
449  1.0,
450  0.5*N_UTL_MachineDependentParams::DoubleMax(),
451  1.0e-3,
452  5,
453  statusTestParams_.get("ENFORCEDEVICECONV", 1),
454  statusTestParams_.get("SMALLUPDATETOL", 1.0e-6),
455  &loader
456  #ifdef Xyce_NLS_MASKED_WRMS_NORMS
457  , nonTrivialDeviceMaskFlag, maskVectorPtr
458  #endif
459  ));
460  }
461  tests_.push_back(allTests);
462  comboPtr_->addStatusTest(allTests);
463  isStatusTestsSet_ = true;
464  return true;
465 }
466 
467 //-----------------------------------------------------------------------------
468 // Function : ParameterSet::getStatusTests
469 // Purpose :
470 // Special Notes :
471 // Scope : public
472 // Creator :
473 // Creation Date :
474 //-----------------------------------------------------------------------------
475 Teuchos::RefCountPtr<NOX::StatusTest::Generic> ParameterSet::getStatusTests()
476 {
477  if (!isStatusTestsSet_)
478  {
479  const std::string message = "Error: N_NLS::NOX::ParameterSet::getStatusTests() - Status tests are not set!";
480  N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::DEV_FATAL, message);
481  }
482 
483  return comboPtr_;
484 }
485 
486 //-----------------------------------------------------------------------------
487 // Function : ParameterSet::getAllParams
488 // Purpose :
489 // Special Notes :
490 // Scope : public
491 // Creator :
492 // Creation Date :
493 //-----------------------------------------------------------------------------
494 Teuchos::RefCountPtr<Teuchos::ParameterList> ParameterSet::getAllParams()
495 {
496  return allParams_;
497 }
498 
499 //-----------------------------------------------------------------------------
500 // Function : ParameterSet::getNoxParams
501 // Purpose :
502 // Special Notes :
503 // Scope : public
504 // Creator :
505 // Creation Date :
506 //-----------------------------------------------------------------------------
507 Teuchos::RefCountPtr<Teuchos::ParameterList> ParameterSet::getNoxParams()
508 {
509  return Teuchos::rcp(&noxParams_, false);
510 }
511 
512 //-----------------------------------------------------------------------------
513 // Function : ParameterSet::getLocaParams
514 // Purpose :
515 // Special Notes :
516 // Scope : public
517 // Creator :
518 // Creation Date :
519 //-----------------------------------------------------------------------------
520 Teuchos::RefCountPtr<Teuchos::ParameterList> ParameterSet::getLocaParams()
521 {
522  return Teuchos::rcp(&locaParams_, false);
523 }
524 
525 //-----------------------------------------------------------------------------
526 // Function : ParameterSet::getDebugParams
527 // Purpose :
528 // Special Notes :
529 // Scope : public
530 // Creator :
531 // Creation Date :
532 //-----------------------------------------------------------------------------
533 Teuchos::RefCountPtr<Teuchos::ParameterList> ParameterSet::getDebugParams()
534 {
535  return Teuchos::rcp(&debugParams_, false);
536 }
537 
538 //-----------------------------------------------------------------------------
539 // Function : ParameterSet::unsupportedOption_
540 // Purpose :
541 // Special Notes :
542 // Scope : public
543 // Creator :
544 // Creation Date :
545 //-----------------------------------------------------------------------------
546 void ParameterSet::unsupportedOption_(const std::string& tag)
547 {
548  const std::string warning =
549  "Tag \"" + tag + "\" is unsupported by the NOX interface at this time.\n";
550  N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::USR_WARNING_0, warning);
551 }
552 
553 //-----------------------------------------------------------------------------
554 // Function : ParameterSet::parseOptionBlock_
555 // Purpose :
556 // Special Notes :
557 // Scope : public
558 // Creator :
559 // Creation Date :
560 //-----------------------------------------------------------------------------
561 bool ParameterSet::parseOptionBlock_(const N_UTL_OptionBlock& OB)
562 {
563  /*
564  RPP: Some parameters can't be immediately set in the nox
565  parameter list because they are in a sublist dependent upon
566  another parameter being set first. We have to store these
567  parameters until the entire option block is parsed and then set
568  them in the correct sublist. These parameters are listed below.
569  */
570  int maxSearchStep = 2;
571  int in_Forcing = 0;
572  double AZ_tol = 1.0e-12;
573  int recoveryStepType = 0;
574  double recoveryStep = 1.0;
575  int memory = 400;
576 
577 
578  // Loop over all parameters in the option block
579  for (std::list<N_UTL_Param>::const_iterator it_tpL = OB.getParams().begin();
580  it_tpL != OB.getParams().end(); ++ it_tpL)
581  {
582  const std::string tag = it_tpL->uTag();
583 
584 
585  // Parameters for nonlinear convergence tests
586  if (tag == "ABSTOL")
587  {
588  statusTestParams_.set("ABSTOL", it_tpL->getImmutableValue<double>());
589  }
590  else if (tag == "RELTOL")
591  {
592  statusTestParams_.set("RELTOL", it_tpL->getImmutableValue<double>());
593  }
594  else if (tag == "DELTAXTOL")
595  {
596  statusTestParams_.set("DELTAXTOL", it_tpL->getImmutableValue<double>());
597  }
598  else if (tag == "RHSTOL")
599  {
600  statusTestParams_.set("RHSTOL", it_tpL->getImmutableValue<double>());
601  }
602  else if (tag == "MAXSTEP")
603  {
604  statusTestParams_.set("MAXSTEP", it_tpL->getImmutableValue<int>());
605  }
606  else if (tag == "SMALLUPDATETOL")
607  {
608  statusTestParams_.set("SMALLUPDATETOL", it_tpL->getImmutableValue<double>());
609  }
610 
611  // Check devices for convergence (by calls to cktloader)
612  else if (tag == "ENFORCEDEVICECONV")
613  {
614  statusTestParams_.set("ENFORCEDEVICECONV", it_tpL->getImmutableValue<int>());
615  }
616  else if (tag == "FASTTESTS")
617  {
618  statusTestParams_.set("FASTTESTS", it_tpL->getImmutableValue<bool>());
619  }
620  else if (tag == "VOLTZEROTOL")
621  {
622  statusTestParams_.set("VOLTZEROTOL", it_tpL->getImmutableValue<double>());
623  }
624  else if (tag == "ABSZEROTOL")
625  {
626  statusTestParams_.set("ABSZEROTOL", it_tpL->getImmutableValue<double>());
627  }
628 
629  // Unsupported options
630  else if (tag == "LINOPT")
631  {
632  unsupportedOption_(tag);
633  }
634  else if (tag == "CONSTRAINTBT")
635  {
636  unsupportedOption_(tag);
637  }
638  else if (tag == "CONSTRAINTMAX")
639  {
640  unsupportedOption_(tag);
641  }
642  else if (tag == "CONSTRAINTMIN")
643  {
644  unsupportedOption_(tag);
645  }
646  else if (tag == "CONSTRAINTCHANGE")
647  {
648  unsupportedOption_(tag);
649  }
650  else if (tag == "NORMLVL")
651  {
652  if (it_tpL->getImmutableValue<int>() != 2)
653  unsupportedOption_(tag);
654  }
655  else if (tag == "DEBUGLEVEL")
656  {
657  debugLevel_ = it_tpL->getImmutableValue<int>();
658  }
659  else if (tag == "SCREENOUTPUT")
660  {
661  screenOutputFlag_ = it_tpL->getImmutableValue<bool>();
662  }
663  else if (tag == "DEBUGMINTIMESTEP")
664  {
665  debugMinTimeStep_ = it_tpL->getImmutableValue<int>();
666  }
667  else if (tag == "DEBUGMAXTIMESTEP")
668  {
669  debugMaxTimeStep_ = it_tpL->getImmutableValue<int>();
670  }
671  else if (tag == "DEBUGMINTIME")
672  {
673  debugMinTime_ = it_tpL->getImmutableValue<double>();
674  }
675  else if (tag == "DEBUGMAXTIME")
676  {
677  debugMaxTime_ = it_tpL->getImmutableValue<double>();
678  }
679  else if (tag == "DLSDEBUG")
680  unsupportedOption_(tag);
681 
682  // Nonlinear Strategy
683  else if (tag == "NLSTRATEGY")
684  {
685  int val = it_tpL->getImmutableValue<int>();
686  if (val == 0) // Newton
687  {
688  noxParams_.set("Nonlinear Solver", "Line Search Based");
689  noxParams_.sublist("Direction").set("Method", "Newton");
690  }
691  else if (val == 1) // Steepest descent
692  {
693  noxParams_.set("Nonlinear Solver", "Line Search Based");
694  noxParams_.sublist("Direction")
695  .set("Method", "Steepest Descent");
696  }
697  else if (val == 2) // Trust Region
698  {
699  noxParams_.set("Nonlinear Solver", "Trust Region Based");
700  }
701  else if (val == 3) // Modified Newton
702  {
703  noxParams_.set("Nonlinear Solver", "Line Search Based");
704  noxParams_.sublist("Direction")
705  .set("Method", "Modified-Newton");
706  }
707  else if (val == 4) // BFGS
708  {
709  noxParams_.set("Nonlinear Solver", "Line Search Based");
710  noxParams_.sublist("Direction").set("Method", "Quasi-Newton");
711  }
712  else if (val == 5) // Broyden
713  {
714  noxParams_.set("Nonlinear Solver", "Line Search Based");
715  noxParams_.sublist("Direction").set("Method", "Broyden");
716  }
717  else if (val == 6) // Tensor
718  {
719  noxParams_.set("Nonlinear Solver", "Tensor Based");
720  noxParams_.sublist("Direction").set("Method", "Tensor");
721  noxParams_.sublist("Direction").sublist("Tensor")
722  .sublist("Linear Solver").set("Compute Step", "Newton");
723  noxParams_.sublist("Direction").sublist("Tensor")
724  .sublist("Linear Solver").set("Reorthogonalize", "Always");
725  noxParams_.sublist("Line Search").set("Method", "Tensor");
726  noxParams_.sublist("Line Search").sublist("Tensor")
727  .set("Submethod", "Full Step");
728  }
729  else if (val == 7) // Fast Newton Direction
730  {
731  // RPP: No longer supported
732  const std::string warning =
733  "NLStrategy = 7 is no longer supported.\n";
734  N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::USR_WARNING_0, warning);
735  }
736  else if (val == 8) // Newton/Steepest Descent Combo Direction
737  {
738  // RPP: No longer supported
739  const std::string warning =
740  "NLStrategy = 8 is no longer supported.\n";
741  N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::USR_WARNING_0, warning);
742  }
743  else
744  {
745  const std::string warning =
746  "NLStrategy is not found!\n";
747  N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::USR_WARNING_0, warning);
748  }
749  }
750 
751  // Line search method
752  else if (tag == "SEARCHMETHOD")
753  {
754  int val = it_tpL->getImmutableValue<int>();
755  if (val == 0)
756  {
757  noxParams_.sublist("Line Search").set("Method", "Full Step");
758  }
759  else if (val == 1)
760  {
761  noxParams_.sublist("Line Search").set("Method", "Backtrack");
762  }
763  else if (val == 2)
764  {
765  noxParams_.sublist("Line Search").set("Method", "Polynomial");
766  noxParams_.sublist("Line Search").sublist("Polynomial")
767  .set("Interpolation Type", "Quadratic");
768  }
769  else if (val == 3)
770  {
771  noxParams_.sublist("Line Search").set("Method", "Polynomial");
772  noxParams_.sublist("Line Search").sublist("Polynomial")
773  .set("Interpolation Type", "Cubic");
774  }
775  else if (val == 4)
776  {
777  noxParams_.sublist("Line Search")
778  .set("Method", "More'-Thuente");
779  }
780  else
781  {
782  std::ostringstream ost;
783  ost << "N_NLS_NOX::ParameterSet::parseOptionBlock_ - "
784  << "SEARCHMETHOD = " << val
785  << " not supported by Xyce at this time." << std::endl;
786  N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::USR_WARNING_0, ost.str());
787  }
788  }
789 
790  // Trust Region auxiliary parameters
791  else if (tag == "TRMINRADIUS")
792  {
793  noxParams_.sublist("Trust Region")
794  .set("Minimum Trust Region Radius", it_tpL->getImmutableValue<double>());
795  }
796  else if (tag == "TRMAXRADIUS")
797  {
798  noxParams_.sublist("Trust Region")
799  .set("Maximum Trust Region Radius", it_tpL->getImmutableValue<double>());
800  }
801  else if (tag == "TRMINIMPROVEMENTRATIO")
802  {
803  noxParams_.sublist("Trust Region")
804  .set("Minimum Improvement Ratio", it_tpL->getImmutableValue<double>());
805  }
806  else if (tag == "TRCONTRACTIONRATIO")
807  {
808  noxParams_.sublist("Trust Region")
809  .set("Contraction Trigger Ratio", it_tpL->getImmutableValue<double>());
810  }
811  else if (tag == "TRCONTRACTIONFACTOR")
812  {
813  noxParams_.sublist("Trust Region")
814  .set("Contraction Factor", it_tpL->getImmutableValue<double>());
815  }
816  else if (tag == "TREXPANSIONRATIO")
817  {
818  noxParams_.sublist("Trust Region")
819  .set("Expansion Trigger Ratio", it_tpL->getImmutableValue<double>());
820  }
821  else if (tag == "TREXPANSIONFACTOR")
822  {
823  noxParams_.sublist("Trust Region")
824  .set("Expansion Factor", it_tpL->getImmutableValue<double>());
825  }
826  else if (tag == "TRRECOVERYSTEP")
827  {
828  noxParams_.sublist("Trust Region")
829  .set("Recovery Step", it_tpL->getImmutableValue<double>());
830  }
831 
832  // RPP: Why this is here???
833  else if (tag == "NOX")
834  {
835  // do nothing (this option is handled in the manager)
836  }
837 
838  // LOCA Continuation control
839  // 0 = Nox solve (no continuation)
840  // 1 = Natural Parameter Continuation
841  // 2 = Mosfet Specific Dual Parameter Continuation
842  // 3 = gmin stepping.
843  // 33 = Artificial Parameter Continuation
844  else if (tag == "CONTINUATION")
845  {
846  if (it_tpL->isNumeric())
847  {
848  noxSolver = it_tpL->getImmutableValue<int>();
849  }
850  else
851  {
852  ExtendedString p(it_tpL->stringValue());
853  p.toUpper();
854  if (p.substr(0,4) == "STAN")
855  {
856  noxSolver = 0;
857  }
858  else if (p.substr(0,3) == "NAT")
859  {
860  noxSolver = 1;
861  }
862  else if (p.substr(0,3) == "MOS")
863  {
864  noxSolver = 2;
865  }
866  else if (p.substr(0,4) == "GMIN")
867  {
868  noxSolver = 3;
869  }
870  else if (p.substr(0,6) == "NEWMOS")
871  {
872  noxSolver = 4;
873  }
874  else if (p.substr(0,9) == "BSIM3INV1")
875  {
876  noxSolver = 5;
877  }
878  else if (p.substr(0,9) == "BSIM3INV2")
879  {
880  noxSolver = 6;
881  }
882  else if (p.substr(0,9) == "BLOCKGAIN")
883  {
884  noxSolver = 7;
885  }
886  else if (p.substr(0,4) == "TEST")
887  {
888  noxSolver = 8;
889  }
890  else if (p.substr(0,6) == "PSEUDO")
891  {
892  noxSolver = 9;
893  }
894  else if (p.substr(0,5) == "POWER")
895  {
896  noxSolver = 10;
897  }
898  else if (p.substr(0,3) == "ART")
899  {
900  noxSolver = 33;
901  }
902  else
903  {
904  std::string message = "Unknown specification in .options for 'continuation': ";
905  message += it_tpL->stringValue();
906  N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::DEV_FATAL, message);
907  }
908 
909  // Bail out if option 33 (artif. homotopy) is chosen but
910  // required support is not built in.
911 #ifndef Xyce_NOX_LOCA_ARTIFICIAL_HOMOTOPY_SUPPORT
912  if (noxSolver == 33)
913  {
914  Xyce::Report::UserFatal0() << "Nonlinear Solver (NOX::Interface) Artificial parameter continuation requires "
915  << "building xyce with the define: -DXyce_NOX_LOCA_ARTIFICIAL_HOMOTOPY_SUPPORT to "
916  << "allow LOCA to augment the diagonal of Jacobian! Either rebuild Xyce or do not "
917  << "run Xyce with \"continuation=33\"";
918  }
919 #endif
920  }
921  }
922 
923  // Parameters that can't be set in the list until all options
924  // have been parsed
925  else if (tag == "MAXSEARCHSTEP")
926  {
927  maxSearchStep = it_tpL->getImmutableValue<int>();
928  }
929  else if (tag == "IN_FORCING")
930  {
931  in_Forcing = it_tpL->getImmutableValue<int>();
932  }
933  else if (tag == "AZ_TOL")
934  {
935  AZ_tol = it_tpL->getImmutableValue<double>();
936  }
937  else if (tag == "RECOVERYSTEPTYPE")
938  {
939  recoveryStepType = it_tpL->getImmutableValue<int>();
940  }
941  else if (tag == "RECOVERYSTEP")
942  {
943  recoveryStep = it_tpL->getImmutableValue<double>();
944  }
945  else if (tag == "MEMORY")
946  {
947  memory = it_tpL->getImmutableValue<int>();
948  }
949 
950  // Parameters that can't be set in the list until all options
951  // have been parsed
952  else if (tag == "MAXSEARCHSTEP")
953  {
954  maxSearchStep = it_tpL->getImmutableValue<int>();
955  }
956  else if (tag == "IN_FORCING")
957  {
958  in_Forcing = it_tpL->getImmutableValue<int>();
959  }
960  else if (tag == "AZ_TOL")
961  {
962  AZ_tol = it_tpL->getImmutableValue<double>();
963  }
964  else if (tag == "RECOVERYSTEPTYPE")
965  {
966  recoveryStepType = it_tpL->getImmutableValue<int>();
967  }
968  else if (tag == "RECOVERYSTEP")
969  {
970  recoveryStep = it_tpL->getImmutableValue<double>();
971  }
972  else if (tag == "MEMORY")
973  {
974  memory = it_tpL->getImmutableValue<int>();
975  }
976 
977  // Warn user about unrecognized solver option
978  else
979  {
980  Xyce::Report::UserWarning() << tag << " is not a recognized nonlinear solver option.\n" << std::endl;
981  }
982 
983  } // end loop over all options in block
984 
985 
986  /*
987  Set parameters that are dependent upon other parameters
988 
989  RPP: Some parameters can't be immediately set in the nox
990  parameter list because they are in a sublist dependent upon
991  another parameter being set first. We have to store these
992  parameters until the entire option block is parsed and then set
993  them in the correct sublist.
994  */
995  std::string directionMethod =
996  noxParams_.sublist("Direction").get("Method", "Newton");
997 
998  std::string lineSearchMethod =
999  noxParams_.sublist("Line Search").get("Method", "Full Step");
1000 
1001  // MAXSEARCHSTEP
1002  noxParams_.sublist("Line Search").sublist(lineSearchMethod)
1003  .set("Max Iters", maxSearchStep);
1004 
1005  // In_FORCING
1006  if (in_Forcing == 0)
1007  {
1008  noxParams_.sublist("Direction").sublist(directionMethod)
1009  .set("Forcing Term Method", "Constant");
1010  }
1011  else if (in_Forcing == 1)
1012  {
1013  noxParams_.sublist("Direction").sublist(directionMethod)
1014  .set("Forcing Term Method", "Type 1");
1015  noxParams_.sublist("Direction").sublist("Newton")
1016  .set("Forcing Term Minimum Tolerance", AZ_tol);
1017  }
1018  else
1019  {
1020  noxParams_.sublist("Direction").sublist(directionMethod)
1021  .set("Forcing Term Method", "Type 2");
1022  noxParams_.sublist("Direction").sublist("Newton")
1023  .set("Forcing Term Minimum Tolerance", AZ_tol);
1024  }
1025 
1026  // RECOVERYSTEPTYPE
1027  if (recoveryStepType == 1)
1028  {
1029  // Recovery the NOX way
1030  noxParams_.sublist("Line Search").sublist(lineSearchMethod)
1031  .set("Recovery Step Type", "Constant");
1032  }
1033  else
1034  {
1035  // Recovery the Xyce way
1036  noxParams_.sublist("Line Search").sublist(lineSearchMethod)
1037  .set("Recovery Step Type", "Last Computed Step");
1038  }
1039 
1040  // RECOVERYSTEP
1041  noxParams_.sublist("Line Search").sublist(lineSearchMethod)
1042  .set("Recovery Step", recoveryStep);
1043 
1044  // MEMORY
1045  if ((directionMethod == "Quasi-Newton") ||
1046  (directionMethod == "Broyden"))
1047  noxParams_.sublist("Direction").sublist(directionMethod)
1048  .set("Memory", memory);
1049 
1050 
1051  return true;
1052 }
1053 
1054 //-----------------------------------------------------------------------------
1055 // Function : ParameterSet::setLocaOptions
1056 // Purpose :
1057 // Special Notes :
1058 // Scope : public
1059 // Creator :
1060 // Creation Date :
1061 //-----------------------------------------------------------------------------
1062 bool ParameterSet::setLocaOptions(const N_UTL_OptionBlock& OB, bool saveCopy)
1063 {
1064  Teuchos::ParameterList& stepperList = locaParams_.sublist("Stepper");
1065  Teuchos::ParameterList& predictorList = locaParams_.sublist("Predictor");
1066  Teuchos::ParameterList& stepSizeList = locaParams_.sublist("Step Size");
1067 
1068  bool stepperGiven=false;
1069  bool predictorGiven=false;
1070 
1071  if (saveCopy)
1072  {
1073  savedLocaOptions_ = true;
1074  savedLocaOB_ = OB; // save a copy to re-assert defaults later, if needed.
1075  }
1076 
1077  for (std::list<N_UTL_Param>::const_iterator it_tpL = OB.getParams().begin();
1078  it_tpL != OB.getParams().end(); ++ it_tpL)
1079  {
1080  const std::string tag = it_tpL->uTag();
1081  std::string baseTag=tag.substr(0,8);
1082  bool isVectorParam=false;
1083  if (baseTag == "CONPARAM" ||
1084  baseTag == "MINVALUE" ||
1085  baseTag == "MAXVALUE" ||
1086  baseTag == "INITIALV" ||
1087  baseTag == "INITIALS" ||
1088  baseTag == "MINSTEPS" ||
1089  (baseTag == "MAXSTEPS" && tag.substr(0,11)=="MAXSTEPSIZE")||
1090  baseTag == "AGGRESSI")
1091  {
1092  if (baseTag == "INITIALV")
1093  {
1094  baseTag = "INITIALVALUE";
1095  }
1096  else if (baseTag == "INITIALS")
1097  {
1098  baseTag = "INITIALSTEPSIZE";
1099  }
1100  else if (baseTag == "MINSTEPS")
1101  {
1102  baseTag = "MINSTEPSIZE";
1103  }
1104  else if (baseTag == "MAXSTEPS")
1105  {
1106  baseTag = "MAXSTEPSIZE";
1107  }
1108  else if (baseTag == "AGGRESSI")
1109  {
1110  baseTag = "AGGRESSIVENESS";
1111  }
1112 
1113  std::string num=tag.substr(baseTag.size(),tag.size()-baseTag.size());
1114  int index=ExtendedString(num).Ival();
1115  vectorParams[baseTag].push_back(*it_tpL);
1116  isVectorParam=true;
1117  }
1118  if (tag == "STEPPER")
1119  {
1120  stepperGiven=true;
1121  if (it_tpL->isNumeric())
1122  {
1123  int iType = it_tpL->getImmutableValue<int>();
1124  if (iType == 1)
1125  {
1126  stepperList.set("Continuation Method", "Arc Length");
1127  stepperList.set("Skip df/dp", false);
1128  }
1129  else
1130  {
1131  stepperList.set("Continuation Method", "Natural");
1132  stepperList.set("Skip df/dp", true);
1133  }
1134  }
1135  else
1136  {
1137  ExtendedString p(it_tpL->stringValue());
1138  p.toUpper();
1139  if (p.substr(0,3) == "ARC")
1140  {
1141  stepperList.set("Continuation Method", "Arc Length");
1142  stepperList.set("Skip df/dp", false);
1143  }
1144  else if (p.substr(0,3) == "NAT")
1145  {
1146  stepperList.set("Continuation Method", "Natural");
1147  stepperList.set("Skip df/dp", true);
1148  }
1149  else
1150  {
1151  std::string message = "Unknown specification in .options for 'stepper': ";
1152  message += it_tpL->stringValue();
1153  message += ". Legal choices are ARCLENGTH or NATURAL, which may be abbreviated to three characters.";
1154  N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::DEV_FATAL, message);
1155  }
1156  }
1157  }
1158  else if (tag == "PREDICTOR")
1159  {
1160  predictorGiven=true;
1161  if (it_tpL->isNumeric())
1162  {
1163  int iType = it_tpL->getImmutableValue<int>();
1164  if (iType == 1)
1165  {
1166  predictorList.set("Method", "Tangent");
1167  }
1168  else if (iType == 2)
1169  {
1170  predictorList.set("Method", "Secant");
1171  }
1172  else if (iType == 3)
1173  {
1174  predictorList.set("Method", "Random");
1175  }
1176  else
1177  {
1178  predictorList.set("Method", "Constant");
1179  }
1180  }
1181  else
1182  {
1183  ExtendedString p(it_tpL->stringValue());
1184  p.toUpper();
1185  if (p.substr(0,3) == "TAN")
1186  {
1187  predictorList.set("Method", "Tangent");
1188  }
1189  else if (p.substr(0,3) == "SEC")
1190  {
1191  predictorList.set("Method", "Secant");
1192  }
1193  else if (p.substr(0,3) == "RAN")
1194  {
1195  predictorList.set("Method", "Random");
1196  }
1197  else if (p.substr(0,3) == "CON")
1198  {
1199  predictorList.set("Method", "Constant");
1200  }
1201  else
1202  {
1203  std::string message = "Unknown specification in .options for 'predictor': ";
1204  message += it_tpL->stringValue();
1205  message += ". Legal choices are TANGENT, SECANT, RANDOM, CONSTANT, which may be abbreviated to three characters.";
1206  N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::DEV_FATAL, message);
1207  }
1208  }
1209  }
1210  // if we're the very first instance of one of these vector params,
1211  // then set our stepperList (this is the old behavior from the
1212  // "alternate" vector handling
1213  else if (tag == "CONPARAM1") // continuation parameter
1214  {
1215  stepperList.set("Continuation Parameter", it_tpL->stringValue());
1216  }
1217  else if (tag == "INITIALVALUE1")
1218  {
1219  stepperList.set("Initial Value", it_tpL->getImmutableValue<double>());
1220  }
1221  else if (tag == "MINVALUE1")
1222  {
1223  gstepping_min_value_ = it_tpL->getImmutableValue<double>();
1224  stepperList.set("Min Value", it_tpL->getImmutableValue<double>());
1225  }
1226  else if (tag == "RESIDUALCONDUCTANCE")
1227  {
1228  gstepping_minimum_conductance_ = it_tpL->getImmutableValue<double>();
1230  {
1231  std::string message = "You have specified a non-zero value for the GMIN Stepping residual conductance (RESIDUALCONDUCTANCE= ";
1232  message += it_tpL->stringValue();
1233  message += ").\nThis option should never be used unless absolutely necessary to obtain an initial condition for transient runs with ill-posed DC operating points. The operating point obtained by GMIN Stepping will not be a valid steady state condition for the circuit as defined in the netlist, but might possibly produce a reasonable initial condition for transient runs.\n";
1234  N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::USR_WARNING_0, message);
1235  }
1236  }
1237  else if (tag == "INITIALSTEPSIZE1")
1238  {
1239  stepSizeList.set("Initial Step Size", it_tpL->getImmutableValue<double>());
1240  }
1241  else if (tag == "MINSTEPSIZE1")
1242  {
1243  stepSizeList.set("Min Step Size", it_tpL->getImmutableValue<double>());
1244  }
1245  else if (tag == "MAXSTEPSIZE1")
1246  {
1247  stepSizeList.set("Max Step Size", it_tpL->getImmutableValue<double>());
1248  }
1249  else if (tag == "AGGRESSIVENESS1")
1250  {
1251  stepSizeList.set("Aggressiveness", it_tpL->getImmutableValue<double>());
1252  }
1253  else if (tag == "MAXVALUE1")
1254  {
1255  stepperList.set("Max Value", it_tpL->getImmutableValue<double>());
1256  }
1257  else if (tag == "BIFPARAM") // bifurcation parameter
1258  {
1259  stepperList.set("Bifurcation Parameter", it_tpL->stringValue());
1260  }
1261  else if (tag == "MAXSTEPS")
1262  {
1263  stepperList.set("Max Steps", it_tpL->getImmutableValue<int>());
1264  }
1265  else if (tag == "MAXNLITERS")
1266  {
1267  stepperList.set("Max Nonlinear Iterations", it_tpL->getImmutableValue<int>());
1268  }
1269  else if (tag == "STEPCONTROL")
1270  {
1271  if (it_tpL->isNumeric())
1272  {
1273  int iType = it_tpL->getImmutableValue<int>();
1274  if (iType == 1)
1275  stepSizeList.set("Method", "Adaptive");
1276  else
1277  stepSizeList.set("Method", "Constant");
1278  }
1279  else
1280  {
1281  ExtendedString p(it_tpL->stringValue());
1282  p.toUpper();
1283  if (p.substr(0,3) == "ADA")
1284  {
1285  stepSizeList.set("Method", "Adaptive");
1286  }
1287  else if (p.substr(0,3) == "CON")
1288  {
1289  stepSizeList.set("Method", "Constant");
1290  }
1291  else
1292  {
1293  std::string message = "Unknown specification in .options for 'stepcontrol': ";
1294  message += it_tpL->stringValue();
1295  message += ". Legal choices are ADAPTIVE or CONSTANT, which may be abbreviated to three characters.";
1296  N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::DEV_FATAL, message);
1297  }
1298  }
1299  }
1300  else if (tag == "POWERNODE") // continuation parameter
1301  {
1302  stepperList.set("Power Node", it_tpL->stringValue());
1303  }
1304  else if (tag == "VOLTAGELIST")
1305  {
1306  ExtendedString p(it_tpL->stringValue());
1307  p.toUpper();
1308  if (p.substr(0,3) == "DOF") // DOFS - degrees of freedom
1309  {
1311  }
1312  else if (p.substr(0,3) == "NOD") // NODES - voltage nodes
1313  {
1315  }
1316  else
1317  {
1318  std::string message = "Unknown specification in .options loca for 'voltagelist': ";
1319  message += it_tpL->stringValue();
1320  message += ". Legal choices are DOFS or NODES, which may be abbreviated to three characters.";
1321  N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::DEV_FATAL, message);
1322  }
1323  }
1324  else if(tag == "VOLTAGESCALEFACTOR")
1325  {
1326  voltageScaleFactor_ = it_tpL->getImmutableValue<double>();
1327  }
1328  // Start of the new parameter section
1329  else if (std::string(tag,0,10) == "PARAMLIST")
1330  {
1331  // don't know what to do yet.
1332  Xyce::dout() << "tag = " << tag << std::endl;
1333  }
1334  else
1335  {
1336  // if "isVectorParam" we've already handled this at the beginning
1337  // of the loop. Otherwise it's an unrecognized parameter.
1338  if (!isVectorParam)
1339  {
1340  std::string tmp =tag + " is not a recognized loca option.\n";
1341  N_ERH_ErrorMgr::report (N_ERH_ErrorMgr::USR_WARNING_0, tmp);
1342  }
1343  }
1344  }
1345 
1346  // Insure that the correct defaults are set. Sometimes the LOCA
1347  // defaults change in the LOCA library from release to release. However
1348  // Xyce's defaults should not necessarily change in that case.
1349  if (!stepperGiven)
1350  {
1351  stepperList.set("Continuation Method", "Natural");
1352  stepperList.set("Skip df/dp", true);
1353  }
1354 
1355  if (!predictorGiven)
1356  {
1357  predictorList.set("Method", "Tangent");
1358  }
1359 
1360  return true;
1361 }
1362 
1363 //-----------------------------------------------------------------------------
1364 // Function : ParameterSet::getVectorParam
1365 // Purpose : Obtain a parameter specified in the option line in vector syntax
1366 // Special Notes :
1367 // Scope : public
1368 // Creator : Dave Shirley, PSSI
1369 // Creation Date : 02/02/06
1370 //-----------------------------------------------------------------------------
1371 bool ParameterSet::getVectorParam (const std::string & tag, int index, double & value)
1372 {
1373  if (vectorParams.find(tag) != vectorParams.end() &&
1374  vectorParams[tag].size() > index)
1375  {
1376  value = vectorParams[tag][index].getImmutableValue<double>();
1377  return true;
1378  }
1379  else
1380  {
1381  return false;
1382  }
1383 }
1384 
1385 //-----------------------------------------------------------------------------
1386 // Function : ParameterSet::getVectorParam
1387 // Purpose : Obtain a parameter specified in the option line in vector syntax
1388 // Special Notes :
1389 // Scope : public
1390 // Creator : Dave Shirley, PSSI
1391 // Creation Date : 02/02/06
1392 //-----------------------------------------------------------------------------
1393 bool ParameterSet::getVectorParam (const std::string & tag, int index, std::string & value)
1394 {
1395  if (vectorParams.find(tag) != vectorParams.end() &&
1396  vectorParams[tag].size() > index)
1397  {
1398  value = vectorParams[tag][index].stringValue();
1399  return true;
1400  }
1401  else
1402  {
1403  return false;
1404  }
1405 }
1406 
1407 //-----------------------------------------------------------------------------
1408 // Function : ParameterSet::getVectorParamSize
1409 // Purpose :
1410 // Special Notes :
1411 // Scope : public
1412 // Creator :
1413 // Creation Date :
1414 //-----------------------------------------------------------------------------
1415 int ParameterSet::getVectorParamSize(const std::string& tag)
1416 {
1417  if (vectorParams.find(tag) != vectorParams.end())
1418  {
1419  return static_cast<int>(vectorParams[tag].size());
1420  }
1421  else
1422  {
1423  std::string msg = "N_NLS_NOX::ParameterSet::getVectorParam - ";
1424  msg += "the parameter \"";
1425  msg += tag;
1426  msg += "\" is required for parameter continuation!";
1427  N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::DEV_FATAL, msg);
1428  }
1429 
1430  return -1;
1431 }
1432 
1433 //-----------------------------------------------------------------------------
1434 // Function : ParameterSet::getStatusTestReturnCode
1435 // Purpose :
1436 // Special Notes :
1437 // Scope : public
1438 // Creator :
1439 // Creation Date :
1440 //-----------------------------------------------------------------------------
1442 {
1443  // Get the main Xyce Test
1444  Teuchos::RefCountPtr<N_NLS_NOX::XyceTests> testPtr =
1445  Teuchos::rcp_dynamic_cast<N_NLS_NOX::XyceTests>(tests_[1]);
1446  if (Teuchos::is_null(testPtr))
1447  {
1448  const std::string message = "N_NLS_NOX::getStatusTestReturnCode - Dynamic cast on Xyce Tests check failed.";
1449  N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::DEV_FATAL, message);
1450  }
1451 
1452  return testPtr->getXyceReturnCode();
1453 }
1454 
1455 //-----------------------------------------------------------------------------
1456 // Function : ParameterSet::setStatusTestReturnCode
1457 // Purpose :
1458 // Special Notes :
1459 // Scope : public
1460 // Creator :
1461 // Creation Date :
1462 //-----------------------------------------------------------------------------
1464  (const N_NLS_ReturnCodes & retCodesTmp)
1465 {
1466  // Get the main Xyce Test
1467  Teuchos::RefCountPtr<N_NLS_NOX::XyceTests> testPtr =
1468  Teuchos::rcp_dynamic_cast<N_NLS_NOX::XyceTests>(tests_[1]);
1469  if (Teuchos::is_null(testPtr))
1470  {
1471  const std::string message = "N_NLS_NOX::setStatusTestReturnCode - Dynamic cast on Xyce Tests check failed.";
1472  N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::DEV_FATAL, message);
1473  }
1474 
1475  return testPtr->setReturnCodes (retCodesTmp);
1476 }
1477 
1478 //-----------------------------------------------------------------------------
1479 // Function : ParameterSet::getMaxNormF
1480 // Purpose :
1481 // Special Notes :
1482 // Scope : public
1483 // Creator :
1484 // Creation Date :
1485 //-----------------------------------------------------------------------------
1487 {
1488  // Get the main Xyce Test
1489  Teuchos::RefCountPtr<N_NLS_NOX::XyceTests> testPtr =
1490  Teuchos::rcp_dynamic_cast<N_NLS_NOX::XyceTests>(tests_[1]);
1491  if (Teuchos::is_null(testPtr))
1492  {
1493  const std::string message = "N_NLS_NOX::getMaxNormF - Dynamic cast on Xyce Tests check failed.";
1494  N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::DEV_FATAL, message);
1495  }
1496 
1497  return testPtr->getMaxNormF();
1498 }
1499 
1500 //-----------------------------------------------------------------------------
1501 // Function : ParameterSet::getMaxNormFindex
1502 // Purpose :
1503 // Special Notes :
1504 // Scope : public
1505 // Creator :
1506 // Creation Date :
1507 //-----------------------------------------------------------------------------
1509 {
1510  // Get the main Xyce Test
1511  Teuchos::RefCountPtr<N_NLS_NOX::XyceTests> testPtr =
1512  Teuchos::rcp_dynamic_cast<N_NLS_NOX::XyceTests>(tests_[1]);
1513  if (Teuchos::is_null(testPtr))
1514  {
1515  const std::string message = "N_NLS_NOX::getMaxNormFindex - Dynamic cast on Xyce Tests check failed.";
1516  N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::DEV_FATAL, message);
1517  }
1518 
1519  return testPtr->getMaxNormFindex ();
1520 }
1521 
1522 //-----------------------------------------------------------------------------
1523 // Function : ParameterSet::getNoxSolverType
1524 // Purpose :
1525 // Special Notes :
1526 // Scope : public
1527 // Creator :
1528 // Creation Date :
1529 //-----------------------------------------------------------------------------
1531 {
1532  return noxSolver;
1533 }
1534 
1535 //-----------------------------------------------------------------------------
1536 // Function : ParameterSet::createAugmentLinearSystem
1537 // Purpose : creates an AugmentLinSys strategy object.
1538 // Special Notes :
1539 // Scope : public
1540 // Creator : Roger Pawlowski, SNL 1416
1541 // Creation Date : 03/08/06
1542 //-----------------------------------------------------------------------------
1543 Teuchos::RefCountPtr<N_NLS_NOX::AugmentLinSys>
1545 {
1546  Teuchos::RefCountPtr<N_NLS_NOX::AugmentLinSys> als;
1547 
1548  if (noxSolver == 9)
1549  {
1550  Teuchos::RefCountPtr<Epetra_MapColoring> color_map =
1551  Teuchos::rcp(ls->builder().createSolnColoring());
1552 
1553  if (voltageScaleFactor_ == 1.0)
1554  {
1555  als = Teuchos::rcp( new N_NLS_NOX::
1556  AugmentLinSysPseudoTransient(color_map,
1557  ls->getRHSVector()) );
1558  }
1559  else
1560  {
1561  als = Teuchos::rcp( new N_NLS_NOX::
1562  AugmentLinSysPseudoTransient(color_map,
1563  ls->getRHSVector(),
1564  true,
1566  }
1567 
1568  }
1569  else if(noxSolver == 1 || noxSolver == 3)
1570  {
1571  if (voltageListType_ == VLT_DOFS)
1572  {
1573  Teuchos::RefCountPtr<Epetra_MapColoring> color_map =
1574  Teuchos::rcp(ls->builder().createSolnColoring());
1575 
1576  als = Teuchos::rcp( new N_NLS_NOX::GStepping(color_map,
1577  ls->getRHSVector(),
1580  }
1581  else
1582  {
1583  als = Teuchos::rcp( new N_NLS_NOX::
1584  GStepping(ls->getQueryUtil()->vnodeGIDVec(),
1585  ls->getRHSVector(),
1588  }
1589  }
1590  else
1591  {
1592  std::string message = "N_NLS_NOX::createAugmentLinearSystem - The \'continuation\' ";
1593  message += "parameter in the .options nox list must be set to PSEUDO or NATURAL for ";
1594  message += "this function to be called!";
1595  N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::DEV_FATAL, message);
1596  }
1597 
1598  return als;
1599 }
1600 
1601 //-----------------------------------------------------------------------------
1602 // Function : ParameterSet::createAugmentLinearSystem
1603 // Purpose : creates an AugmentLinSys strategy object.
1604 // Special Notes :
1605 // Scope : public
1606 // Creator : Dave Shirley, PSSI
1607 // Creation Date : 05/08/06
1608 //-----------------------------------------------------------------------------
1609 Teuchos::RefCountPtr<N_NLS_NOX::AugmentLinSys>
1610 ParameterSet::createAugmentLinearSystem(N_LAS_System* ls, Xyce::NodeNamePairMap & op,
1611 #ifdef Xyce_PARALLEL_MPI
1612  Xyce::NodeNamePairMap & allNodes, N_PDS_Comm * pdsCommPtr
1613 #else
1614  Xyce::NodeNamePairMap & allNodes
1615 #endif
1616  ) const
1617 {
1618  Teuchos::RefCountPtr<N_NLS_NOX::AugmentLinSys> als;
1619 
1620 #ifdef Xyce_PARALLEL_MPI
1621  als = Teuchos::rcp( new N_NLS_NOX::AugmentLinSysOPStart(op, allNodes, pdsCommPtr) );
1622 #else
1623  als = Teuchos::rcp( new N_NLS_NOX::AugmentLinSysOPStart(op, allNodes) );
1624 #endif
1625 
1626  return als;
1627 }
1628 
1629 //-----------------------------------------------------------------------------
1630 // Function : ParameterSet::createAugmentLinearSystem
1631 // Purpose : creates an AugmentLinSys strategy object for .IC with
1632 // or without gmin stepping
1633 // Special Notes :
1634 // Scope : public
1635 // Creator : Eric Keiter, SNL
1636 // Creation Date : 03/08/07
1637 //-----------------------------------------------------------------------------
1638 Teuchos::RefCountPtr<N_NLS_NOX::AugmentLinSys>
1639 ParameterSet::createAugmentLinearSystem(N_LAS_System* ls, Xyce::NodeNamePairMap & op,
1640  bool gminStepping) const
1641 {
1642  Teuchos::RefCountPtr<N_NLS_NOX::AugmentLinSys> als;
1643 
1644  Teuchos::RefCountPtr<Epetra_MapColoring> ICcolor_map =
1645  Teuchos::rcp(ls->builder().createInitialConditionColoring());
1646 
1647  if (gminStepping==false)
1648  {
1649  als = Teuchos::rcp( new N_NLS_NOX::AugmentLinSysIC(op, ICcolor_map, ls->getRHSVector() ) );
1650  }
1651  else
1652  {
1653  if (voltageListType_ == VLT_DOFS)
1654  {
1655  Teuchos::RefCountPtr<Epetra_MapColoring> GMINcolor_map =
1656  Teuchos::rcp(ls->builder().createSolnColoring());
1657 
1658  als = Teuchos::rcp( new N_NLS_NOX::AugmentLinSysIC_Gmin(
1659  op,
1660  ICcolor_map,
1661  GMINcolor_map,
1662  ls->getRHSVector(),
1665  }
1666  else
1667  {
1668  als = Teuchos::rcp( new N_NLS_NOX::AugmentLinSysIC_Gmin(
1669  op,
1670  ICcolor_map,
1671  //AugmentLinSysIC_Gmin(ls->getQueryUtil()->vnodeGIDVec()),
1672  ls->getQueryUtil()->vnodeGIDVec(),
1673  ls->getRHSVector(),
1676  }
1677  }
1678 
1679  return als;
1680 }
1681