Xyce  6.1
N_ANP_DCSweep.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_ANP_DCSweep.C,v $
27 // Purpose : DC Sweep class analysis functions.
28 // Special Notes :
29 // Creator : Richard Schiek, SNL, Electrical and Microsystem Modeling
30 // Creation Date : 01/24/08
31 //
32 // Revision Information:
33 // ---------------------
34 // Revision Number: $Revision: 1.125.2.1 $
35 // Revision Date : $Date: 2015/04/02 18:20:07 $
36 // Current Owner : $Author: tvrusso $
37 //-----------------------------------------------------------------------------
38 #include <Xyce_config.h>
39 
40 // ---------- Standard Includes ----------
41 #include <iostream>
42 
43 // ---------- Xyce Includes ----------
44 #include <N_ANP_AnalysisManager.h>
45 #include <N_ANP_DCSweep.h>
46 #include <N_ANP_HB.h>
47 #include <N_ANP_OutputMgrAdapter.h>
48 #include <N_ANP_SweepParam.h>
49 #include <N_IO_PkgOptionsMgr.h>
50 #include <N_IO_CmdParse.h>
51 #include <N_LOA_Loader.h>
52 #include <N_NLS_Manager.h>
53 #include <N_TIA_DataStore.h>
55 #include <N_TIA_StepErrorControl.h>
57 #include <N_TOP_Topology.h>
58 #include <N_UTL_Diagnostic.h>
59 #include <N_UTL_ExtendedString.h>
60 #include <N_UTL_FeatureTest.h>
61 #include <N_UTL_OptionBlock.h>
62 #include <N_ERH_Message.h>
63 
64 #include <Teuchos_RCP.hpp>
65 
66 namespace Xyce {
67 namespace Analysis {
68 
70  AnalysisManager & analysis_manager,
71  Nonlinear::Manager & nonlinear_manager,
72  Topo::Topology & topology,
73  HB * hb_analysis)
74  : AnalysisBase(analysis_manager, "DC Sweep"),
75  analysisManager_(analysis_manager),
76  loader_(analysis_manager.getLoader()),
77  nonlinearManager_(nonlinear_manager),
78  topology_(topology),
79  outputManagerAdapter_(analysis_manager.getOutputManagerAdapter()),
80  tiaParams_(),
81  hbAnalysis_(hb_analysis),
82  sensFlag_(analysis_manager.getSensFlag()),
83  dcLoopInitialized_(false),
84  dcLoopSize_(0)
85 {}
86 
88 {}
89 
90 //-----------------------------------------------------------------------------
91 // Function : AnalysisManager::setTranOptions
92 // Purpose :
93 // Special Notes : These are from '.options timeint'
94 // Scope : public
95 // Creator : Eric R. Keiter, SNL, Parallel Computational Sciences
96 // Creation Date : 04/18/02
97 //-----------------------------------------------------------------------------
98 bool
100  const Util::OptionBlock & option_block)
101 {
102  for (Util::ParamList::const_iterator it = option_block.begin(), end = option_block.end(); it != end; ++it)
103  {
104  const Util::Param &param = (*it);
105 
106  if (param.uTag() == "DAESTATEDERIV")
107  analysisManager_.setDAEStateDerivFlag(static_cast<bool> (param.getImmutableValue<int>()));
108  else if (param.uTag() == "DEBUGLEVEL")
109  IO::setTimeIntegratorDebugLevel(analysisManager_.getCommandLine(), param.getImmutableValue<int>());
110  else if (nonlinearManager_.setReturnCodeOption(param))
111  ;
112  else if (tiaParams_.setTimeIntegratorOption(param))
113  ;
114  else if (setDCOPOption(param))
115  ;
116  else if (param.uTag() == "METHOD")
117  ;
118  else
119  Report::UserError() << param.uTag() << " is not a recognized time integration option";
120  }
121 
122  return true;
123 }
124 
125 
126 //-----------------------------------------------------------------------------
127 // Function : DCSweep::setAnalysisParams
128 // Purpose :
129 // Special Notes :
130 // Scope : public
131 // Creator : Eric R. Keiter, SNL
132 // Creation Date : 6/22/10
133 //-----------------------------------------------------------------------------
134 bool DCSweep::setAnalysisParams(const Util::OptionBlock & paramsBlock)
135 {
136  dcSweepVector_.push_back(parseSweepParams(paramsBlock.begin(), paramsBlock.end()));
137 
138  return true;
139 }
140 
141 //-----------------------------------------------------------------------------
142 // Function : DCSweep::outputFailureStats
143 // Purpose :
144 // Special Notes :
145 // Scope : public
146 // Creator : Eric Keiter, SNL
147 // Creation Date : 6/21/2010
148 //-----------------------------------------------------------------------------
149 bool DCSweep::outputFailureStats(std::ostream &os)
150 {
151  if (!(dcSweepFailures_.empty()))
152  {
153  os << "\tFailed DC sweep steps:\t\t" << std::endl;
154 
155  for (std::vector<int>::iterator iter = dcSweepFailures_.begin(); iter != dcSweepFailures_.end(); ++iter)
156  {
157  os << "\t\tDC Step # " << *iter << std::endl;
158  }
159  }
160  return true;
161 }
162 
163 //-----------------------------------------------------------------------------
164 // Function : DCSweep::run()
165 // Purpose : This is the main controlling loop for DC sweep analysis.
166 // This loop calls a series of operating point calculations
167 // (ie calculations in which there is no time integration,
168 // and the time integration method is always set to "none").
169 // Special Notes :
170 // Scope : public
171 // Creator : Richard Schiek, SNL, Electrical and Microsystem Modeling
172 // Creation Date : 1/28/08
173 //-----------------------------------------------------------------------------
175 {
176  return doInit() && doLoopProcess() && doFinish();
177 }
178 
179 //-----------------------------------------------------------------------------
180 // Function : DCSweep::init()
181 // Purpose :
182 // Special Notes :
183 // Scope : public
184 // Creator : Richard Schiek, SNL, Electrical and Microsystem Modeling
185 // Creation Date : 1/28/08
186 //-----------------------------------------------------------------------------
188 {
189  bool bsuccess = true;
190 
191  if (sensFlag_)
192  {
193  Stats::StatTop _sensitivityStat("Sensitivity");
194 
196  }
197 
198  // set up the various sweep variables
199  // the following should only happen once, but must be isolated to
200  // prevent a step loop outside of this dc sweep from causing to
201  // occur more often
202  if( !dcLoopInitialized_ )
203  {
204  if (DEBUG_ANALYSIS && isActive(Diag::TIME_PARAMETERS))
205  {
206  Xyce::dout() << std::endl << std::endl
207  << Xyce::subsection_divider << std::endl
208  << "DCSweep::run()" << std::endl;
209  }
210 
212 
215 
216  dcLoopInitialized_ = true;
217  }
218 
219  //setup for operating pt calculation
222 
223  stepNumber = 0;
226 
228 
229  return bsuccess;
230 }
231 
232 //-----------------------------------------------------------------------------
233 // Function : DCSweep::initializeSolution()
234 // Purpose : Move solution-initialization steps to separate routine so
235 // the process may be repeated cleanly when necessary.
236 // Special Notes :
237 // Scope : public
238 // Creator : Tom Russo, SNL, Electrical and Microsystem Modeling
239 // Creation Date : 2/17/2010
240 //-----------------------------------------------------------------------------
242 {
243  // set initial guess, if there is one to be set.
244  // this setInitialGuess call is to up an initial guess in the
245  // devices that have them (usually PDE devices). This is different than
246  // the "intializeProblem" call, which sets IC's. (initial conditions are
247  // different than initial guesses.
249 
250  // If available, set initial solution (.IC, .NODESET, etc).
255 
256  // Set a constant history for operating point calculation
260 }
261 
262 //-----------------------------------------------------------------------------
263 // Function : DCSweep::loopProcess()
264 // Purpose :
265 // Special Notes :
266 // Scope : public
267 // Creator : Richard Schiek, SNL, Electrical and Microsystem Modeling
268 // Creation Date : 1/28/08
269 //-----------------------------------------------------------------------------
271 {
272  static_cast<Xyce::Util::Notifier<AnalysisEvent> &>(analysisManager_).publish(AnalysisEvent(AnalysisEvent::INITIALIZE, AnalysisEvent::DC));
273 
274  int currentStep = 0;
275  int finalStep = dcLoopSize_;
276  while (currentStep < finalStep)
277  {
279 
280  if (VERBOSE_TIME)
281  {
282  printStepHeader(Xyce::dout());
284  }
285 
286  bool reset = updateSweepParams(loader_, currentStep, dcSweepVector_.begin(), dcSweepVector_.end(), true);
287 
288  // Tell the manager if any of our sweeps are being reset in this loop iteration.
290 
292 
293  if (currentStep != 0 && reset)
294  {
297  }
298 
299  // Perform the step:
300  static_cast<Xyce::Util::Notifier<AnalysisEvent> &>(analysisManager_).publish(AnalysisEvent(AnalysisEvent::STEP_STARTED, AnalysisEvent::DC, 0.0, currentStep));
301 
302  takeStep_();
303 
304  // Set things up for the next time step, based on if this one was
305  // successful.
307  {
308  static_cast<Xyce::Util::Notifier<AnalysisEvent> &>(analysisManager_).publish(AnalysisEvent(AnalysisEvent::STEP_SUCCESSFUL, AnalysisEvent::DC, 0.0, currentStep));
310  }
311  else // stepAttemptStatus (ie do this if the step FAILED)
312  {
313  static_cast<Xyce::Util::Notifier<AnalysisEvent> &>(analysisManager_).publish(AnalysisEvent(AnalysisEvent::STEP_FAILED, AnalysisEvent::DC, 0.0, currentStep));
315  }
316 
317  // we don't really control the loop counter here. processSuccessfulStep
318  // and processFailedStep do that work. This needs to be cleaned up. RLS
319  currentStep = stepNumber;
320  } // end of sweep loop
321 
322  static_cast<Xyce::Util::Notifier<AnalysisEvent> &>(analysisManager_).publish(AnalysisEvent(AnalysisEvent::FINISH, AnalysisEvent::DC));
323 
324  return true;
325 }
326 
327 //-----------------------------------------------------------------------------
328 // Function : DCSweep::processSuccessfulStep()
329 //
330 // Purpose : Used by both function dcSweepLoop and 2-level solve
331 // function calls to process successful DC steps.
332 // Special Notes :
333 // Scope : public
334 // Creator : Richard Schiek, SNL, Electrical and Microsystem Modeling
335 // Creation Date : 1/28/08
336 //-----------------------------------------------------------------------------
338 {
339  Stats::StatTop _processSuccessfulStepStat("Successful Step");
340  Stats::TimeBlock _processSuccessfulStepTimer(_processSuccessfulStepStat);
341 
342  loader_.stepSuccess(TWO_LEVEL_MODE_DC_SWEEP); // analysisManager_.getTwoLevelMode());
343 
344  // This output call is for device-specific output, such as .OP,
345  // or internal plot output from PDE(TCAD) devices.
346  loader_.output();
347 
348  if (sensFlag_ && !firstDoubleDCOPStep() )
349  {
351  }
352 
353  // Do some statistics, as long as this isn't the first "double"
354  // DCOP step. (that one doesn't count)
355  if ( !firstDoubleDCOPStep() )
356  {
357  stepNumber += 1;
360  }
361 
362  // update the data arrays, output:
364 
365  if (DEBUG_ANALYSIS & DEBUG_TIME && isActive(Diag::TIME_DUMP_SOLUTION_ARRAYS))
367 
368  dcSweepOutput();
369 
370  // now that output has been called, update the doubleDCOP step
371  // if neccessary. (pde-only)
373 
374  return true;
375 }
376 
377 //-----------------------------------------------------------------------------
378 // Function : DCSweep::processFailedStep()
379 // Purpose :
380 // Special Notes :
381 // Scope : public
382 // Creator : Richard Schiek, SNL, Electrical and Microsystem Modeling
383 // Creation Date : 1/28/08
384 //-----------------------------------------------------------------------------
386 {
387  Stats::StatTop _processFailedStat("Failed Steps");
388  Stats::TimeBlock _processFailedTimer(_processFailedStat);
389 
391 
392  stepNumber += 1;
393  dcSweepFailures_.push_back(stepNumber);
396 
397  return true;
398 }
399 
400 //-----------------------------------------------------------------------------
401 // Function : DCSweep::doFinish()
402 // Purpose :
403 // Special Notes :
404 // Scope : public
405 // Creator : Richard Schiek, SNL, Electrical and Microsystem Modeling
406 // Creation Date : 1/28/08
407 //-----------------------------------------------------------------------------
409 {
410  bool bsuccess = true;
411 
412  if (DEBUG_ANALYSIS)
413  Xyce::dout() << "Calling DCSweep::doFinish() outputs!" << std::endl;
414 
416  if (!(dcSweepFailures_.empty()))
417  {
418  bsuccess = false;
419  }
420  return bsuccess;
421 }
422 
423 
424 //-----------------------------------------------------------------------------
425 // Function : DCSweep::doHandlePredictor
426 // Purpose :
427 // Special Notes :
428 // Scope : private
429 // Creator : Eric Keiter, SNL
430 // Creation Date : 06/24/2013
431 //-----------------------------------------------------------------------------
433 {
437 
438  // In case this is the upper level of a 2-level sim, tell the
439  // inner solve to do its prediction:
441 
442  return true;
443 }
444 
445 //-----------------------------------------------------------------------------
446 // Function : DCSweep::takeStep_
447 // Purpose : Take a DC Sweep integration step.
448 // Special Notes :
449 // Scope : private
450 // Creator : Richard Schiek, SNL, Electrical and Microsystem Modeling
451 // Creation Date : 01/24/08
452 //-----------------------------------------------------------------------------
454 {
455  { // Integration step predictor
456  Stats::StatTop _predictorStat("Predictor");
457  Stats::TimeBlock _predictorTimer(_predictorStat);
458 
460  }
461 
462  { // Load B/V source devices with time data
463  Stats::StatTop _updateDeviceSourceStat("Update Device Sources");
464  Stats::TimeBlock _updateDeviceSourceTimer(_updateDeviceSourceStat);
465 
467  }
468 
469  { // Nonlinear solve
470  Stats::StatTop _nonlinearSolveStat("Solve");
471  Stats::TimeBlock _nonlinearSolveTimer(_nonlinearSolveStat);
472 
474  }
475 
476  { // Add change to solution
477  Stats::StatTop _errorStat("Error Estimation");
478  Stats::TimeBlock _errorTimer(_errorStat);
479 
481 
483 
485  }
486 }
487 
488 //-----------------------------------------------------------------------------
489 // Function : DCSweep::twoLevelStep
490 //
491 // Purpose : Used by 2-level Newton solves to execute a single DC sweep
492 // step.
493 //
494 // Special Notes : This is mostly what happens on the inner loop of
495 // dcSweepLoop, except that DC parameters are not updated,
496 // and success/failure of the step is not determined.
497 //
498 // Scope : public
499 // Creator : Eric Keiter, SNL
500 // Creation Date : 03/10/06
501 //-----------------------------------------------------------------------------
503 {
509 
511 }
512 
513 //-----------------------------------------------------------------------------
514 // Function : DCSweep::dcSweepOutput
515 // Purpose :
516 // Special Notes :
517 // Scope : public
518 // Creator : Richard Schiek, SNL, Electrical and Microsystem Modeling
519 // Creation Date : 1/31/08
520 //-----------------------------------------------------------------------------
522 {
523  if (hbAnalysis_)
524  {
525  std::vector<double> timePoints, freqPoints;
526  Teuchos::RCP<Linear::BlockVector> timeDomainSolnVec;
527  Teuchos::RCP<Linear::BlockVector> freqDomainSolnVecReal;
528  Teuchos::RCP<Linear::BlockVector> freqDomainSolnVecImaginary;
529  Teuchos::RCP<Linear::BlockVector> timeDomainStoreVec;
530  Teuchos::RCP<Linear::BlockVector> freqDomainStoreVecReal;
531  Teuchos::RCP<Linear::BlockVector> freqDomainStoreVecImaginary;
532  Teuchos::RCP<Linear::BlockVector> timeDomainLeadCurrentVec;
533  Teuchos::RCP<Linear::BlockVector> freqDomainLeadCurrentVecReal;
534  Teuchos::RCP<Linear::BlockVector> freqDomainLeadCurrentVecImaginary;
535  Teuchos::RCP<Linear::BlockVector> timeDomainJunctionVoltageVec;
536  Teuchos::RCP<Linear::BlockVector> freqDomainJunctionVoltageVecReal;
537  Teuchos::RCP<Linear::BlockVector> freqDomainJunctionVoltageVecImaginary;
538 
539  // RLS Todo: Need to update HB call here
540  // for leadcurrent and junctionvoltage vector
541 
542 
545  timePoints,
546  freqPoints,
547  timeDomainSolnVec,
548  freqDomainSolnVecReal,
549  freqDomainSolnVecImaginary,
550  timeDomainStoreVec,
551  freqDomainStoreVecReal,
552  freqDomainStoreVecImaginary,
553  timeDomainLeadCurrentVec,
554  freqDomainLeadCurrentVecReal,
555  freqDomainLeadCurrentVecImaginary,
556  timeDomainJunctionVoltageVec,
557  freqDomainJunctionVoltageVecReal,
558  freqDomainJunctionVoltageVecImaginary);
559 
561  timePoints,
562  freqPoints,
563  *timeDomainSolnVec,
564  *freqDomainSolnVecReal,
565  *freqDomainSolnVecImaginary,
566  *timeDomainStoreVec,
567  *freqDomainStoreVecReal,
568  *freqDomainStoreVecImaginary,
569  *timeDomainLeadCurrentVec,
570  *freqDomainLeadCurrentVecReal,
571  *freqDomainLeadCurrentVecImaginary,
572  *timeDomainJunctionVoltageVec,
573  *freqDomainJunctionVoltageVecReal,
574  *freqDomainJunctionVoltageVecImaginary);
575  }
576 
577  // Make sure this isn't the NLP step of a PDE DCOP.
578  else if (!firstDoubleDCOPStep())
579  {
580  // conventional .PRINT output
582  stepNumber,
590 
591  // output for DCOP restart
593  }
594 
595 }
596 
597 //-----------------------------------------------------------------------------
598 // Function : DCSweep::printStepHeader()
599 // Purpose : Prints out time step information.
600 // Special Notes :
601 // Scope : public
602 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
603 // Creation Date : 6/26/00
604 //-----------------------------------------------------------------------------
605 void DCSweep::printStepHeader(std::ostream &os)
606 {
607  if (VERBOSE_TIME)
608  dout() << std::endl << std::endl
609  << "***** "<< (DEBUG_ANALYSIS ? analysisManager_.getNetlistFilename() : "")
610  << " Start of DCOP STEP # " << stepNumber+1
611  << std::endl << std::endl;
612 }
613 
614 //-----------------------------------------------------------------------------
615 // Function : DCSweep::printLoopInfo
616 // Purpose :
617 // Scope : public
618 // Creator : Eric Keiter
619 // Creation Date : 12/14/2010
620 //-----------------------------------------------------------------------------
621 bool DCSweep::printLoopInfo(int start, int finish)
622 {
623  bool bsuccess = AnalysisBase::printLoopInfo(start, finish);
624  if (start == 0 && finish == 0)
625  {
626  outputFailureStats(Xyce::lout());
627  }
628  return bsuccess;
629 }
630 
631 namespace {
632 
633 //-----------------------------------------------------------------------------
634 // Class : DCSweepFactory
635 // Purpose :
636 // Special Notes :
637 // Scope : public
638 // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
639 // Creation Date : Thu Jan 29 12:53:02 2015
640 //-----------------------------------------------------------------------------
641 ///
642 /// Factory for parsing DCSweep parameters from the netlist and creating DCSweep analysis.
643 ///
644 class DCSweepFactory : public Factory<DCSweep>
645 {
646 public:
647  //-----------------------------------------------------------------------------
648  // Function : DCSweepFactory
649  // Purpose :
650  // Special Notes :
651  // Scope : public
652  // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
653  // Creation Date : Thu Jan 29 12:54:09 2015
654  //-----------------------------------------------------------------------------
655  ///
656  /// Constructs the DCSweep analysis factory
657  ///
658  /// @invariant Stores the results of parsing. Multiple DCSweep analysis options may be
659  /// applied and each generates and additional dcsweep.
660  ///
661  /// @invariant The existence of the parameters specified in the constructor cannot
662  /// change.
663  ///
664  /// @param analysis_manager
665  /// @param linear_system
666  /// @param nonlinear_manager
667  /// @param topology
668  ///
669  DCSweepFactory(
670  Analysis::AnalysisManager & analysis_manager,
671  Linear::System & linear_system,
672  Nonlinear::Manager & nonlinear_manager,
673  Topo::Topology & topology)
674  : Factory<DCSweep>(),
675  analysisManager_(analysis_manager),
676  linearSystem_(linear_system),
677  nonlinearManager_(nonlinear_manager),
678  topology_(topology)
679  {}
680 
681  virtual ~DCSweepFactory()
682  {}
683 
684  //-----------------------------------------------------------------------------
685  // Function : create
686  // Purpose :
687  // Special Notes :
688  // Scope : public
689  // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
690  // Creation Date : Thu Jan 29 12:59:00 2015
691  //-----------------------------------------------------------------------------
692  ///
693  /// Create a new DCSweep analysis and applies the analysis and time integrator option blocks.
694  ///
695  /// @return new DCSweep analysis object
696  ///
697  ///
698  DCSweep *create() const
699  {
700  analysisManager_.setAnalysisMode(ANP_MODE_DC_SWEEP);
701  DCSweep *dc_sweep = new DCSweep(analysisManager_, nonlinearManager_, topology_);
702  for (std::vector<Util::OptionBlock>::const_iterator it = dcSweepAnalysisOptionBlock_.begin(), end = dcSweepAnalysisOptionBlock_.end(); it != end; ++it)
703  dc_sweep->setAnalysisParams(*it);
704  dc_sweep->setTimeIntegratorOptions(timeIntegratorOptionBlock_);
705 
706  return dc_sweep;
707  }
708 
709  //-----------------------------------------------------------------------------
710  // Function : setDCSweepAnalysisOptionBlock
711  // Purpose :
712  // Special Notes :
713  // Scope : public
714  // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
715  // Creation Date : Thu Jan 29 13:00:14 2015
716  //-----------------------------------------------------------------------------
717  ///
718  /// Saves the analysis parsed options block in the factory.
719  ///
720  /// @invariant Appends to any previously specified analysis option block.
721  ///
722  /// @param option_block parsed option block
723  ///
724  void setDCSweepAnalysisOptionBlock(const Util::OptionBlock &option_block)
725  {
726  for (std::vector<Util::OptionBlock>::iterator it = dcSweepAnalysisOptionBlock_.begin(), end = dcSweepAnalysisOptionBlock_.end(); it != end; ++it)
727  {
728  if ((*it).compareParamLists(option_block))
729  {
730  (*it) = option_block;
731  return;
732  }
733  }
734 
735  // save the new one.
736  dcSweepAnalysisOptionBlock_.push_back(option_block); // save a copy for later.
737  }
738 
739  //-----------------------------------------------------------------------------
740  // Function : setTimeIntegratorOptionBlock
741  // Purpose :
742  // Special Notes :
743  // Scope : public
744  // Creator : David G. Baur Raytheon Sandia National Laboratories 1355
745  // Creation Date : Thu Jan 29 13:01:27 2015
746  //-----------------------------------------------------------------------------
747  ///
748  /// Saves the time integrator parsed option block.
749  ///
750  /// @invariant Overwrites any previously specified time integrator option block.
751  ///
752  /// @param option_block parsed option block
753  ///
754  void setTimeIntegratorOptionBlock(const Util::OptionBlock &option_block)
755  {
756  timeIntegratorOptionBlock_ = option_block;
757  }
758 
759 public:
760  AnalysisManager & analysisManager_;
761  Linear::System & linearSystem_;
762  Nonlinear::Manager & nonlinearManager_;
763  Topo::Topology & topology_;
764 
765 private:
766  std::vector<Util::OptionBlock> dcSweepAnalysisOptionBlock_;
767  Util::OptionBlock timeIntegratorOptionBlock_;
768 };
769 
770 
771 // .options TIMEINT
772 struct TimeIntegratorOptionsReg : public IO::PkgOptionsReg
773 {
774  TimeIntegratorOptionsReg(
775  DCSweepFactory & factory)
776  : factory_(factory)
777  {}
778 
779  bool operator()(const Util::OptionBlock &option_block)
780  {
781  factory_.setTimeIntegratorOptionBlock(option_block);
782 
783  return true;
784  }
785 
786  DCSweepFactory & factory_;
787 };
788 
789 // .DC
790 struct DCSweepAnalysisReg : public IO::PkgOptionsReg
791 {
792  DCSweepAnalysisReg(
793  DCSweepFactory & factory)
794  : factory_(factory)
795  {}
796 
797  bool operator()(const Util::OptionBlock &option_block)
798  {
799  factory_.setDCSweepAnalysisOptionBlock(option_block);
800 
801  factory_.analysisManager_.addAnalysis(&factory_);
802 
803  return true;
804  }
805 
806  DCSweepFactory & factory_;
807 };
808 
809 } // namespace <unnamed>
810 
811 bool
813  const std::string & netlist_filename,
814  IO::PkgOptionsMgr & options_manager,
815  AnalysisManager & analysis_manager,
816  Linear::System & linear_system,
817  Nonlinear::Manager & nonlinear_manager,
818  Topo::Topology & topology)
819 {
820  DCSweepFactory *factory = new DCSweepFactory(analysis_manager, linear_system, nonlinear_manager, topology);
821 
822  analysis_manager.addAnalysisFactory(factory);
823 
824  options_manager.submitRegistration("DC", netlist_filename, new DCSweepAnalysisReg(*factory));
825  options_manager.submitRegistration("TIMEINT", netlist_filename, new TimeIntegratorOptionsReg(*factory));
826 
827  return true;
828 }
829 
830 
831 } // namespace Analysis
832 } // namespace Xyce
bool enableSensitivity(TimeIntg::DataStore &data_store, Parallel::Manager &parallel_manager, Topo::Topology &topology)
unsigned int successfulStepsTaken_
Number of consecutive successful time-integration steps.
virtual bool setInitialGuess(Linear::Vector *solVectorPtr)
Definition: N_LOA_Loader.h:231
bool setTimeIntegratorOption(const Util::Param &param)
bool printLoopInfo(int start, int finish)
bool calcSensitivity(std::vector< double > &objectiveVec, std::vector< double > &dOdpVec, std::vector< double > &dOdpAdjVec, std::vector< double > &scaled_dOdpVec, std::vector< double > &scaled_dOdpAdjVec)
AnalysisManager & analysisManager_
std::vector< double > objectiveVec_
Pure virtual class to augment a linear system.
bool updateSweepParams(Loader::Loader &loader, int step_count, std::vector< SweepParam >::iterator begin, std::vector< SweepParam >::iterator end, bool overrideOriginal=false)
int doubleDCOPStep_
current step in the DCOP loop.
virtual void stepFailure(Analysis::TwoLevelMode analysis)
Definition: N_LOA_Loader.h:286
void dcOutput(int dcStepNumber, Linear::Vector &currSolutionPtr, Linear::Vector &stateVecPtr, Linear::Vector &storeVecPtr, Linear::Vector &lead_current_vector, Linear::Vector &junction_voltage_vector, std::vector< double > &objectiveVec_, std::vector< double > &dOdpVec_, std::vector< double > &dOdpAdjVec_, std::vector< double > &scaled_dOdpVec_, std::vector< double > &scaled_dOdpAdjVec_)
std::vector< double > dOdpVec_
unsigned int stepNumber
Time-integration step number counter.
void outputSolDataArrays(std::ostream &os)
Linear::Vector * currStorePtr
void gatherStepStatistics(StatCounts &stats, Nonlinear::NonLinearSolver &nonlinear_solver, int newton_convergence_status)
OutputMgrAdapter & outputManagerAdapter_
void createTimeIntegratorMethod(const TimeIntg::TIAParams &tia_params, const unsigned int integration_method)
bool setupInitialConditions(Linear::Vector &solnVec, Linear::Vector &flagVec)
Linear::Vector * currStatePtr
unsigned int failedStepsAttempted_
Total number of failed time-integration steps.
Parallel::Manager * getPDSManager() const
Topo::Topology & topology_
bool setDCOPOption(const Util::Param &param)
TimeIntg::StepErrorControl & getStepErrorControl()
const std::string & getNetlistFilename() const
std::vector< int > dcSweepFailures_
bool outputFailureStats(std::ostream &os)
NonLinearSolver & getNonlinearSolver()
void prepareHBOutput(Linear::Vector &solnVecPtr, std::vector< double > &timePoints, std::vector< double > &freqPoints, Teuchos::RCP< Linear::BlockVector > &timeDomainSolnVec, Teuchos::RCP< Linear::BlockVector > &freqDomainSolnVecReal, Teuchos::RCP< Linear::BlockVector > &freqDomainSolnVecImaginary, Teuchos::RCP< Linear::BlockVector > &timeDomainStoreVec, Teuchos::RCP< Linear::BlockVector > &freqDomainStoreVecReal, Teuchos::RCP< Linear::BlockVector > &freqDomainStoreVecImaginary, Teuchos::RCP< Linear::BlockVector > &timeDomainLeadCurrentVec, Teuchos::RCP< Linear::BlockVector > &freqDomainLeadCurrentVecReal, Teuchos::RCP< Linear::BlockVector > &freqDomainLeadCurrentVecImaginary, Teuchos::RCP< Linear::BlockVector > &timeDomainJunctionVoltageVec, Teuchos::RCP< Linear::BlockVector > &freqDomainJunctionVoltageVecReal, Teuchos::RCP< Linear::BlockVector > &freqDomainJunctionVoltageVecImaginary) const
Definition: N_ANP_HB.C:816
std::vector< double > dOdpAdjVec_
std::vector< double > scaled_dOdpAdjVec_
bool setTimeIntegratorOptions(const Util::OptionBlock &option_block)
Definition: N_ANP_DCSweep.C:99
virtual bool startTimeStep()
Definition: N_LOA_Loader.h:304
Nonlinear::Manager & nonlinearManager_
void setErrorWtVector(const TIAParams &tia_params)
Nonlinear::Manager & nonlinearManager_
DCSweep(AnalysisManager &analysis_manager, Nonlinear::Manager &nonlinear_manager, Topo::Topology &topology, HB *hb_analysis=0)
Definition: N_ANP_DCSweep.C:69
Loader::Loader & loader_
Util::OptionBlock timeIntegratorOptionBlock_
void setDCSweepVector(const Analysis::SweepVector &sweep_vector)
DCSweepFactory & factory_
virtual bool updateSources()
Definition: N_LOA_Loader.h:243
void printStepHeader(std::ostream &os)
virtual bool printLoopInfo(int start, int finish)
SweepParam parseSweepParams(Util::ParamList::const_iterator first, Util::ParamList::const_iterator last)
Populate the sweep params from the parameter list.
Linear::Vector * currLeadDeltaVPtr
std::vector< double > scaled_dOdpVec_
void addAnalysisFactory(Factory< void > *factory)
AnalysisManager & analysisManager_
Linear::Vector * nextSolutionPtr
virtual bool getDoubleDCOPFlag() const
Definition: N_LOA_Loader.h:255
bool registerDCSweepFactory(const std::string &netlist_filename, IO::PkgOptionsMgr &options_manager, AnalysisManager &analysis_manager, Linear::System &linear_system, Nonlinear::Manager &nonlinear_manager, Topo::Topology &topology)
TimeIntg::TIAParams tiaParams_
The analysis factory template defines an interface for analysis type testing and analysis creation...
Definition: N_ANP_Factory.h:65
Linear::Vector * currLeadCurrentPtr
void setInputOPFlag(bool initial_conditions_loaded)
TimeIntg::WorkingIntegrationMethod & getWorkingIntegrationMethod()
const IO::CmdParse & getCommandLine() const
Linear::Vector * currSolutionPtr
TimeIntg::DataStore * getDataStore()
void evaluateStepError(const TIAParams &tia_params)
bool doubleDCOPFlag_
true if doing a double-DCOP is possible.
unsigned int baseIntegrationMethod_
Current time-integration method flag.
Linear::System & linearSystem_
virtual void stepSuccess(Analysis::TwoLevelMode analysis)
Definition: N_LOA_Loader.h:283
void outputDCOP(const Linear::Vector &solution)
void outputHB(const std::vector< double > &timePoints, const std::vector< double > &freqPoints, const Linear::BlockVector &timeDomainSolnVec, const Linear::BlockVector &freqDomainSolnVecReal, const Linear::BlockVector &freqDomainSolnVecImaginary, const Linear::BlockVector &timeDomainStoreVec, const Linear::BlockVector &freqDomainStoreVecReal, const Linear::BlockVector &freqDomainStoreVecImaginary, const Linear::BlockVector &timeDomainLeadCurrentVec, const Linear::BlockVector &freqDomainLeadCurrentVecReal, const Linear::BlockVector &freqDomainLeadCurrentVecImaginary, const Linear::BlockVector &timeDomainJunctionVoltageVec, const Linear::BlockVector &freqDomainJunctionVoltageVecReal, const Linear::BlockVector &freqDomainJunctionVoltageVecImaginary)
std::vector< Util::OptionBlock > dcSweepAnalysisOptionBlock_
int setupSweepLoop(Loader::Loader &loader, std::vector< SweepParam >::iterator begin, std::vector< SweepParam >::iterator end)
Linear::Vector * flagSolutionPtr
bool setAnalysisParams(const Util::OptionBlock &paramsBlock)
bool setReturnCodeOption(const Util::Param &param)
virtual bool output() const
Definition: N_LOA_Loader.h:260
Topo::Topology & topology_