Xyce  6.1
N_NLS_NOX_Interface.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_NLS_NOX_Interface.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.191.2.1 $
40 //
41 // Revision Date : $Date: 2015/04/02 18:20:17 $
42 //
43 // Current Owner : $Author: tvrusso $
44 //-------------------------------------------------------------------------
45 
46 #include <Xyce_config.h>
47 
48 #ifndef HAVE_CONFIG_H
49 #define HAVE_CONFIG_H
50 #endif
51 
52 #include <sstream>
53 
54 #include <LOCA_GlobalData.H>
55 #include <LOCA_StatusTest_Wrapper.H>
56 #include <NOX_Solver_Factory.H>
57 #include <N_ANP_AnalysisManager.h>
58 #include <N_ERH_ErrorMgr.h>
59 #include <N_IO_CmdParse.h>
60 #include <N_IO_OutputMgr.h>
61 #include <N_LAS_Builder.h>
62 #include <N_LAS_QueryUtil.h>
63 #include <N_LAS_Solver.h>
64 #include <N_LAS_System.h>
66 #include <N_NLS_LOCA_Group.h>
68 #include <N_NLS_NOX_Group.h>
69 #include <N_NLS_NOX_Interface.h>
72 #include <N_NLS_NOX_SharedSystem.h>
73 #include <N_NLS_NOX_XyceTests.h>
74 #include <N_UTL_FeatureTest.h>
75 
76 #ifdef Xyce_PARALLEL_MPI
77 #include <N_PDS_ParComm.h>
78 #else
79 #include <N_PDS_SerialComm.h>
80 #endif
81 
82 
83 // ---------- NOX Includes ----------
84 #include <LOCA.H>
85 
86 // ----------- Forward declarations -------
87 namespace Xyce {
88 namespace Nonlinear {
89 namespace N_NLS_NOX {
90 
91 //-----------------------------------------------------------------------------
92 // Function : Interface::Interface
93 // Purpose : constructor
94 // Special Notes :
95 // Scope : public
96 // Creator :
97 // Creation Date :
98 //-----------------------------------------------------------------------------
99 Interface::Interface(const IO::CmdParse & cp)
100  : Nonlinear::NonLinearSolver(cp),
101  dcParams_(Nonlinear::DC_OP),
102  transientParams_(Nonlinear::TRANSIENT),
103  hbParams_(Nonlinear::HB_MODE),
104  sharedSystemPtr_(0),
105  mode_(Nonlinear::DC_OP),
106  lastParametersMode_(Nonlinear::DC_OP),
107  parametersMode_(Nonlinear::DC_OP),
108  usemode_(true),
109  copiedGroupFlag_(false),
110  DCOPused_(false),
111  ICspecified_(false),
112  NODESETspecified_(false),
113  isFirstContinuationParam_(true),
114  firstSolveComplete_(false),
115  iParam_(0)
116 {
117 }
118 
119 //-----------------------------------------------------------------------------
120 // Function : Interface::~Interface
121 // Purpose : destructor
122 // Special Notes :
123 // Scope : public
124 // Creator :
125 // Creation Date :
126 //-----------------------------------------------------------------------------
128 {
129  delete sharedSystemPtr_;
130  if (!Teuchos::is_null(globalDataPtr_))
131  {
132  LOCA::destroyGlobalData(globalDataPtr_);
133  }
134 }
135 
136 //-----------------------------------------------------------------------------
137 // Function : Interface::setOptions
138 // Purpose : Passes option block corresponding to "NONLIN" onto
139 // nonlinear solver. These parameters set convergence
140 // tolerances, the type of method used, and so on.
141 // Special Notes :
142 // Return Type : boolean
143 //
144 // See also : setTranOptions, setAnalysisMode
145 //
146 // - Input Arguments -
147 //
148 // OB : Option block containing options corresponding to
149 // "NONLIN" in the netlist.
150 // Scope : public
151 // Creator :
152 // Creation Date :
153 //-----------------------------------------------------------------------------
154 bool Interface::setOptions(const Util::OptionBlock& OB)
155 {
156  return dcParams_.setOptions(OB);
157 }
158 
159 
160 //-----------------------------------------------------------------------------
161 // Function : Interface::setTranOptions
162 //
163 // Purpose : Passes option block corresponding to "NONLIN-TRAN" onto
164 // nonlinear solver. This affects the settings used when
165 // the mode is Transient.
166 //
167 // Special Notes :
168 // Return Type : boolean
169 //
170 // See also : setOptions, setAnalysisMode
171 //
172 // - Input Arguments -
173 // OB : Option block containing options corresponding to
174 // "NONLIN-TRAN" in the netlist.
175 // Scope : public
176 // Creator :
177 // Creation Date :
178 //-----------------------------------------------------------------------------
179 bool Interface::setTranOptions(const Util::OptionBlock& OB)
180 {
181  return transientParams_.setOptions(OB);
182 }
183 
184 //-----------------------------------------------------------------------------
185 // Function : Interface::setHBOptions
186 // Purpose :
187 // Scope : public
188 // Creator :
189 // Creation Date :
190 //-----------------------------------------------------------------------------
191 bool Interface::setHBOptions(const Util::OptionBlock& OB)
192 {
193  return hbParams_.setOptions(OB);
194 }
195 
196 
197 //-----------------------------------------------------------------------------
198 // Function : Interface::setLocaOptions
199 // Purpose :
200 // Special Notes :
201 // Scope : public
202 // Creator :
203 // Creation Date :
204 //-----------------------------------------------------------------------------
205 bool Interface::setLocaOptions(const Util::OptionBlock& OB)
206 {
208  return dcParams_.setLocaOptions(OB);
209 }
210 
211 //-----------------------------------------------------------------------------
212 // Function : Interface::setDCOPRestartOptions
213 // Purpose :
214 // Special Notes :
215 // Scope : public
216 // Creator :
217 // Creation Date :
218 //-----------------------------------------------------------------------------
219 bool Interface::setDCOPRestartOptions(const Util::OptionBlock& OB)
220 {
221  DCOPspecified_ = true;
222  return true;
223 }
224 
225 //-----------------------------------------------------------------------------
226 // Function : Interface::setICOptions
227 // Purpose :
228 // Special Notes :
229 // Scope : public
230 // Creator :
231 // Creation Date :
232 //-----------------------------------------------------------------------------
233 bool Interface::setICOptions(const Util::OptionBlock& OB)
234 {
235  ICspecified_ = true;
236  return true;
237 }
238 
239 //-----------------------------------------------------------------------------
240 // Function : Interface::setNodeSetOptions
241 // Purpose :
242 // Special Notes :
243 // Scope : public
244 // Creator :
245 // Creation Date :
246 //-----------------------------------------------------------------------------
247 bool Interface::setNodeSetOptions(const Util::OptionBlock& OB)
248 {
249  NODESETspecified_ = true;
250  return true;
251 }
252 
253 //-----------------------------------------------------------------------------
254 // Function : Interface::initializeAll
255 //
256 // Purpose : Called after all register and set functions.
257 // Once the various registrations have taken place,
258 // this function sets the remaining pointers.
259 //
260 // Special Notes :
261 // Derived Notes : This function also calls the base object initializeAll.
262 //
263 // Special Notes: This function obtains the solution, temporary solution and
264 // f vectors from the LAS system class.
265 //
266 // Return Type : boolean
267 // Scope : public
268 // Creator : Eric Keiter
269 // Creation Date :
270 //-----------------------------------------------------------------------------
272 {
273  // Use the base class initialization
275  if (!initok)
276  {
277  return false;
278  }
279 
280  // Set the processor ID for printing in the nonlinear solver
281  // For now, processor 0 will output information to the screen
282  //int myPID = ((**nextSolVectorPtrPtr_).epetraObj()).Comm().MyPID();
283  int myPID = pdsMgrPtr_->getPDSComm()->procID();
284  dcParams_.setOutputOptions(myPID, 0);
286 
287  hbParams_.setOutputOptions(myPID, 0);
288 
289  // Set up the status tests
290  bool testsok = false;
291  if (NLS_MASKED_WRMS_NORMS)
292  {
293  testsok =
294  dcParams_.createStatusTests(pdsMgrPtr_->getPDSComm()->comm(), currSolVectorPtrPtr_, getLoader(), lasSysPtr_->getDeviceMaskVector()) &&
295  transientParams_.createStatusTests(pdsMgrPtr_->getPDSComm()->comm(), currSolVectorPtrPtr_, getLoader(), lasSysPtr_->getDeviceMaskVector()) &&
296  hbParams_.createStatusTests(pdsMgrPtr_->getPDSComm()->comm(), currSolVectorPtrPtr_, getLoader(), lasSysPtr_->getDeviceMaskVector());
297  }
298  else
299  {
300  testsok =
304  }
305 
306  if (!testsok)
307  return false;
308 
309  // Set up any linear solver options
310  // We only set the tolerance if adaptive forcing is being used.
311  setAZ_Tol_DC = false;
312  setAZ_Tol_Transient = false;
313  if (!(dcParams_.getNoxParams()->sublist("Direction").sublist("Newton")
314  .get("Forcing Term Method","Constant") == std::string("Constant")))
315  {
316  setAZ_Tol_DC = true;
317  }
318  if (!(transientParams_.getNoxParams()->sublist("Direction").sublist("Newton")
319  .get("Forcing Term Method", "Constant") == std::string("Constant")))
320  {
321  setAZ_Tol_Transient = true;
322  }
323  if (!(hbParams_.getNoxParams()->sublist("Direction").sublist("Newton")
324  .get("Forcing Term Method", "Constant") == std::string("Constant")))
325  {
326  setAZ_Tol_Transient = true;
327  }
328 
329  return true;
330 }
331 
332 //-----------------------------------------------------------------------------
333 // Function : Interface::spiceStrategy
334 //
335 // Purpose : This function attempts a stdNewton solve first, and if that
336 // fails then does gmin stepping. This is only done for DCOP
337 // calculations.
338 //
339 // Special Notes :
340 // Scope : public
341 // Creator : Eric Keiter
342 // Creation Date : 5/7/2014
343 //-----------------------------------------------------------------------------
345 {
346  groupPtr_->setNonContinuationFlag (true);
347  int isuccess = stdNewtonSolve (paramsPtr);
348 
349  if (isuccess < 0) // attempt gmin stepping.
350  {
351  int saveSolverType=paramsPtr->getNoxSolverType();
352  paramsPtr->setNoxSolverType(3);
353  groupPtr_->setNonContinuationFlag (false);
354 
355  rhsVectorPtr_->putScalar(0.0);
356  NewtonVectorPtr_->putScalar(0.0);
357  gradVectorPtr_->putScalar(0.0);
358  (*nextSolVectorPtrPtr_)->putScalar(0.0);
359 
361  groupPtr_->setX(tmpVec);
362 
364  *rhsVectorPtr_,
368  *lasSysPtr_,
369  *this);
370 
371  isuccess=gminSteppingSolve ( paramsPtr );
372  if (isuccess < 0)
373  {
374  paramsPtr->setNoxSolverType(34);
375  groupPtr_->setNonContinuationFlag (false);
376 
377  rhsVectorPtr_->putScalar(0.0);
378  NewtonVectorPtr_->putScalar(0.0);
379  gradVectorPtr_->putScalar(0.0);
380  (*nextSolVectorPtrPtr_)->putScalar(0.0);
381 
383  groupPtr_->setX(tmpVec);
384 
386  *rhsVectorPtr_,
390  *lasSysPtr_,
391  *this);
392 
393  isuccess=sourceSteppingSolve ( paramsPtr );
394  paramsPtr->setNoxSolverType(saveSolverType);
395  }
396  }
397  return isuccess;
398 
399 }
400 
401 //-----------------------------------------------------------------------------
402 // Function : Interface::opStartCont0
403 // Purpose :
404 // Special Notes : returns true if DCOP restart is being used.
405 //
406 // The "found" variable indicates if any of the nodes specified
407 // in the dcop start file were found in this circuit. If not,
408 // then don't bother with this.
409 //
410 // Scope : public
411 // Creator : Eric R. Keiter, SNL, Electrical and Microsystem Modeling
412 // Creation Date : 09/15/07
413 //-----------------------------------------------------------------------------
414 bool Interface::opStartCont0 (ParameterSet* paramsPtr, int found, int icType, IO::InitialConditionsData::NodeNamePairMap & op, const NodeNameMap & allNodes, N_PDS_Comm * pdsCommPtr)
415 {
416  bool usedOP = false;
417 
418  if (found > 0 && icType == IO::InitialConditionsData::IC_TYPE_DCOP_RESTART)
419  {
420  usedOP = true;
421  Teuchos::RCP<AugmentLinSys> als =
422  paramsPtr->createAugmentLinearSystem(lasSysPtr_, op, allNodes, pdsCommPtr);
423  groupPtr_->setAugmentLinearSystem(true, als);
424  NOX::StatusTest::StatusType status = solverPtr_->solve();
425  // Create a new solver after performing the initial op_start solve.
426  solverPtr_ = NOX::Solver::buildSolver(groupPtr_,
427  paramsPtr->getStatusTests(),
428  paramsPtr->getNoxParams());
429  firstSolveComplete_ = true;
430  groupPtr_->setAugmentLinearSystem(false, Teuchos::null);
431 
432 #ifdef Xyce_DEBUG_OP_START
433  groupPtr_->setOutputLinear (&op, &allNodes, pdsCommPtr);
434 #endif // debug op start
435 
436  }
437  return usedOP;
438 }
439 
440 
441 //-----------------------------------------------------------------------------
442 // Function : Interface::stdNewtonSolve
443 // Purpose :
444 // Special Notes : This corresponds to
445 // .options nonlin continuation=stan or
446 // .options nonlin continuation=0
447 // Scope : public
448 // Creator : Roger Pawlowski, Eric Keiter
449 // Creation Date :
450 //-----------------------------------------------------------------------------
452 {
453  bool usedIC=false;
454  bool usedNODESET=false;
455 
456  // RPP: needed for tensor method. DO NOT UNCOMMENT!
457  // This somehow breaks the one-shot test circuit.
458  // ERK: it breaks it (and probably many other circuits) b/c voltage
459  // limiting is fragile and cannot handle extra (unexpected)
460  // F-loads.
461  //groupPtr_->computeF();
462 
463  // Set up nox nonlinear solver. solverPtr is only needed for
464  // non-LOCA (i.e. just Newton's method, no continuation) solves.
465  if ( Teuchos::is_null(solverPtr_) || ((usemode_) && (lastParametersMode_ != parametersMode_)) )
466  {
467  if (DEBUG_NONLINEAR)
468  {
469  if ( Teuchos::is_null(solverPtr_) )
470  dout() << "Creating new NLS solver b/c it is 0." <<std::endl;
472  dout() << "Creating new NLS solver b/c starting next phase, post-DC." <<std::endl;
473  }
474 
475  solverPtr_ = NOX::Solver::buildSolver(groupPtr_,
476  paramsPtr->getStatusTests(),
477  paramsPtr->getNoxParams());
478  }
479  else // solverPtr is not null, and the mode didn't change since last call.
480  {
481  if (DEBUG_NONLINEAR)
482  dout() << "NOT Creating new NLS solver, just resetting." <<std::endl;
483 
484  solverPtr_->reset(groupPtr_->getX());
485  }
486 
487  // If .IC, .NODESET or .OP have been specified, then set up the
488  // augmented linear systems
489  if ((usemode_) && (mode_ != Nonlinear::TRANSIENT))
490  {
491  if (ICspecified_)
492  {
493  usedIC=icCont (paramsPtr);
494  }
495  else if (NODESETspecified_)
496  {
497  usedNODESET=nodesetCont0 (paramsPtr);
498  }
499  else
500  {
501  if (!DCOPused_) {
502  int found = 0;
503  int icType;
504  IO::InitialConditionsData::NodeNamePairMap & op = initialConditionsManager_->getICData(found, icType);
505  DCOPused_ = opStartCont0(paramsPtr, found, icType, op, outMgrPtr_->getSolutionNodeMap(), pdsMgrPtr_->getPDSComm());
507  }
508  }
509  }
510 
511  NOX::StatusTest::StatusType status = solverPtr_->solve();
512  firstSolveComplete_ = true;
513 
514  if (usedIC)
515  {
516  groupPtr_->setAugmentLinearSystem(false, Teuchos::null);
517  }
518  // Send back the correct return code
519  if (DEBUG_NONLINEAR)
520  dout() << "return code for transient params: " << transientParams_.getStatusTestReturnCode() <<std::endl
521  << "return code for hb params: " << hbParams_.getStatusTestReturnCode() << std::endl
522  << "return code for dc params: " << dcParams_.getStatusTestReturnCode () << std::endl;
523 
524  return paramsPtr->getStatusTestReturnCode();
525 }
526 
527 //-----------------------------------------------------------------------------
528 // Function : Interface::naturalParameterContinuationSolve
529 // Purpose :
530 // Special Notes : This corresponds to
531 // .options nonlin continuation=nat or
532 // .options nonlin continuation=1
533 // Scope : public
534 // Creator : Roger Pawlowski, Eric Keiter
535 // Creation Date :
536 //-----------------------------------------------------------------------------
538 {
539  std::vector<std::string> pars;
540  std::string con;
541  int j, numParam = 0;
542  double value;
543  bool usedOP=false;
544  bool usedNODESET=false;
545  bool usedIC=false;
546 
547  if ((usemode_) && (mode_ != Nonlinear::TRANSIENT))
548  {
549  if (ICspecified_)
550  {
551  usedIC=icCont (paramsPtr);
552  }
553  else if (NODESETspecified_)
554  {
555  usedNODESET=nodesetCont1 (paramsPtr);
556  }
557  else
558  {
559  usedOP = opStartCont1 (paramsPtr);
560  }
561  }
562 
563  Teuchos::RCP<Teuchos::ParameterList> locaList =
564  paramsPtr->getLocaParams();
565 
566  // Create Parameter Vector and get the stepper parameter list.
567  LOCA::ParameterVector locaPVec;
568  Teuchos::ParameterList& stepperList = locaList->sublist("Stepper");
569  Teuchos::ParameterList& stepSizeList = locaList->sublist("Step Size");
570 
571  while (paramsPtr->getVectorParam("CONPARAM", numParam, con))
572  {
573  pars.push_back(con);
574  numParam++;
575  }
576 
577  // Fail out if no parameters have been specified.
578  if ( numParam == 0 ) {
579  std::string message = "Using \"continuation=1\" requires a parameter to be set with the conparam keyword in the loca option block!";
580  N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::USR_FATAL, message);
581  }
582 
583  Teuchos::RCP<AugmentLinSys> als;
584 
585  std::vector<double> minValue(numParam, 0.);
586  std::vector<double> maxValue(numParam, 0.);
587  std::vector<double> initialValue(numParam, 0.);
588  std::vector<double> initialStepSize(numParam, 0.);
589  std::vector<double> minStepSize(numParam, 0.);
590  std::vector<double> maxStepSize(numParam, 0.);
591  std::vector<double> aggressiveness(numParam, 0.);
592 
593  // Check the size of params to make sure users provided all required data
594  std::vector<std::string> paramNames(0);
595  paramNames.push_back("MINVALUE");
596  paramNames.push_back("MAXVALUE");
597  paramNames.push_back("INITIALVALUE");
598  paramNames.push_back("INITIALSTEPSIZE");
599  paramNames.push_back("MINSTEPSIZE");
600  paramNames.push_back("MAXSTEPSIZE");
601  paramNames.push_back("AGGRESSIVENESS");
602 
603  for (std::size_t p = 0 ; p < paramNames.size() ; ++p) {
604  if ( paramsPtr->getVectorParamSize(paramNames[p]) != numParam) {
605  std::string msg = "The parameter \"" +
606  paramNames[p] +
607  "\" must have a list of values with size equal to the numParamber of parameters specified in \"conparam\".";
608  N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::DEV_FATAL, msg);
609  }
610  }
611 
612  for (iParam_=0 ; iParam_<numParam ; ++iParam_)
613  {
614  paramsPtr->getVectorParam("MINVALUE", iParam_, value);
615  minValue[iParam_] = value;
616 
617  paramsPtr->getVectorParam("MAXVALUE", iParam_, value);
618  maxValue[iParam_] = value;
619 
620  paramsPtr->getVectorParam("INITIALVALUE", iParam_, value);
621  initialValue[iParam_] = value;
622 
623  paramsPtr->getVectorParam("INITIALSTEPSIZE", iParam_, value);
624  initialStepSize[iParam_] = value;
625 
626  paramsPtr->getVectorParam("MINSTEPSIZE", iParam_, value);
627  minStepSize[iParam_] = value;
628 
629  paramsPtr->getVectorParam("MAXSTEPSIZE", iParam_, value);
630  maxStepSize[iParam_] = value;
631 
632  paramsPtr->getVectorParam("AGGRESSIVENESS", iParam_, value);
633  aggressiveness[iParam_] = value;
634 
635  locaPVec.addParameter (pars[iParam_], initialValue[iParam_]);
636 
637  }
638 
639  if (usedOP || usedNODESET)
640  {
641  const N_NLS_LOCA::Group & conLocaGrp =
642  dynamic_cast<const N_NLS_LOCA::Group&>(solverPtr_->getSolutionGroup());
643  *groupPtr_ = const_cast<N_NLS_LOCA::Group&>(conLocaGrp);
644  solverPtr_ = Teuchos::null;
645  }
646 
647  groupPtr_->setParams(locaPVec);
648 
649  LOCA::Abstract::Iterator::IteratorStatus locaStatus;
650 
651  for (iParam_=0 ; iParam_<numParam ; ++iParam_)
652  {
653  // Copy out the solution and use it in the next run
654  if (iParam_ > 0)
655  {
656  groupPtr_->copy(*(stepperPtr_->getSolutionGroup()));
657  }
658 
659  stepperList.set("Continuation Parameter", pars[iParam_]);
660  stepperList.set("Initial Value", initialValue[iParam_]);
661  stepperList.set("Max Value", maxValue[iParam_]);
662  stepperList.set("Min Value", minValue[iParam_]);
663  stepSizeList.set("Initial Step Size", initialStepSize[iParam_]);
664  stepSizeList.set("Min Step Size", minStepSize[iParam_]);
665  stepSizeList.set("Max Step Size", maxStepSize[iParam_]);
666  stepSizeList.set("Aggressiveness", aggressiveness[iParam_]);
667 
668  for (j=0 ; j<iParam_ ; ++j)
669  {
670  locaPVec.setValue(pars[j], maxValue[j]);
671  }
672  for (j=iParam_ ; j<numParam ; ++j)
673  {
674  locaPVec.setValue(pars[j], initialValue[j]);
675  }
676  groupPtr_->setParams(locaPVec);
677 
678  if (iParam_==0)
679  {
680  if (!usedOP && !usedNODESET) // (usedOP and usedNODESET have already loaded F)
681  {
682  groupPtr_->computeF();
683  }
684  }
685 
686  // RPP 03/08/2006 If this is a special parameter used in voltage
687  // node resistance (Spice's GMIN stepping) then we need to
688  // intercept and handle the parameter in the solver (in the LOCA
689  // Group) - the device package does nothing for this parameter.
690  if (pars[iParam_] != "GSTEPPING")
691  {
692  // Do the continuation run
694  locaStatus = stepperPtr_->run();
695  if (usedIC || usedNODESET)
696  {
697  groupPtr_->setAugmentLinearSystem(false, Teuchos::null);
698  }
699  }
700  else
701  {
702  if (iParam_ == 0 && DCOPused_)
703  {
704  std::string message = "'.dcop input=' and gstepping are incompatible";
705  N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::USR_FATAL, message);
706  }
707  Teuchos::RCP<AugmentLinSys> als =
709  groupPtr_->setAugmentLinearSystem(true, als);
710 
711  // Do the continuation run
713  locaStatus = stepperPtr_->run();
714 
715  groupPtr_->setAugmentLinearSystem(false, Teuchos::null);
716  }
717 
718  // Kick out if continuation failed
719  if (locaStatus != LOCA::Abstract::Iterator::Finished)
720  return (-1);
721 
722  // Increment Param Number Tracking
724  firstSolveComplete_ = true;
725  }
726  return (paramsPtr->getStatusTestReturnCode());
727 }
728 
729 //-----------------------------------------------------------------------------
730 // Function : Interface::mosfetContinuationSolve
731 // Purpose :
732 // Special Notes : This corresponds to
733 // .options nonlin continuation=mos or
734 // .options nonlin continuation=2
735 // Scope : public
736 // Creator : Roger Pawlowski, Eric Keiter
737 // Creation Date :
738 //-----------------------------------------------------------------------------
740 {
741  bool usedOP=false;
742  bool usedNODESET=false;
743  bool usedIC=false;
744 
745  if ((usemode_) && (mode_ != Nonlinear::TRANSIENT))
746  {
747  if (ICspecified_)
748  {
749  usedIC=icCont (paramsPtr);
750  }
751  else if (NODESETspecified_)
752  {
753  usedNODESET=nodesetCont1 (paramsPtr);
754  }
755  else
756  {
757  usedOP = opStartCont1 (paramsPtr);
758  }
759  }
760 
761  // check if use specified vector params. If so, flag a warning.
762  std::vector<std::string> pars;
763  std::string con;
764  int numParam;
765  while (paramsPtr->getVectorParam("CONPARAM", numParam, con))
766  {
767  pars.push_back(con);
768  numParam++;
769  }
770 
771  if ( numParam > 1 ) {
772  Report::UserWarning() << "Using \"continuation=2\" currently does not support vectorized loca parameters. Only the first values in each list will be used";
773  }
774 
775  Teuchos::RCP<Teuchos::ParameterList> locaList = paramsPtr->getLocaParams();
776 
777  // Create the continuation parameter names
778  std::string gain = "mosfet:gainscale";
779  std::string nonlinear = "mosfet:nltermscale";
780 
781  // Create Parameter Vector and get the stepper parameter list.
782  LOCA::ParameterVector locaPVec;
783  Teuchos::ParameterList& stepperList = locaList->sublist("Stepper");
784  Teuchos::ParameterList& predictorList = locaList->sublist("Predictor");
785  Teuchos::ParameterList& stepSizeList = locaList->sublist("Step Size");
786 
787  // Continuation solve from alpha2 (gain) = 0.0 -> 1.0
788  // with alpha1 (nlterm) = 0.0 (constant)
789  locaPVec.addParameter(gain, 0.0);
790  locaPVec.addParameter(nonlinear, 0.0);
791  groupPtr_->setParams(locaPVec);
792  stepperList.set("Continuation Parameter", gain);
793 
794  stepperList.set("Initial Value", 0.0);
795  stepperList.set("Max Value", 1.0);
796  stepperList.set("Min Value",-1.0);
797 
798  stepSizeList.set("Initial Step Size", 0.2);
799  stepSizeList.set("Min Step Size", 1.0e-4);
800  stepSizeList.set("Max Step Size", 1.0);
801  stepSizeList.set("Aggressiveness", 1.0);
802 
803  // assert the user-specified defaults, if any.
805 
806  // Initialize parameters in xyce
807  if (!usedOP && !usedNODESET) // (usedOP and usedNODESET have already loaded F)
808  {
809  groupPtr_->computeF();
810  }
811 
812  // Do the continuation run
813  iParam_ = 0;
815  LOCA::Abstract::Iterator::IteratorStatus locaStatus = stepperPtr_->run();
816 
817  // Kick out if continuation failed
818  if (locaStatus != LOCA::Abstract::Iterator::Finished)
819  return (-1);
820 
821  // Increment Param Number Tracking
823  firstSolveComplete_ = true;
824 
825  // Copy out the solution and use it in the next run
826  groupPtr_->copy(*(stepperPtr_->getSolutionGroup()));
827 
828  // Continuation solve from alpha1 (nlterm) = 0.0 -> 1.0
829  // with alpha2 (gain) = 1.0 (constant)
830  stepperList.set("Continuation Parameter", nonlinear);
831 
832  stepperList.set("Initial Value", 0.0);
833  stepperList.set("Max Value", 1.0);
834  stepperList.set("Min Value",-1.0);
835 
836  stepSizeList.set("Initial Step Size", 0.2);
837  stepSizeList.set("Min Step Size", 1.0e-4);
838  stepSizeList.set("Max Step Size", 1.0);
839  stepSizeList.set("Aggressiveness", 1.0);
840 
841  // assert the user-specified defaults, if any.
843 
844  locaPVec.setValue(gain, 1.0);
845  locaPVec.setValue(nonlinear, 0.0);
846  groupPtr_->setParams(locaPVec);
847 
848  // Do the continuation run
849  iParam_ = 1;
851  locaStatus = stepperPtr_->run();
852 
853  if (usedIC)
854  {
855  groupPtr_->setAugmentLinearSystem(false, Teuchos::null);
856  }
857 
858  // Return the solution status
859  if (locaStatus != LOCA::Abstract::Iterator::Finished)
860  return (-1);
861  else
862  return (paramsPtr->getStatusTestReturnCode());
863 }
864 
865 //-----------------------------------------------------------------------------
866 // Function : Interface::mosfetContinuationSolve2
867 // Purpose :
868 // Return Type :
869 // Special Notes : This corresponds to
870 // .options nonlin continuation=newmos or
871 // .options nonlin continuation=4
872 // Scope : public
873 // Creator : Roger Pawlowski, Eric Keiter
874 // Creation Date : 2/21/2004
875 //-----------------------------------------------------------------------------
877 {
878  Teuchos::RCP<Teuchos::ParameterList> locaList = paramsPtr->getLocaParams();
879 
880  // Create the continuation parameter names
881  std::string gain = "mosfet:gainscale";
882  std::string nonlinear = "mosfet:nltermscale";
883  std::string size = "mosfet:sizescale";
884 
885  // Create Parameter Vector and get the stepper parameter list.
886  LOCA::ParameterVector locaPVec;
887  Teuchos::ParameterList& stepperList = locaList->sublist("Stepper");
888 
889  // Continuation solve from alpha2 (gain) = 0.0 -> 1.0
890  // with alpha1 (nlterm) = 0.0 (constant)
891  // sizeScale = 0.0 (constant)
892  locaPVec.addParameter(gain, 0.0);
893  locaPVec.addParameter(nonlinear, 0.0);
894  locaPVec.addParameter(size, 0.0);
895  groupPtr_->setParams(locaPVec);
896  stepperList.set("Continuation Parameter", gain);
897  stepperList.set("Initial Value", 0.0);
898  stepperList.set("Max Value", 1.0);
899 
900  // Initialize parameters in xyce
901  groupPtr_->computeF();
902 
903  // Do the continuation run
905  LOCA::Abstract::Iterator::IteratorStatus locaStatus = stepperPtr_->run();
906 
907  // Kick out if continuation failed
908  if (locaStatus != LOCA::Abstract::Iterator::Finished)
909  return (-1);
910 
911  // Increment Param Number Tracking
913  firstSolveComplete_ = true;
914 
915  // Copy out the solution and use it in the next run
916  groupPtr_->copy(*(stepperPtr_->getSolutionGroup()));
917 
918  // Continuation solve from alpha1 (nlterm) = 0.0 -> 1.0
919  // with alpha2 (gain) = 1.0 (constant)
920  // with size (scale) = 0.0 (constant)
921  stepperList.set("Continuation Parameter", nonlinear);
922  stepperList.set("Initial Value", 0.0);
923  stepperList.set("Max Value", 1.0);
924  locaPVec.setValue(gain, 1.0);
925  locaPVec.setValue(nonlinear, 0.0);
926  locaPVec.setValue(size, 0.0);
927  groupPtr_->setParams(locaPVec);
928 
929  // Do the continuation run
931  locaStatus = stepperPtr_->run();
932 
933  // Kick out if continuation failed
934  if (locaStatus != LOCA::Abstract::Iterator::Finished)
935  return (-1);
936 
937  // Copy out the solution and use it in the next run
938  groupPtr_->copy(*(stepperPtr_->getSolutionGroup()));
939 
940  // Continuation solve from alpha1 (nlterm) = 1.0 -> 1.0
941  // with alpha2 (gain) = 1.0 (constant)
942  // with size (scale) = 0.0 -> 1.0
943  stepperList.set("Continuation Parameter", size);
944  stepperList.set("Initial Value", 0.0);
945  stepperList.set("Max Value", 1.0);
946  locaPVec.setValue(gain, 1.0);
947  locaPVec.setValue(nonlinear, 1.0);
948  locaPVec.setValue(size, 0.0);
949  groupPtr_->setParams(locaPVec);
950 
951  // Do the continuation run
953  locaStatus = stepperPtr_->run();
954 
955  // Return the solution status
956  if (locaStatus != LOCA::Abstract::Iterator::Finished)
957  return (-1);
958  else
959  return (paramsPtr->getStatusTestReturnCode());
960 }
961 
962 //-----------------------------------------------------------------------------
963 // Function : Interface::mosfetContinuationSolve3
964 // Purpose : (5) Mosfet:BSIM3:Inverter specific continuation
965 // Special Notes : This corresponds to
966 // .options nonlin continuation=bsim3inv1 or
967 // .options nonlin continuation=5
968 // Scope : public
969 // Creator : Roger Pawlowski, Eric Keiter
970 // Creation Date : 2/25/2004
971 //-----------------------------------------------------------------------------
973 {
974  Teuchos::RCP<Teuchos::ParameterList> locaList = paramsPtr->getLocaParams();
975 
976  // Create the continuation parameter names
977  //std::string gain = "mosfet:gainscale";
978  std::string nonlinear = "mosfet:nltermscale";
979  std::string size = "mosfet:sizescale";
980 
981  // Create Parameter Vector and get the stepper parameter list.
982  LOCA::ParameterVector locaPVec;
983  Teuchos::ParameterList& stepperList = locaList->sublist("Stepper");
984 
985  // Continuation solve from alpha2 (gain) = 0.0 -> 1.0
986  // with alpha1 (nlterm) = 0.0 (constant)
987  // sizeScale = 0.0 (constant)
988  //locaPVec.addParameter(gain, 0.0);
989  locaPVec.addParameter(nonlinear, 0.0);
990  locaPVec.addParameter(size, 0.0);
991  groupPtr_->setParams(locaPVec);
992  stepperList.set("Continuation Parameter", nonlinear);
993  stepperList.set("Initial Value", 0.0);
994  stepperList.set("Max Value", 1.0);
995 
996  // Initialize parameters in xyce
997  groupPtr_->computeF();
998 
999  // Do the continuation run
1001  LOCA::Abstract::Iterator::IteratorStatus locaStatus = stepperPtr_->run();
1002 
1003  // Kick out if continuation failed
1004  if (locaStatus != LOCA::Abstract::Iterator::Finished)
1005  return (-1);
1006 
1007  // Increment Param Number Tracking
1008  isFirstContinuationParam_ = false;
1009  firstSolveComplete_ = true;
1010 
1011  // Copy out the solution and use it in the next run
1012  groupPtr_->copy(*(stepperPtr_->getSolutionGroup()));
1013 
1014  // Continuation solve from alpha1 (nlterm) = 0.0 -> 1.0
1015  // with alpha2 (gain) = 1.0 (constant)
1016  // with size (scale) = 0.0 (constant)
1017  stepperList.set("Continuation Parameter", size);
1018  stepperList.set("Initial Value", 0.0);
1019  stepperList.set("Max Value", 1.0);
1020  //locaPVec.setValue(gain, 1.0);
1021  locaPVec.setValue(nonlinear, 1.0);
1022  locaPVec.setValue(size, 0.0);
1023  groupPtr_->setParams(locaPVec);
1024 
1025  // Do the continuation run
1027  locaStatus = stepperPtr_->run();
1028 
1029  // Return the solution status
1030  if (locaStatus != LOCA::Abstract::Iterator::Finished)
1031  return (-1);
1032  else
1033  return (paramsPtr->getStatusTestReturnCode());
1034 }
1035 
1036 //-----------------------------------------------------------------------------
1037 // Function : Interface::mosfetContinuationSolve4
1038 // Purpose : (6) Mosfet:BSIM3:Inverter specific continuation
1039 // Special Notes : This corresponds to
1040 // .options nonlin continuation=bsim3inv2 or
1041 // .options nonlin continuation=6
1042 // Scope : public
1043 // Creator : Roger Pawlowski, Eric Keiter
1044 // Creation Date : 2/25/2004
1045 //-----------------------------------------------------------------------------
1047 {
1048  Teuchos::RCP<Teuchos::ParameterList> locaList = paramsPtr->getLocaParams();
1049 
1050  // Create the continuation parameter names
1051  std::string gain = "mosfet:gainscale";
1052  std::string nonlinear = "mosfet:nltermscale";
1053  std::string size = "mosfet:sizescale";
1054 
1055  // Create Parameter Vector and get the stepper parameter list.
1056  LOCA::ParameterVector locaPVec;
1057  Teuchos::ParameterList& stepperList = locaList->sublist("Stepper");
1058 
1059  // Continuation solve
1060  locaPVec.addParameter(gain, 1.0);
1061  locaPVec.addParameter(nonlinear, 1.0);
1062  locaPVec.addParameter(size, 0.0);
1063  groupPtr_->setParams(locaPVec);
1064  stepperList.set("Continuation Parameter", size);
1065  stepperList.set("Initial Value", 0.0);
1066  stepperList.set("Max Value", 1.0);
1067 
1068  // Initialize parameters in xyce
1069  groupPtr_->computeF();
1070 
1071  // Do the continuation run
1073  LOCA::Abstract::Iterator::IteratorStatus locaStatus = stepperPtr_->run();
1074 
1075  // Return the solution status
1076  if (locaStatus != LOCA::Abstract::Iterator::Finished)
1077  return (-1);
1078  else
1079  {
1080  firstSolveComplete_ = true;
1081  return (paramsPtr->getStatusTestReturnCode());
1082  }
1083 }
1084 
1085 //-----------------------------------------------------------------------------
1086 // Function : Interface::mosfetContinuationSolve5
1087 // Purpose :
1088 // Return Type :
1089 // Special Notes : This corresponds to
1090 // .options nonlin continuation=test or
1091 // .options nonlin continuation=8
1092 // Scope : public
1093 // Creator : Roger Pawlowski, Eric Keiter
1094 // Creation Date : 2/25/2004
1095 //-----------------------------------------------------------------------------
1097 {
1098  // Get some initial objects
1099  Teuchos::RCP<Teuchos::ParameterList> locaList = paramsPtr->getLocaParams();
1100  Teuchos::ParameterList& stepperList = locaList->sublist("Stepper");
1101  LOCA::ParameterVector locaPVec;
1102 
1103  // Create storage for continuation objects
1104  int numHomotopyContinuationRuns = 1;
1105  std::vector<std::string> names(numHomotopyContinuationRuns);
1106  std::vector<double> initialVal(numHomotopyContinuationRuns);
1107  std::vector<double> finalVal(numHomotopyContinuationRuns);
1108  std::vector<double> minVal(numHomotopyContinuationRuns);
1109  std::vector<double> maxVal(numHomotopyContinuationRuns);
1110 
1111  // Set up continuation steps
1112  // ***************************************************
1113  // Changes vals below for continuation
1114  // ***************************************************
1115  names[0] = "mosfet:gainscale";
1116  //names[1] = "mosfet:nltermscale";
1117  //names[2] = "mosfet:sizescale";
1118  //names[2] = "mosfet:l";
1119  initialVal[0] = 0.0;
1120  //initialVal[1] = 0.0;
1121  //initialVal[2] = 0.0;
1122  finalVal[0] = 1.0;
1123  //finalVal[1] = 1.0;
1124  //finalVal[2] = 1.0;
1125  // ***************************************************
1126  std::string n1 = "mosfet:nltermscale";
1127  locaPVec.addParameter(n1, 0.0);
1128  //std::string n2 = "mosfet:sizescale";
1129  //locaPVec.addParameter(n2, 0.0);
1130  // ***************************************************
1131  // ***************************************************
1132 
1133  // Ste up max/min bounds
1134  for (int i = 0; i < names.size(); ++i) {
1135  if (finalVal[i] > initialVal[i]) {
1136  minVal[i] = initialVal[i];
1137  maxVal[i] = finalVal[i];
1138  }
1139  else {
1140  minVal[i] = finalVal[i];
1141  maxVal[i] = initialVal[i];
1142  }
1143  }
1144 
1145  // Initialize loca parameter vector
1146  for (int i = 0; i < names.size(); ++i)
1147  locaPVec.addParameter(names[i], initialVal[i]);
1148 
1149  LOCA::Abstract::Iterator::IteratorStatus locaStatus;
1150 
1151  LOCA::StatusTest::Wrapper test(paramsPtr->getStatusTests());
1152 
1153  // Loop over the number of homotopy steps
1154  for (int hs = 0; hs < names.size(); ++hs) {
1155  for (int i = 0; i < names.size(); ++i) {
1156  if (i >= hs)
1157  locaPVec.setValue(names[i], initialVal[i]);
1158  else
1159  locaPVec.setValue(names[i], finalVal[i]);
1160  }
1161  groupPtr_->setParams(locaPVec);
1162  stepperList.set("Continuation Parameter", names[hs]);
1163  stepperList.set("Initial Value", initialVal[hs]);
1164  stepperList.set("Min Value", minVal[hs]);
1165  stepperList.set("Max Value", maxVal[hs]);
1166 
1167  // Initialize parameters in xyce
1168  groupPtr_->computeF();
1169 
1170  // Do the continuation run
1172  locaStatus = stepperPtr_->run();
1173 
1174  // Kick out if continuation failed
1175  if (locaStatus != LOCA::Abstract::Iterator::Finished)
1176  return (-1);
1177 
1178  // Increment Param Number Tracking
1179  isFirstContinuationParam_ = false;
1180  firstSolveComplete_ = true;
1181 
1182  // Copy out the solution and use it in the next run
1183  groupPtr_->copy(*(stepperPtr_->getSolutionGroup()));
1184  }
1185 
1186  // Return converged solver code
1187  return (paramsPtr->getStatusTestReturnCode());
1188 }
1189 
1190 //-----------------------------------------------------------------------------
1191 // Function : Interface::mosfetContinuationSolve6
1192 // Purpose :
1193 // Special Notes : This corresponds to
1194 // .options nonlin continuation=power or
1195 // .options nonlin continuation=10
1196 // Scope : public
1197 // Creator : Roger Pawlowski, Eric Keiter
1198 // Creation Date : 2/25/2004
1199 //-----------------------------------------------------------------------------
1201 {
1202  // Get some initial objects
1203  Teuchos::RCP<Teuchos::ParameterList> locaList = paramsPtr->getLocaParams();
1204  Teuchos::ParameterList& stepperList = locaList->sublist("Stepper");
1205  LOCA::ParameterVector locaPVec;
1206 
1207  // Create storage for continuation objects
1208  int numHomotopyContinuationRuns = 4;
1209  std::vector<std::string> names(numHomotopyContinuationRuns);
1210  std::vector<double> initialVal(numHomotopyContinuationRuns);
1211  std::vector<double> finalVal(numHomotopyContinuationRuns);
1212  std::vector<double> minVal(numHomotopyContinuationRuns);
1213  std::vector<double> maxVal(numHomotopyContinuationRuns);
1214 
1215  // Set up continuation steps
1216  // ***************************************************
1217  // Changes vals below for continuation
1218  // ***************************************************
1219  names[0] = stepperList.get("Power Node", "VA:V0");
1220  names[1] = "mosfet:gainscale";
1221  names[2] = "mosfet:nltermscale";
1222  names[3] = "mosfet:sizescale";
1223  initialVal[0] = 0.0;
1224  initialVal[1] = 0.0;
1225  initialVal[2] = 0.0;
1226  initialVal[3] = 0.0;
1227  finalVal[0] = 1.0;
1228  finalVal[1] = 1.0;
1229  finalVal[2] = 1.0;
1230  finalVal[3] = 1.0;
1231  // ***************************************************
1232  //std::string n1 = "mosfet:nltermscale";
1233  //locaPVec.addParameter(n1, 0.0);
1234  //std::string n2 = "mosfet:sizescale";
1235  //locaPVec.addParameter(n2, 0.0);
1236  // ***************************************************
1237  // ***************************************************
1238 
1239  // Set up max/min bounds
1240  for (int i = 0; i < names.size(); ++i) {
1241  if (finalVal[i] > initialVal[i]) {
1242  minVal[i] = initialVal[i];
1243  maxVal[i] = finalVal[i];
1244  }
1245  else {
1246  minVal[i] = finalVal[i];
1247  maxVal[i] = initialVal[i];
1248  }
1249  }
1250 
1251  // Initialize loca parameter vector
1252  for (int i = 0; i < names.size(); ++i)
1253  locaPVec.addParameter(names[i], initialVal[i]);
1254 
1255  LOCA::Abstract::Iterator::IteratorStatus locaStatus;
1256 
1257  // Loop over the number of homotopy steps
1258  for (int hs = 0; hs < names.size(); ++hs) {
1259  for (int i = 0; i < names.size(); ++i) {
1260  if (i >= hs)
1261  locaPVec.setValue(names[i], initialVal[i]);
1262  else
1263  locaPVec.setValue(names[i], finalVal[i]);
1264  }
1265  groupPtr_->setParams(locaPVec);
1266  stepperList.set("Continuation Parameter", names[hs]);
1267  stepperList.set("Initial Value", initialVal[hs]);
1268  stepperList.set("Min Value", minVal[hs]);
1269  stepperList.set("Max Value", maxVal[hs]);
1270 
1271  // Initialize parameters in xyce
1272  groupPtr_->computeF();
1273 
1274  // Do the continuation run
1276  locaStatus = stepperPtr_->run();
1277 
1278  // Kick out if continuation failed
1279  if (locaStatus != LOCA::Abstract::Iterator::Finished)
1280  return (-1);
1281 
1282  firstSolveComplete_ = true;
1283 
1284  // Copy out the solution and use it in the next run
1285  groupPtr_->copy(*(stepperPtr_->getSolutionGroup()));
1286  }
1287 
1288  // Return converged solver code
1289  return (paramsPtr->getStatusTestReturnCode());
1290 }
1291 
1292 //-----------------------------------------------------------------------------
1293 // Function : Interface::blockGainscaleMosfetSolve
1294 // Purpose :
1295 // Special Notes : This corresponds to
1296 // .options nonlin continuation=blockgain or
1297 // .options nonlin continuation=7
1298 // Scope : public
1299 // Creator : Roger Pawlowski, Eric Keiter
1300 // Creation Date :
1301 //-----------------------------------------------------------------------------
1303 {
1304  // Get some initial objects
1305  Teuchos::RCP<Teuchos::ParameterList> locaList = paramsPtr->getLocaParams();
1306  Teuchos::ParameterList& stepperList = locaList->sublist("Stepper");
1307  LOCA::ParameterVector locaPVec;
1308 
1309  // Create storage for continuation objects
1310  int numGainBlocks = loaderPtr_->getHomotopyBlockSize();
1311  int numHomotopyContinuationRuns = 1 + numGainBlocks;
1312  std::vector<std::string> names(numHomotopyContinuationRuns);
1313  std::vector<double> initialVal(numHomotopyContinuationRuns);
1314  std::vector<double> finalVal(numHomotopyContinuationRuns);
1315  std::vector<double> minVal(numHomotopyContinuationRuns);
1316  std::vector<double> maxVal(numHomotopyContinuationRuns);
1317 
1318  // Set up continuation steps
1319  // ***************************************************
1320  // Changes vals below for continuation
1321  // ***************************************************
1322  for (int i = 0; i < numGainBlocks; ++i) {
1323  std::stringstream s;
1324  s << i;
1325  names[i] = "mosfet:gainscale_block_" + s.str();
1326  initialVal[i] = 0.0;
1327  finalVal[i] = 1.0;
1328  }
1329  names[numHomotopyContinuationRuns - 1] = "mosfet:nltermscale";
1330  initialVal[numHomotopyContinuationRuns - 1] = 0.0;
1331  finalVal[numHomotopyContinuationRuns - 1] = 1.0;
1332  // ***************************************************
1333  // ***************************************************
1334 
1335  // Ste up max/min bounds
1336  for (int i = 0; i < names.size(); ++i) {
1337  if (finalVal[i] > initialVal[i]) {
1338  minVal[i] = initialVal[i];
1339  maxVal[i] = finalVal[i];
1340  }
1341  else {
1342  minVal[i] = finalVal[i];
1343  maxVal[i] = initialVal[i];
1344  }
1345  }
1346 
1347  // Initialize loca parameter vector
1348  for (int i = 0; i < names.size(); ++i)
1349  locaPVec.addParameter(names[i], initialVal[i]);
1350 
1351  LOCA::Abstract::Iterator::IteratorStatus locaStatus;
1352 
1353  // Loop over the number of homotopy steps
1354  for (int hs = 0; hs < names.size(); ++hs) {
1355  for (int i = 0; i < names.size(); ++i) {
1356  if (i >= hs)
1357  locaPVec.setValue(names[i], initialVal[i]);
1358  else
1359  locaPVec.setValue(names[i], finalVal[i]);
1360  }
1361  groupPtr_->setParams(locaPVec);
1362  stepperList.set("Continuation Parameter", names[hs]);
1363  stepperList.set("Initial Value", initialVal[hs]);
1364  stepperList.set("Min Value", minVal[hs]);
1365  stepperList.set("Max Value", maxVal[hs]);
1366 
1367  // Initialize parameters in xyce
1368  groupPtr_->computeF();
1369 
1370  // Do the continuation run
1372  locaStatus = stepperPtr_->run();
1373 
1374  // Kick out if continuation failed
1375  if (locaStatus != LOCA::Abstract::Iterator::Finished)
1376  return (-1);
1377 
1378  // Increment Param Number Tracking
1379  isFirstContinuationParam_ = false;
1380  firstSolveComplete_ = true;
1381 
1382  // Copy out the solution and use it in the next run
1383  groupPtr_->copy(*(stepperPtr_->getSolutionGroup()));
1384  }
1385 
1386  // Return converged solver code
1387  return (paramsPtr->getStatusTestReturnCode());
1388 }
1389 
1390 //-----------------------------------------------------------------------------
1391 // Function : Interface::gminSteppingSolve
1392 // Purpose :
1393 // Special Notes : This corresponds to
1394 // .options nonlin continuation=gmin or
1395 // .options nonlin continuation=3
1396 // Scope : public
1397 // Creator : Roger Pawlowski, Eric Keiter
1398 // Creation Date :
1399 //-----------------------------------------------------------------------------
1401 {
1402  Teuchos::RCP<Teuchos::ParameterList> locaList = paramsPtr->getLocaParams();
1403 
1404  // Create the continuation parameter names
1405  std::string gmin = "GSTEPPING";
1406 
1407  // Create Parameter Vector and get the stepper parameter list.
1408  LOCA::ParameterVector locaPVec;
1409  Teuchos::ParameterList& stepperList = locaList->sublist("Stepper");
1410  Teuchos::ParameterList& predictorList = locaList->sublist("Predictor");
1411  Teuchos::ParameterList& stepSizeList = locaList->sublist("Step Size");
1412 
1413  // Continuation solve using Gmin stepping.
1414  locaPVec.addParameter(gmin, 0.0);
1415  groupPtr_->setParams(locaPVec);
1416  stepperList.set("Continuation Parameter", gmin);
1417  stepperList.set("Continuation Method", "Natural");
1418 
1419  stepSizeList.set("Method", "Adaptive");
1420  predictorList.set("Method", "Constant");
1421 
1422  stepperList.set("Initial Value", 4.0);
1423  stepperList.set("Min Value", -4.0);
1424  paramsPtr->set_gstepping_min_value (-4.0);
1425  stepperList.set("Max Value", 4.0);
1426 
1427  stepSizeList.set("Initial Step Size", -2.0);
1428  stepSizeList.set("Min Step Size", 1.0e-6);
1429  stepSizeList.set("Max Step Size", 1.0e+12);
1430  stepSizeList.set("Aggressiveness", 0.01);
1431 
1432  stepperList.set("Max Steps", 400);
1433  stepperList.set("Max Nonlinear Iterations", 20);
1434 
1435  // the following set of if-statemtents call functions that
1436  // allocate augmented linear systems for various scenarios.
1437  // It is important that the augmented systems get allocated
1438  // after the paramter (above) have been set.
1439  bool usedOP=false;
1440  bool usedNODESET=false;
1441  bool usedIC=false;
1442 
1443  if ((usemode_) && (mode_ != Nonlinear::TRANSIENT))
1444  {
1445  if (ICspecified_)
1446  {
1447  usedIC=icCont3 (paramsPtr);
1448  }
1449  else if (NODESETspecified_)
1450  {
1451  usedNODESET=nodesetCont1 (paramsPtr);
1452  }
1453  else
1454  {
1455  usedOP = opStartCont1 (paramsPtr);
1456  }
1457  }
1458 
1459  // Initialize parameters in xyce
1460  if (!usedOP && !usedNODESET) // (usedOP and usedNODESET have already loaded F)
1461  {
1462  groupPtr_->computeF();
1463  }
1464 
1465  // Do the continuation run
1466  iParam_ = 0;
1467  if (iParam_ == 0 && DCOPused_)
1468  {
1469  std::string message = "'.dcop input=' and gstepping are incompatible";
1470  N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::USR_FATAL, message);
1471  }
1472  if (!usedIC)
1473  {
1474  Teuchos::RCP<AugmentLinSys> als =
1476  groupPtr_->setAugmentLinearSystem(true, als);
1477  }
1478 
1479  // Do the continuation run
1481  LOCA::Abstract::Iterator::IteratorStatus locaStatus = stepperPtr_->run();
1482 
1483  groupPtr_->setAugmentLinearSystem(false, Teuchos::null);
1484 
1485  // Kick out if continuation failed
1486  if (locaStatus != LOCA::Abstract::Iterator::Finished)
1487  return (-1);
1488  else
1489  return (paramsPtr->getStatusTestReturnCode());
1490 }
1491 
1492 //-----------------------------------------------------------------------------
1493 // Function : Interface::pseudoTransientSolve
1494 // Purpose :
1495 // Special Notes : This corresponds to
1496 // .options nonlin continuation=pseudo or
1497 // .options nonlin continuation=9
1498 // Scope :
1499 // Creator :
1500 // Creation Date :
1501 //-----------------------------------------------------------------------------
1503 {
1504  Teuchos::RCP<NOX::StatusTest::Combo> ctest =
1505  Teuchos::rcp(new NOX::StatusTest::Combo(NOX::StatusTest::Combo::OR));
1506 
1507  Teuchos::RCP<Teuchos::ParameterList> locaList =
1508  paramsPtr->getLocaParams();
1509  Teuchos::ParameterList& stepperList = locaList->sublist("Stepper");
1510  Teuchos::ParameterList& stepSizeList = locaList->sublist("Step Size");
1511  double initialStepSize =
1512  stepSizeList.get("Initial Step Size", 1.0e-3);
1513  double minStepSize = stepSizeList.get("Min Step Size", 1.0e-12);
1514  double maxStepSize = stepSizeList.get("Max Step Size", 1.0e4);
1515  Teuchos::RCP<Teuchos::ParameterList> noxList =
1516  paramsPtr->getNoxParams();
1517 
1518  // Create Pseudo Transient status tests.
1519  //paramsPtr->getStatusTests()
1520  Teuchos::RCP<NOX::StatusTest::MaxIters> mi =
1521  Teuchos::rcp(new NOX::StatusTest::MaxIters(stepperList.get("Max Steps", 200)));
1522  Teuchos::RCP<NOX::StatusTest::FiniteValue> fv =
1523  Teuchos::rcp(new NOX::StatusTest::FiniteValue);
1524  Teuchos::RCP<PseudoTransientTest> pt =
1525  Teuchos::rcp(new PseudoTransientTest(maxStepSize, 1.0e-8));
1526 
1527  ctest->addStatusTest(mi);
1528  ctest->addStatusTest(fv);
1529  ctest->addStatusTest(pt);
1530 
1531  // First solve - pseudo transient
1532 
1533  Teuchos::RCP<AugmentLinSys> als =
1535 
1536  solverPtr_ = Teuchos::rcp(new PseudoTransientBased(als,
1537  groupPtr_,
1538  ctest,
1539  noxList,
1540  initialStepSize,
1541  minStepSize,
1542  maxStepSize));
1543 
1544  NOX::StatusTest::StatusType status = solverPtr_->solve();
1545  firstSolveComplete_ = true;
1546 
1547  // RPP 3/7/2006: We don't care if pseudo transient solve fails the
1548  // solve() call above. This is just to get an inital guess for
1549  // the corrector step in the next solve. So we don't check the
1550  // status at this point.
1551 
1552  // Turn off pseudo transient in groups. (this is also done in the
1553  // pseudo transient solver, but just being safe - groups could be
1554  // different).
1555  groupPtr_->setAugmentLinearSystem(false, Teuchos::null);
1556 
1557  // Second solve is the correct steady state solve
1558  solverPtr_ = NOX::Solver::buildSolver(groupPtr_,
1559  paramsPtr->getStatusTests(),
1560  paramsPtr->getNoxParams());
1561  status = solverPtr_->solve();
1562 
1563  // Send back the correct return code
1564  return (paramsPtr->getStatusTestReturnCode());
1565 }
1566 
1567 //-----------------------------------------------------------------------------
1568 // Function : Interface::artificialParameterHomotopy
1569 // Purpose :
1570 // Special Notes : This corresponds to
1571 // .options nonlin continuation=art or
1572 // .options nonlin continuation=33
1573 // Scope :
1574 // Creator :
1575 // Creation Date :
1576 //-----------------------------------------------------------------------------
1578 {
1579 #ifdef Xyce_NOX_LOCA_ARTIFICIAL_HOMOTOPY_SUPPORT
1580  Teuchos::RCP<Teuchos::ParameterList> locaList = paramsPtr->getLocaParams();
1581  Teuchos::ParameterList& locaUtilsList = locaList->sublist("Utilities");
1582 
1583  Teuchos::RCP<LOCA::Homotopy::Group> hGrp =
1584  Teuchos::rcp(new LOCA::Homotopy::Group(*locaList, globalDataPtr_, groupPtr_, 1.0, 0.0));
1585 
1586  hGrp->computeF();
1587 
1588  locaList->sublist("Predictor").set("Secant", 0.999);
1589  locaList->sublist("Stepper").set("Max Value", 0.999);
1590 
1592 
1593  LOCA::Abstract::Iterator::IteratorStatus locaStatus = stepperPtr_->run();
1594  firstSolveComplete_ = true;
1595 
1596  Teuchos::RCP<LOCA::Homotopy::Group> hGrp2 =
1597  Teuchos::rcp(new LOCA::Homotopy::Group(*locaList, globalDataPtr_, groupPtr_, 0.1, 1.0));
1598 
1599  locaList->sublist("Predictor").set("Secant", 0.999);
1600  locaList->sublist("Stepper").set("Initial Value", 0.999);
1601  locaList->sublist("Stepper").set("Max Value", 1.0);
1602  locaList->sublist("Step Size").set("Method", "Constant");
1603  locaList->sublist("Step Size").set("Initial Step Size", 0.0001);
1604  locaList->sublist("Step Size").set("Min Step Size", 0.0001);
1605 
1607 
1608  locaStatus = stepperPtr_->run();
1609 
1610  // Return the solution status
1611  if (locaStatus != LOCA::Abstract::Iterator::Finished)
1612  return (-1);
1613  else
1614  return (paramsPtr->getStatusTestReturnCode());
1615 
1616 #else
1617  Report::UserFatal0() << "Nonlinear Solver (NOX::Interface) Artificial parameter continuation requires "
1618  << "building xyce with the define: -DXyce_NOX_LOCA_ARTIFICIAL_HOMOTOPY_SUPPORT to "
1619  << "allow LOCA to augment the diagonal of Jacobian! Either rebuild Xyce or do not "
1620  << "run Xyce with \"continuation=33\"";
1621  return -1;
1622 #endif
1623 }
1624 
1625 //-----------------------------------------------------------------------------
1626 // Function : Interface::sourceSteppingSolve
1627 // Purpose :
1628 // Special Notes : This corresponds to
1629 // .options nonlin continuation=sourcestep or
1630 // .options nonlin continuation=34
1631 // Scope : public
1632 // Creator : Tom Russo
1633 // Creation Date :
1634 //-----------------------------------------------------------------------------
1636 {
1637  Teuchos::RCP<Teuchos::ParameterList> locaList = paramsPtr->getLocaParams();
1638 
1639  // Create the continuation parameter names
1640  std::string vsrcscale = "VSRCSCALE";
1641 
1642  // Create Parameter Vector and get the stepper parameter list.
1643  LOCA::ParameterVector locaPVec;
1644  Teuchos::ParameterList& stepperList = locaList->sublist("Stepper");
1645  Teuchos::ParameterList& predictorList = locaList->sublist("Predictor");
1646  Teuchos::ParameterList& stepSizeList = locaList->sublist("Step Size");
1647 
1648  // Continuation solve using source stepping.
1649  locaPVec.addParameter(vsrcscale, 0.0);
1650  groupPtr_->setParams(locaPVec);
1651  stepperList.set("Continuation Parameter", vsrcscale);
1652  stepperList.set("Continuation Method", "Natural");
1653 
1654  stepSizeList.set("Method", "Adaptive");
1655  predictorList.set("Method", "Constant");
1656 
1657  stepperList.set("Initial Value", 0.0);
1658  stepperList.set("Min Value", -1.0);
1659  stepperList.set("Max Value", 1.0);
1660 
1661  stepSizeList.set("Initial Step Size", 0.2);
1662  stepSizeList.set("Min Step Size", 1.0e-4);
1663  stepSizeList.set("Max Step Size", 0.2);
1664  stepSizeList.set("Aggressiveness", 1.0);
1665 
1666  stepperList.set("Max Steps", 400);
1667  stepperList.set("Max Nonlinear Iterations", 20);
1668 
1669  // the following set of if-statemtents call functions that
1670  // allocate augmented linear systems for various scenarios.
1671  // It is important that the augmented systems get allocated
1672  // after the paramter (above) have been set.
1673  bool usedOP=false;
1674  bool usedNODESET=false;
1675  bool usedIC=false;
1676 
1677  if ((usemode_) && (mode_ != Nonlinear::TRANSIENT))
1678  {
1679  if (ICspecified_)
1680  {
1681  usedIC=icCont3 (paramsPtr);
1682  }
1683  else if (NODESETspecified_)
1684  {
1685  usedNODESET=nodesetCont1 (paramsPtr);
1686  }
1687  else
1688  {
1689  usedOP = opStartCont1 (paramsPtr);
1690  }
1691  }
1692 
1693  // Initialize parameters in xyce
1694  if (!usedOP && !usedNODESET) // (usedOP and usedNODESET have already loaded F)
1695  {
1696  groupPtr_->computeF();
1697  }
1698 
1699  // Do the continuation run
1701  LOCA::Abstract::Iterator::IteratorStatus locaStatus = stepperPtr_->run();
1702 
1703  groupPtr_->setAugmentLinearSystem(false, Teuchos::null);
1704 
1705  // Kick out if continuation failed
1706  if (locaStatus != LOCA::Abstract::Iterator::Finished)
1707  return (-1);
1708  else
1709  return (paramsPtr->getStatusTestReturnCode());
1710 }
1711 
1712 //-----------------------------------------------------------------------------
1713 // Function : Interface::solve
1714 //
1715 // Purpose : Reset all the counters and parameters and solve the
1716 // nonlinear problem for this time step. The solution is
1717 // stored in nextSolVector (obtained from the N_LAS_System
1718 // registered above by registerLinearSystem).
1719 //
1720 // Special Notes : Should not be called until *after* initializeAll() has
1721 // been called.
1722 //
1723 // Return Type : Integer - postive for sucess, negative for failure.
1724 // Special Notes :
1725 // Scope : public
1726 // Creator : Roger Pawlowski, SNL 9233
1727 // Creation Date :
1728 //-----------------------------------------------------------------------------
1730 {
1731 
1732  try
1733  {
1734  // For base object
1736 
1737  if (DEBUG_NONLINEAR)
1739 
1740  // Setup the status tests
1741  if (Teuchos::is_null(locaStatusTestPtr_))
1742  {
1744  Teuchos::rcp(new LOCA::StatusTest::Wrapper(dcParams_.getStatusTests()));
1746  Teuchos::rcp(new LOCA::StatusTest::Wrapper(transientParams_.getStatusTests()));
1748  Teuchos::rcp(new LOCA::StatusTest::Wrapper(hbParams_.getStatusTests()));
1749 
1750  }
1751 
1752  // Pick the parameter set to use.
1753  ParameterSet* paramsPtr;
1754  if ((usemode_) && (mode_ == Nonlinear::TRANSIENT))
1755  {
1756  paramsPtr = &transientParams_;
1760  }
1761  else if ((usemode_) && (mode_ == Nonlinear::HB_MODE))
1762  {
1763  paramsPtr = &hbParams_;
1767  }
1768  else
1769  {
1770  paramsPtr = &dcParams_;
1774  }
1775 
1776  if (Teuchos::is_null(globalDataPtr_))
1777  {
1778  globalDataPtr_ = LOCA::createGlobalData(paramsPtr->getAllParams());
1779  }
1780 
1781  // set the xyce return codes:
1782  paramsPtr->setStatusTestReturnCodes(retCodes_);
1783 
1784  // Set up the shared system (we have to redo this every time because
1785  // the object pointed to by nextSolVectorPtrPtr may have changed.
1786  //delete sharedSystemPtr_;
1787  if (sharedSystemPtr_ == 0)
1789  *rhsVectorPtr_,
1792  *gradVectorPtr_,
1793  *lasSysPtr_,
1794  *this);
1795  else
1797  *rhsVectorPtr_,
1800  *gradVectorPtr_,
1801  *lasSysPtr_,
1802  *this);
1803 
1804  //////////////////////////////////////////////////////////////////////////
1805  // erkeite: Group handling required by 2-level Newton:
1806  // Reset up the corresponding group as well
1807  if (nlsTmpPtr==0)
1808  {
1809  if (Teuchos::is_null(groupPtr_))
1810  {
1811  groupPtr_ = Teuchos::rcp(new N_NLS_LOCA::Group(globalDataPtr_,
1813  getLoader(),
1814  *outMgrPtr_,
1816  );
1817  }
1818  else
1819  {
1821  groupPtr_->setX(tmpVec);
1822  }
1823  }
1824  else
1825  {
1826  copiedGroupFlag_ = true;
1827  Interface * nlsOtherPtr = dynamic_cast<Interface*>(nlsTmpPtr);
1828  groupPtr_ = nlsOtherPtr->getSolutionGroup();
1829  }
1830  // End of block needed by 2-level Newton.
1831  //////////////////////////////////////////////////////////////////////////
1832 
1833  int solverType = paramsPtr->getNoxSolverType();
1834  bool continuationSpecified = paramsPtr->getContinuationSpecifiedFlag();
1835 
1836  if (mode_ == Nonlinear::DC_OP && !continuationSpecified)
1837  {
1838  return spiceStrategy(paramsPtr);
1839  }
1840  else
1841  {
1842 
1843  // Setting the nonContinuation flag is required to prevent incorrect
1844  // Device::DeviceMgr::setParam calls.
1845  if (solverType==0)
1846  {
1847  groupPtr_->setNonContinuationFlag (true);
1848  }
1849  else
1850  {
1851  groupPtr_->setNonContinuationFlag (false);
1852  }
1853 
1854  if (DEBUG_NONLINEAR)
1855  dout() << "solverType is " << solverType << std::endl;
1856 
1857  // (0) Standard Newton Method Solve (includes line search and
1858  // trust region based methods
1859  if (solverType == 0)
1860  {
1861  return stdNewtonSolve(paramsPtr);
1862  }
1863  // (1) Natural Parameter Continuation
1864  else if (solverType == 1)
1865  {
1866  return naturalParameterContinuationSolve ( paramsPtr );
1867  }
1868  // (2) Mosfet specific continuation
1869  else if (solverType == 2)
1870  {
1871  return mosfetContinuationSolve ( paramsPtr );
1872  }
1873  else if (solverType == 3) // GMIN stepping, simple specification
1874  {
1875  return gminSteppingSolve ( paramsPtr );
1876  }
1877  // (4) Mosfet specific continuation (ERK, new 2/21/2004)
1878  else if (solverType == 4)
1879  {
1880  return mosfetContinuationSolve2 (paramsPtr);
1881  }
1882  // (5) Mosfet:BSIM3:Inverter specific continuation (RPP, new 2/25/2004)
1883  else if (solverType == 5)
1884  {
1885  return mosfetContinuationSolve3 (paramsPtr);
1886  }
1887  // (6) Mosfet:BSIM3:Inverter specific continuation (RPP, new 2/25/2004)
1888  else if (solverType == 6)
1889  {
1890  return mosfetContinuationSolve4 (paramsPtr);
1891  } // Block gainscale
1892  else if (solverType == 7)
1893  {
1894  return blockGainscaleMosfetSolve ( paramsPtr );
1895  } // Test suite
1896  else if (solverType == 8)
1897  {
1898  return mosfetContinuationSolve5 (paramsPtr);
1899  } // Pseudo Transient
1900  else if (solverType == 9)
1901  {
1902  return pseudoTransientSolve( paramsPtr );
1903  } // continuation = 4 + power node
1904  else if (solverType == 10)
1905  {
1906  return mosfetContinuationSolve6 (paramsPtr);
1907  }
1908  else if (solverType == 33) // artificial parameter
1909  {
1910  return artificialParameterHomotopy (paramsPtr);
1911  }
1912  else if (solverType == 34) // source stepping, simple specification
1913  {
1914  return sourceSteppingSolve ( paramsPtr );
1915  }// End of if (solverType == )
1916  }
1917  } // try
1918  catch (const char* error_msg) {
1919  std::string nox_error = "NOX Error";
1920  std::string err_msg = std::string(error_msg);
1921  if (err_msg == nox_error) {
1922  const std::string message =
1923  "Caught a NOX Exception in Interface::solve()!";
1924  N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::DEV_FATAL, message);
1925  }
1926  else // Otherwise, rethrow...
1927  throw;
1928  }
1929 #ifndef Xyce_CHARON
1930  catch (const std::exception& e) {
1931  dout() << e.what() << std::endl;
1932  const std::string message =
1933  "Caught std::exception in Interface::solve()!";
1934  N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::DEV_FATAL, message);
1935  }
1936  catch (...) {
1937  const std::string message =
1938  "Caught Unknown Exception in Interface::solve()!";
1939  N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::DEV_FATAL, message);
1940  }
1941 #endif
1942 
1943  // Should never get this far
1944  return -1;
1945 }
1946 
1947 
1948 //-----------------------------------------------------------------------------
1949 // Function : Interface::opStartCont1
1950 // Purpose :
1951 // Special Notes : returns true if DCOP restart is being used.
1952 //
1953 // The "found" variable indicates if any of the nodes specified
1954 // in the dcop start file were found in this circuit. If not,
1955 // then don't bother with this.
1956 //
1957 // Scope : public
1958 // Creator : Eric R. Keiter, SNL, Electrical and Microsystem Modeling
1959 // Creation Date : 09/15/07
1960 //-----------------------------------------------------------------------------
1962 {
1963  bool usedOP(false);
1964 
1965 #ifdef Xyce_DEBUG_OP_START
1966  dout() << "NOX_Interface: Inside continuation=1 OP_START code (case 2)" << std::endl;
1967 #endif
1968  if (!DCOPused_)
1969  {
1970  int found = 0;
1971  int icType;
1972  IO::InitialConditionsData::NodeNamePairMap & op = initialConditionsManager_->getICData(found, icType);
1973  const NodeNameMap & allNodes = outMgrPtr_->getSolutionNodeMap();
1974  N_PDS_Comm * pdsCommPtr = pdsMgrPtr_->getPDSComm();
1975 
1976  if (found > 0 && icType == IO::InitialConditionsData::IC_TYPE_DCOP_RESTART)
1977  {
1978  DCOPused_ = true;
1979  usedOP = true;
1980  // Set up nox nonlinear solver
1981  if (Teuchos::is_null(solverPtr_))
1982  {
1983  solverPtr_ = NOX::Solver::buildSolver(groupPtr_,
1984  paramsPtr->getStatusTests(),
1985  paramsPtr->getNoxParams());
1986  }
1987 
1988  Teuchos::RCP<AugmentLinSys> als =
1989  paramsPtr->createAugmentLinearSystem(lasSysPtr_, op, allNodes, pdsCommPtr);
1990 
1991  groupPtr_->setAugmentLinearSystem(true, als);
1992  NOX::StatusTest::StatusType status = solverPtr_->solve();
1993 
1994  firstSolveComplete_ = true;
1995  groupPtr_->setAugmentLinearSystem(false, Teuchos::null);
1997 
1998 #ifdef Xyce_DEBUG_OP_START
1999  // DNS: Uncommenting this will set debug output of linear system for every step
2000 #ifdef Xyce_PARALLEL_MPI
2001  groupPtr_->setOutputLinear (&op, &allNodes, pdsCommPtr);
2002 #else
2003  groupPtr_->setOutputLinear (&op, &allNodes);
2004 #endif
2005 #endif // debug op start
2006 
2007  }
2008  }
2009  return usedOP;
2010 }
2011 
2012 //-----------------------------------------------------------------------------
2013 // Function : Interface::icCont
2014 // Purpose :
2015 // Special Notes : returns true if IC is being used.
2016 //
2017 // The "found" variable indicates if any of the nodes specified
2018 // in the dcop start file were found in this circuit. If not,
2019 // then don't bother with this.
2020 //
2021 // Scope : public
2022 // Creator : Eric R. Keiter, SNL, Electrical and Microsystem Modeling
2023 // Creation Date : 09/15/07
2024 //-----------------------------------------------------------------------------
2026 {
2027  bool usedIC(false);
2028 
2029 #ifdef Xyce_DEBUG_IC
2030  dout() << "NOX_Interface: Inside continuation=0 .IC code." << std::endl;
2031 #endif
2032  int found = 0;
2033  int icType;
2034  IO::InitialConditionsData::NodeNamePairMap & op = initialConditionsManager_->getICData(found, icType);
2035 
2036  usedIC = (icType==IO::InitialConditionsData::IC_TYPE_IC && found > 0);
2037  if (usedIC)
2038  {
2039  bool useGminStepping=false;
2040  Teuchos::RCP<AugmentLinSys> als =
2041  paramsPtr->createAugmentLinearSystem(lasSysPtr_, op, useGminStepping);
2042  groupPtr_->setAugmentLinearSystem(true, als);
2043  }
2044  return usedIC;
2045 }
2046 
2047 //-----------------------------------------------------------------------------
2048 // Function : Interface::icCont3
2049 // Purpose : IC with gmin stepping
2050 // Special Notes : returns true if IC is being used.
2051 //
2052 // The "found" variable indicates if any of the nodes specified
2053 // in the dcop start file were found in this circuit. If not,
2054 // then don't bother with this.
2055 //
2056 // Scope : public
2057 // Creator : Eric R. Keiter, SNL
2058 // Creation Date : 04/29/2012
2059 //-----------------------------------------------------------------------------
2061 {
2062  bool usedIC(false);
2063 
2064 #ifdef Xyce_DEBUG_IC
2065  dout() << "NOX_Interface: Inside continuation=3 .IC code." << std::endl;
2066 #endif
2067  int found = 0;
2068  int icType;
2069  IO::InitialConditionsData::NodeNamePairMap & op = initialConditionsManager_->getICData(found, icType);
2070 
2071  usedIC = (icType==IO::InitialConditionsData::IC_TYPE_IC && found > 0);
2072  if (usedIC)
2073  {
2074  bool useGminStepping=true;
2075  Teuchos::RCP<AugmentLinSys> als =
2076  paramsPtr->createAugmentLinearSystem(lasSysPtr_, op, useGminStepping);
2077  groupPtr_->setAugmentLinearSystem(true, als);
2078  }
2079  return usedIC;
2080 }
2081 
2082 //-----------------------------------------------------------------------------
2083 // Function : Interface::nodesetCont0
2084 // Purpose :
2085 // Special Notes : returns true if is being used.
2086 // Scope : public
2087 // Creator : Eric R. Keiter, SNL, Electrical and Microsystem Modeling
2088 // Creation Date : 09/15/07
2089 //-----------------------------------------------------------------------------
2091 {
2092  bool usedNODESET(false);
2093 
2094 #ifdef Xyce_DEBUG_IC
2095  dout() << "NOX_Interface: Inside continuation=0 .NODESET code (case 1)" << std::endl;
2096 #endif
2097  int found = 0;
2098  int icType;
2099  IO::InitialConditionsData::NodeNamePairMap & op = initialConditionsManager_->getICData(found, icType);
2100 
2101  usedNODESET = (icType==IO::InitialConditionsData::IC_TYPE_NODESET && found > 0);
2102  if (usedNODESET)
2103  {
2104  Teuchos::RCP<AugmentLinSys> als =
2105  paramsPtr->createAugmentLinearSystem(lasSysPtr_, op);
2106 
2107  groupPtr_->setAugmentLinearSystem(true, als);
2108  NOX::StatusTest::StatusType status = solverPtr_->solve();
2109 
2110  // Create a reset solver after performing the initial nodeset solve.
2111  groupPtr_->setAugmentLinearSystem(false, Teuchos::null);
2112  solverPtr_->reset(groupPtr_->getX());
2114  firstSolveComplete_ = true;
2115  }
2116  return usedNODESET;
2117 }
2118 
2119 
2120 //-----------------------------------------------------------------------------
2121 // Function : Interface::nodesetCont1
2122 // Purpose :
2123 // Special Notes : returns true if .NODESET is being used.
2124 // Scope : public
2125 // Creator : Eric R. Keiter, SNL, Electrical and Microsystem Modeling
2126 // Creation Date : 09/15/07
2127 //-----------------------------------------------------------------------------
2129 {
2130  bool usedNODESET(false);
2131 
2132 #ifdef Xyce_DEBUG_IC
2133  dout() << "NOX_Interface: Inside continuation=1 .NODESET code (case 2)" << std::endl;
2134 #endif
2135 
2136  int found = 0;
2137  int icType;
2138  IO::InitialConditionsData::NodeNamePairMap & op = initialConditionsManager_->getICData(found, icType);
2139 
2140  usedNODESET = (icType==IO::InitialConditionsData::IC_TYPE_NODESET && found > 0);
2141  if (usedNODESET)
2142  {
2143  // Set up nox nonlinear solver
2144  if (Teuchos::is_null(solverPtr_))
2145  {
2146  solverPtr_ = NOX::Solver::buildSolver(groupPtr_,
2147  paramsPtr->getStatusTests(),
2148  paramsPtr->getNoxParams());
2149  }
2150 
2151  Teuchos::RCP<AugmentLinSys> als =
2152  paramsPtr->createAugmentLinearSystem(lasSysPtr_, op);
2153 
2154  groupPtr_->setAugmentLinearSystem(true, als);
2155  NOX::StatusTest::StatusType status = solverPtr_->solve();
2156 
2157  firstSolveComplete_ = true;
2158  groupPtr_->setAugmentLinearSystem(false, Teuchos::null);
2160  }
2161  return usedNODESET;
2162 }
2163 
2164 //-----------------------------------------------------------------------------
2165 // Function : Interface::takeFirstSolveStep
2166 // Purpose : same as Interface::solve, except that solverPtr_->iterate is
2167 // called instead of solverPtr_->solve.
2168 // Special Notes :
2169 // Scope : public
2170 // Creator :
2171 // Creation Date :
2172 //-----------------------------------------------------------------------------
2174 {
2175  // For base object
2177 
2178  // Pick the parameter set to use.
2179  ParameterSet* paramsPtr;
2180  if ((usemode_) && (mode_ == Nonlinear::TRANSIENT))
2181  paramsPtr = &transientParams_;
2182  else if ((usemode_) && (mode_ == Nonlinear::HB_MODE))
2183  paramsPtr = &hbParams_;
2184  else
2185  paramsPtr = &dcParams_;
2186 
2187  // set the xyce return codes:
2188  paramsPtr->setStatusTestReturnCodes(retCodes_);
2189 
2190  if (Teuchos::is_null(globalDataPtr_))
2191  globalDataPtr_ = LOCA::createGlobalData(paramsPtr->getAllParams());
2192 
2193  // Set up the shared system (we have to redo this every time because
2194  // the object pointed to by nextSolVectorPtrPtr may have changed.
2195  delete sharedSystemPtr_;
2196  sharedSystemPtr_ = new SharedSystem(**nextSolVectorPtrPtr_,
2197  *rhsVectorPtr_,
2200  *gradVectorPtr_,
2201  *lasSysPtr_,
2202  *this);
2203 
2204  // Reset up the corresponding group as well
2205  //delete groupPtr_;
2206  if (nlsTmpPtr==0)
2207  {
2208  if (Teuchos::is_null(groupPtr_))
2209  {
2210  dout() << "takeFirstSolveStep: allocating a new group!" << std::endl;
2211  groupPtr_ = Teuchos::rcp(new N_NLS_LOCA::Group(globalDataPtr_,
2212  *sharedSystemPtr_,
2213  getLoader(),
2214  *outMgrPtr_,
2215  getAnalysisManager()));
2216  }
2217  else
2218  {
2219  dout() << "takeFirstSolveStep: using the old group!" << std::endl;
2221  groupPtr_->setX(tmpVec);
2222  }
2223  }
2224  else
2225  {
2226  dout() << "takeFirstSolveStep: copying over the passed group!" << std::endl;
2227  copiedGroupFlag_ = true;
2228  Interface * nlsOtherPtr = dynamic_cast<Interface*>(nlsTmpPtr);
2229  groupPtr_ = nlsOtherPtr->getSolutionGroup();
2230  }
2231 
2232  // Set up solver
2233  if (Teuchos::is_null(solverPtr_))
2234  solverPtr_ = NOX::Solver::buildSolver(groupPtr_,
2235  paramsPtr->getStatusTests(),
2236  paramsPtr->getNoxParams());
2237  else
2238  solverPtr_->reset(groupPtr_->getX());
2239 
2240  // Solve
2241  NOX::StatusTest::StatusType status = solverPtr_->step();
2242 
2243  // Return the solution status
2244  return (status == NOX::StatusTest::Converged) ? 1 : -1;
2245 }
2246 
2247 //-----------------------------------------------------------------------------
2248 // Function : Interface::takeOneSolveStep
2249 // Purpose : same as Interface::takeFirstSolveStep, except that none of the
2250 // set up stuff (like allocating the solverPtr) is done here.
2251 // Special Notes :
2252 // Scope : public
2253 // Creator :
2254 // Creation Date :
2255 //-----------------------------------------------------------------------------
2257 {
2258  // Solve
2259  NOX::StatusTest::StatusType status = solverPtr_->step();
2260 
2261  // Return the solution status
2262  return (status == NOX::StatusTest::Converged) ? 1 : -1;
2263 }
2264 
2265 //-----------------------------------------------------------------------------
2266 // Function : Interface::getNumIterations
2267 // Purpose :
2268 // Special Notes :
2269 // Return Type : Integer (current number of nonlinear iterations)
2270 // Scope : public
2271 // Creator :
2272 // Creation Date :
2273 //-----------------------------------------------------------------------------
2275 {
2276  // Pick the parameter set to use.
2277  const ParameterSet* paramsPtr;
2278  if ((usemode_) && (mode_ == Nonlinear::TRANSIENT))
2279  paramsPtr = &transientParams_;
2280  else if ((usemode_) && (mode_ == Nonlinear::HB_MODE))
2281  paramsPtr = &hbParams_;
2282  else
2283  paramsPtr = &dcParams_;
2284 
2285  int solverType = paramsPtr->getNoxSolverType();
2286 
2287  if ((!Teuchos::is_null(solverPtr_)) && (solverType == 0))
2288  return solverPtr_->getNumIterations();
2289  else if ((!Teuchos::is_null(solverPtr_)) && (solverType == 1))
2290  return solverPtr_->getNumIterations();
2291  else if ((!Teuchos::is_null(solverPtr_)) && (solverType == 9))
2292  return solverPtr_->getNumIterations();
2293  else if ((!Teuchos::is_null(stepperPtr_)) && (solverType != 0))
2294  {
2295  return stepperPtr_->getSolver()->getNumIterations();
2296  }
2297 
2298  // Sometimes this is called before solve() itself, in which calse
2299  // the solverPtr_ has not yet been initialized, so we just return 0.
2300  return 0;
2301 }
2302 
2303 //-----------------------------------------------------------------------------
2304 // Function : Interface::getMaxNormF() const
2305 // Purpose :
2306 // Special Notes :
2307 // Return Type : double (norm of F)
2308 // Scope : public
2309 // Creator :
2310 // Creation Date :
2311 //-----------------------------------------------------------------------------
2313 {
2314  // Pick the parameter set to use.
2315  const ParameterSet* paramsPtr;
2316  if ((usemode_) && (mode_ == Nonlinear::TRANSIENT))
2317  {
2318  paramsPtr = &transientParams_;
2319  }
2320  else if ((usemode_) && (mode_ == Nonlinear::HB_MODE))
2321  {
2322  paramsPtr = &hbParams_;
2323  }
2324  else
2325  {
2326  paramsPtr = &dcParams_;
2327  }
2328 
2329  double maxNormF = paramsPtr->getMaxNormF();
2330  return maxNormF;
2331 }
2332 
2333 
2334 //-----------------------------------------------------------------------------
2335 // Function : Interface::getMaxNormFindex() const
2336 // Purpose :
2337 // Special Notes :
2338 // Return Type : int (vector index norm of F)
2339 // Scope : public
2340 // Creator :
2341 // Creation Date :
2342 //-----------------------------------------------------------------------------
2344 {
2345  // Pick the parameter set to use.
2346  const ParameterSet* paramsPtr;
2347  if ((usemode_) && (mode_ == Nonlinear::TRANSIENT))
2348  {
2349  paramsPtr = &transientParams_;
2350  }
2351  else if ((usemode_) && (mode_ == Nonlinear::HB_MODE))
2352  {
2353  paramsPtr = &hbParams_;
2354  }
2355  else
2356  {
2357  paramsPtr = &dcParams_;
2358  }
2359 
2360  int maxNormFindex = paramsPtr->getMaxNormFindex();
2361  return maxNormFindex;
2362 }
2363 
2364 //-----------------------------------------------------------------------------
2365 // Function : Interface::getDebugLevel
2366 // Purpose :
2367 // Special Notes :
2368 // Scope : public
2369 // Creator : Eric Keiter, SNL
2370 // Creation Date : 9/17/2007
2371 //-----------------------------------------------------------------------------
2373 {
2374  const ParameterSet* paramsPtr;
2375  if ((usemode_) && (mode_ == Nonlinear::TRANSIENT))
2376  {
2377  paramsPtr = &transientParams_;
2378  }
2379  else if ((usemode_) && (mode_ == Nonlinear::HB_MODE))
2380  {
2381  paramsPtr = &hbParams_;
2382  }
2383  else
2384  {
2385  paramsPtr = &dcParams_;
2386  }
2387 
2388  return (paramsPtr->getDebugLevel());
2389 }
2390 
2391 //-----------------------------------------------------------------------------
2392 // Function : Interface::getScreenOutputFlag
2393 // Purpose :
2394 // Special Notes :
2395 // Scope : public
2396 // Creator : Eric Keiter, SNL
2397 // Creation Date : 9/17/2007
2398 //-----------------------------------------------------------------------------
2400 {
2401  const ParameterSet* paramsPtr;
2402  if ((usemode_) && (mode_ == Nonlinear::TRANSIENT))
2403  {
2404  paramsPtr = &transientParams_;
2405  }
2406  else if ((usemode_) && (mode_ == Nonlinear::HB_MODE))
2407  {
2408  paramsPtr = &hbParams_;
2409  }
2410  else
2411  {
2412  paramsPtr = &dcParams_;
2413  }
2414 
2415  return (paramsPtr->getScreenOutputFlag());
2416 }
2417 
2418 //-----------------------------------------------------------------------------
2419 // Function : Interface::getDebugMinTime
2420 // Purpose :
2421 // Special Notes :
2422 // Scope : public
2423 // Creator : Eric Keiter, SNL
2424 // Creation Date : 9/17/2007
2425 //-----------------------------------------------------------------------------
2427 {
2428  const ParameterSet* paramsPtr;
2429  if ((usemode_) && (mode_ == Nonlinear::TRANSIENT))
2430  {
2431  paramsPtr = &transientParams_;
2432  }
2433  else if ((usemode_) && (mode_ == Nonlinear::HB_MODE))
2434  {
2435  paramsPtr = &hbParams_;
2436  }
2437  else
2438  {
2439  paramsPtr = &dcParams_;
2440  }
2441 
2442  return (paramsPtr->getDebugMinTime());
2443 }
2444 
2445 //-----------------------------------------------------------------------------
2446 // Function : Interface::getDebugMaxTime
2447 // Purpose :
2448 // Special Notes :
2449 // Scope : public
2450 // Creator : Eric Keiter, SNL
2451 // Creation Date : 9/17/2007
2452 //-----------------------------------------------------------------------------
2454 {
2455  const ParameterSet* paramsPtr;
2456  if ((usemode_) && (mode_ == Nonlinear::TRANSIENT))
2457  {
2458  paramsPtr = &transientParams_;
2459  }
2460  else if ((usemode_) && (mode_ == Nonlinear::HB_MODE))
2461  {
2462  paramsPtr = &hbParams_;
2463  }
2464  else
2465  {
2466  paramsPtr = &dcParams_;
2467  }
2468 
2469  return (paramsPtr->getDebugMaxTime());
2470 }
2471 
2472 //-----------------------------------------------------------------------------
2473 // Function : Interface::getDebugMinTimeStep
2474 // Purpose :
2475 // Special Notes :
2476 // Scope : public
2477 // Creator : Eric Keiter, SNL
2478 // Creation Date : 9/17/2007
2479 //-----------------------------------------------------------------------------
2481 {
2482  const ParameterSet* paramsPtr;
2483  if ((usemode_) && (mode_ == Nonlinear::TRANSIENT))
2484  {
2485  paramsPtr = &transientParams_;
2486  }
2487  else if ((usemode_) && (mode_ == Nonlinear::HB_MODE))
2488  {
2489  paramsPtr = &hbParams_;
2490  }
2491  else
2492  {
2493  paramsPtr = &dcParams_;
2494  }
2495 
2496  return (paramsPtr->getDebugMinTimeStep());
2497 }
2498 
2499 //-----------------------------------------------------------------------------
2500 // Function : Interface::getDebugMaxTimeStep
2501 // Purpose :
2502 // Special Notes :
2503 // Scope : public
2504 // Creator : Eric Keiter, SNL
2505 // Creation Date : 9/17/2007
2506 //-----------------------------------------------------------------------------
2508 {
2509  const ParameterSet* paramsPtr;
2510  if ((usemode_) && (mode_ == Nonlinear::TRANSIENT))
2511  {
2512  paramsPtr = &transientParams_;
2513  }
2514  else if ((usemode_) && (mode_ == Nonlinear::HB_MODE))
2515  {
2516  paramsPtr = &hbParams_;
2517  }
2518  else
2519  {
2520  paramsPtr = &dcParams_;
2521  }
2522 
2523  return (paramsPtr->getDebugMaxTimeStep());
2524 }
2525 
2526 //-----------------------------------------------------------------------------
2527 // Function : Interface::getMMFormat
2528 // Purpose :
2529 // Special Notes :
2530 // Scope : public
2531 // Creator : Eric Keiter, SNL
2532 // Creation Date : 3/2/2011
2533 //-----------------------------------------------------------------------------
2535 {
2536  return false;
2537 }
2538 
2539 //-----------------------------------------------------------------------------
2540 // Function : Interface::isFirstContinuationParam
2541 // Purpose :
2542 // Special Notes :
2543 // Scope : public
2544 // Creator :
2545 // Creation Date :
2546 //-----------------------------------------------------------------------------
2548 {
2550 }
2551 
2552 //-----------------------------------------------------------------------------
2553 // Function : Interface::isFirstSolveComplete
2554 // Purpose :
2555 // Special Notes :
2556 // Scope : public
2557 // Creator :
2558 // Creation Date :
2559 //-----------------------------------------------------------------------------
2561 {
2562  return firstSolveComplete_;
2563 }
2564 
2565 //-----------------------------------------------------------------------------
2566 // Function : Interface::getContinuationStep
2567 // Purpose :
2568 // Special Notes :
2569 // Scope : public
2570 // Creator :
2571 // Creation Date :
2572 //-----------------------------------------------------------------------------
2574 {
2575  if (!Teuchos::is_null(stepperPtr_))
2576  {
2577  return stepperPtr_->getStepNumber();
2578  }
2579  return 0;
2580 }
2581 
2582 //-----------------------------------------------------------------------------
2583 // Function : Interface::getContinuationStep
2584 // Purpose :
2585 // Special Notes :
2586 // Scope : public
2587 // Creator :
2588 // Creation Date :
2589 //-----------------------------------------------------------------------------
2591 {
2592  return iParam_;
2593 }
2594 
2595 //-----------------------------------------------------------------------------
2596 // Function : Interface::setAnalysisMode
2597 //
2598 // Purpose : Specify the analysis mode to be used by the nonlinear
2599 // solver in the next call to solve(). This *may* affect
2600 // the parameters used by the solver.
2601 //
2602 // See Also : setOptions, setTranOptions
2603 //
2604 // - Input Arguments -
2605 //
2606 // mode : Mode to be used in the next nonlinear solve.
2607 // Special Notes :
2608 // Scope : public
2609 // Creator :
2610 // Creation Date :
2611 //-----------------------------------------------------------------------------
2613 {
2614  mode_ = mode;
2615 }
2616 
2617 //-----------------------------------------------------------------------------
2618 // Function : Interface::resetAll
2619 // Purpose : This is used when Xyce is doing a STEP loop, and
2620 // needs to act like it is at the beginning of a transient
2621 // simulation again, for the next parameter in the STEP loop.
2622 // Special Notes :
2623 // Scope : public
2624 // Creator : Eric Keiter
2625 // Creation Date :
2626 //-----------------------------------------------------------------------------
2628 {
2629  setAnalysisMode(mode);
2630 }
2631 
2632 //-----------------------------------------------------------------------------
2633 // Function : Interface::copySolnVectors()
2634 //
2635 // Purpose : To be called at the beginning of each nonlinear
2636 // iteration. It equates the tmp and next vectors as
2637 // well as some special hidden vectors.
2638 //
2639 // See Also : setX0_
2640 // Special Notes :
2641 // Scope : public
2642 // Creator :
2643 // Creation Date :
2644 //-----------------------------------------------------------------------------
2646 {
2648  return true;
2649 }
2650 
2651 //-----------------------------------------------------------------------------
2652 // Function : Interface::getMatrixFreeFlag()
2653 //
2654 // Purpose :
2655 // See Also :
2656 // Special Notes :
2657 // Scope : public
2658 // Creator : Todd Coffey, Ting Mei
2659 // Creation Date : 07/29/08
2660 //-----------------------------------------------------------------------------
2662 {
2664 }
2665 
2666 //-----------------------------------------------------------------------------
2667 // Function : Interface::computeF()
2668 // Purpose :
2669 // Special Notes :
2670 // Scope : public
2671 // Creator :
2672 // Creation Date :
2673 //-----------------------------------------------------------------------------
2675 {
2677 }
2678 
2679 //-----------------------------------------------------------------------------
2680 // Function : Interface::computeNewton
2681 // Purpose : Set up the parameters for the linear solver and then
2682 // call newton_()
2683 // Special Notes :
2684 // Scope : public
2685 // Creator :
2686 // Creation Date :
2687 //-----------------------------------------------------------------------------
2688 bool Interface::computeNewton(Teuchos::ParameterList& params)
2689 {
2691  {
2692  lasSolverPtr_->setTolerance(params.get("Tolerance", 1.0e-12));
2693  }
2695  {
2696  lasSolverPtr_->setTolerance(params.get("Tolerance", 1.0e-12));
2697  }
2698 
2700 }
2701 
2702 //-----------------------------------------------------------------------------
2703 // Function : Interface::computeJacobian()
2704 // Purpose :
2705 // Special Notes :
2706 // Scope : public
2707 // Creator :
2708 // Creation Date :
2709 //-----------------------------------------------------------------------------
2711 {
2712  bool status = Nonlinear::NonLinearSolver::jacobian_();
2713  return status;
2714 }
2715 
2716 //-----------------------------------------------------------------------------
2717 // Function : Interface::applyJacobian(const N_LAS_Vector& input, N_LAS_Vector& result)
2718 // Purpose :
2719 // Special Notes :
2720 // Scope : public
2721 // Creator :
2722 // Creation Date :
2723 //-----------------------------------------------------------------------------
2724 bool Interface::applyJacobian(const Linear::Vector& input, Linear::Vector& result)
2725 {
2726  return Nonlinear::NonLinearSolver::applyJacobian(input,result);
2727 }
2728 
2729 //-----------------------------------------------------------------------------
2730 // Function : Interface::computeGradient()
2731 // Purpose :
2732 // Special Notes :
2733 // Scope : public
2734 // Creator :
2735 // Creation Date :
2736 //-----------------------------------------------------------------------------
2738 {
2739  bool status = Nonlinear::NonLinearSolver::gradient_();
2740  return status;
2741 }
2742 
2743 //-----------------------------------------------------------------------------
2744 // Function : Interface::getSolutionGroup
2745 // Purpose :
2746 // Special Notes :
2747 // Scope : public
2748 // Creator :
2749 // Creation Date :
2750 //-----------------------------------------------------------------------------
2751 Teuchos::RCP<N_NLS_LOCA::Group> Interface::getSolutionGroup ()
2752 {
2753  return groupPtr_;
2754 }
2755 
2756 //-----------------------------------------------------------------------------
2757 // Function : Interface::getLoader
2758 //
2759 // Purpose : LOCA needs access to loader to set parameters
2760 //
2761 // Special Notes :
2762 // Scope : public
2763 // Creator :
2764 // Creation Date :
2765 //-----------------------------------------------------------------------------
2767 {
2768  return *loaderPtr_;
2769 }
2770 
2771 //-----------------------------------------------------------------------------
2772 // Function : Interface::resetStepper
2773 // Purpose :
2774 // Special Notes :
2775 // Scope : public
2776 // Creator :
2777 // Creation Date :
2778 //-----------------------------------------------------------------------------
2779 void Interface::resetStepper(const Teuchos::RCP<LOCA::GlobalData>& gd,
2780  const Teuchos::RCP<LOCA::MultiContinuation::AbstractGroup>& initialGuess,
2781  const Teuchos::RCP<NOX::StatusTest::Generic>& test,
2782  const Teuchos::RCP<Teuchos::ParameterList>& p)
2783 {
2784  stepperPtr_ =
2785  Teuchos::rcp(new LOCA::Stepper(gd, initialGuess, test, p));
2786 }
2787 
2788 //-----------------------------------------------------------------------------
2789 // Function : Interface::getLocaFlag
2790 // Purpose :
2791 // Special Notes :
2792 // Scope : public
2793 // Creator :
2794 // Creation Date :
2795 //-----------------------------------------------------------------------------
2797 {
2798  // Pick the parameter set to use.
2799  const ParameterSet* paramsPtr;
2800  bool retCode;
2801 
2802  if ((usemode_) && (mode_ == Nonlinear::TRANSIENT))
2803  {
2804  firstSolveComplete_ = false;
2805  paramsPtr = &transientParams_;
2806  int solverType = paramsPtr->getNoxSolverType();
2807  retCode = false;
2808  if (solverType != 0) retCode = true;
2809  }
2810  else
2811  {
2812  if ((usemode_) && (mode_ == Nonlinear::HB_MODE))
2813  {
2814  paramsPtr = &hbParams_;
2815  }
2816  else
2817  {
2818  paramsPtr = &dcParams_;
2819  }
2820 
2821  if (DCOPused_)
2822  {
2823  retCode = firstSolveComplete_;
2824  }
2825  else
2826  {
2827  int solverType = paramsPtr->getNoxSolverType();
2828  retCode=false;
2829  if (solverType != 0) retCode = true;
2830  }
2831  }
2832 
2833  return retCode;
2834 }
2835 
2836 }}} // namespace N_NLS_NOX
Xyce::Nonlinear::AnalysisMode lastParametersMode_
bool setLocaOptions(const Xyce::Util::OptionBlock &OB)
bool setOptions(const Xyce::Util::OptionBlock &OB)
bool setOutputOptions(int myPID, int outputProcess)
bool opStartCont0(ParameterSet *paramsPtr, int found, int icType, Xyce::IO::InitialConditionsData::NodeNamePairMap &op, const Xyce::NodeNameMap &allNodes, N_PDS_Comm *pdsCommPtr)
void setAnalysisMode(Xyce::Nonlinear::AnalysisMode mode)
void reset(Xyce::Linear::Vector &x, Xyce::Linear::Vector &f, Xyce::Linear::Matrix &jacobian, Xyce::Linear::Vector &newton, Xyce::Linear::Vector &gradient, Xyce::Linear::System &lasSys, Interface &interface)
int mosfetContinuationSolve6(ParameterSet *paramsPtr)
Pure virtual class to augment a linear system.
bool setHBOptions(const Xyce::Util::OptionBlock &OB)
Teuchos::RCP< Teuchos::ParameterList > getLocaParams()
int mosfetContinuationSolve2(ParameterSet *paramsPtr)
int spiceStrategy(ParameterSet *paramsPtr)
bool setOptions(const Xyce::Util::OptionBlock &OB)
bool nodesetCont1(ParameterSet *paramsPtr)
Teuchos::RCP< NOX::Solver::Generic > solverPtr_
Teuchos::RCP< LOCA::Stepper > stepperPtr_
virtual bool applyJacobian(const Linear::Vector &input, Linear::Vector &result)
Teuchos::RCP< LOCA::StatusTest::Wrapper > locaTransientStatusTestPtr_
int stdNewtonSolve(ParameterSet *paramsPtr)
Teuchos::RCP< Teuchos::ParameterList > getNoxParams()
int mosfetContinuationSolve(ParameterSet *paramsPtr)
bool computeNewton(Teuchos::ParameterList &p)
const T & value(const ParameterBase &entity, const Descriptor &descriptor)
Returns the value of the parameter for the entity.
Definition: N_DEV_Pars.h:1224
bool setLocaOptions(const Xyce::Util::OptionBlock &OB, bool saveCopy=true)
int blockGainscaleMosfetSolve(ParameterSet *paramsPtr)
int naturalParameterContinuationSolve(ParameterSet *paramsPtr)
int solve(Xyce::Nonlinear::NonLinearSolver *nlsTmpPtr=NULL)
int mosfetContinuationSolve3(ParameterSet *paramsPtr)
Teuchos::RCP< LOCA::StatusTest::Wrapper > locaDCOpStatusTestPtr_
bool setTranOptions(const Xyce::Util::OptionBlock &OB)
Teuchos::RCP< LOCA::StatusTest::Wrapper > locaHBStatusTestPtr_
bool icCont(ParameterSet *paramsPtr)
int pseudoTransientSolve(ParameterSet *paramsPtr)
bool getVectorParam(const std::string &, int, double &)
Teuchos::RCP< N_NLS_LOCA::Group > getSolutionGroup()
const Analysis::AnalysisManager & getAnalysisManager() const
void setDebugFlags(int output_step_number, double time)
Teuchos::RCP< AugmentLinSys > createAugmentLinearSystem(Xyce::Linear::System *ls) const
bool opStartCont1(ParameterSet *paramsPtr)
Teuchos::RCP< LOCA::StatusTest::Wrapper > locaStatusTestPtr_
Teuchos::RCP< NOX::StatusTest::Generic > getStatusTests()
Xyce::Nonlinear::AnalysisMode parametersMode_
void setStatusTestReturnCodes(const Xyce::Nonlinear::ReturnCodes &retCodesTmp)
void resetAll(Xyce::Nonlinear::AnalysisMode mode)
int artificialParameterHomotopy(ParameterSet *paramsPtr)
Interface(const Xyce::IO::CmdParse &cp)
int takeFirstSolveStep(Xyce::Nonlinear::NonLinearSolver *nlsTmpPtr=NULL)
bool applyJacobian(const Xyce::Linear::Vector &input, Xyce::Linear::Vector &result)
bool setNodeSetOptions(const Xyce::Util::OptionBlock &OB)
bool setDCOPRestartOptions(const Xyce::Util::OptionBlock &OB)
int gminSteppingSolve(ParameterSet *paramsPtr)
Xyce::Loader::NonlinearEquationLoader & getLoader() const
IO::InitialConditionsManager * initialConditionsManager_
bool setICOptions(const Xyce::Util::OptionBlock &OB)
int sourceSteppingSolve(ParameterSet *paramsPtr)
int mosfetContinuationSolve5(ParameterSet *paramsPtr)
Teuchos::RCP< Teuchos::ParameterList > getAllParams()
bool icCont3(ParameterSet *paramsPtr)
Teuchos::RCP< N_NLS_LOCA::Group > groupPtr_
bool nodesetCont0(ParameterSet *paramsPtr)
bool createStatusTests(Parallel::Machine comm, N_LAS_Vector **currSolnVectorPtrPtr, Xyce::Loader::NonlinearEquationLoader &nonlinear_equation_loader, N_LAS_Vector *maskVectorPtr=0)
Only used when NLS_MASKED_WRMS_NORMS.
Loader::NonlinearEquationLoader * loaderPtr_
int getVectorParamSize(const std::string &vectorName)
Xyce::Nonlinear::AnalysisMode mode_
int mosfetContinuationSolve4(ParameterSet *paramsPtr)
Teuchos::RCP< LOCA::GlobalData > globalDataPtr_
void resetStepper(const Teuchos::RCP< LOCA::GlobalData > &gd, const Teuchos::RCP< LOCA::MultiContinuation::AbstractGroup > &initialGuess, const Teuchos::RCP< NOX::StatusTest::Generic > &test, const Teuchos::RCP< Teuchos::ParameterList > &p)