Xyce  6.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
N_ANP_Transient.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 // Copyright Notice
3 //
4 // Copyright 2002 Sandia Corporation. Under the terms
5 // of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S.
6 // Government retains certain rights in this software.
7 //
8 // Xyce(TM) Parallel Electrical Simulator
9 // Copyright (C) 2002-2014 Sandia Corporation
10 //
11 // This program is free software: you can redistribute it and/or modify
12 // it under the terms of the GNU General Public License as published by
13 // the Free Software Foundation, either version 3 of the License, or
14 // (at your option) any later version.
15 //
16 // This program is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // GNU General Public License for more details.
20 //
21 // You should have received a copy of the GNU General Public License
22 // along with this program. If not, see <http://www.gnu.org/licenses/>.
23 //-----------------------------------------------------------------------------
24 
25 //-----------------------------------------------------------------------------
26 // Filename : $RCSfile: N_ANP_Transient.h,v $
27 //
28 // Purpose : Transient analysis class
29 //
30 // Special Notes : Specify any "hidden" or subtle details of the class here.
31 // Portability details, error handling information, etc.
32 //
33 // Creator : Richard Schiek, SNL, Electrical and Microsystem Modeling
34 //
35 // Creation Date : 01/24/08
36 //
37 // Revision Information:
38 // ---------------------
39 //
40 // Revision Number: $Revision: 1.31 $
41 // Revision Date : $Date: 2014/02/24 23:49:12 $
42 // Current Owner : $Author: tvrusso $
43 //-----------------------------------------------------------------------------
44 
45 #ifndef Xyce_N_ANP_Transient_h
46 #define Xyce_N_ANP_Transient_h
47 
48 #include <Teuchos_RefCountPtr.hpp>
49 using Teuchos::RefCountPtr;
50 using Teuchos::rcp;
51 
52 #include <N_ANP_fwd.h>
53 #include <N_UTL_fwd.h>
54 
55 #include <N_ANP_AnalysisBase.h>
56 #include <N_UTL_FixedQueue.h>
57 
58 namespace Xyce {
59 namespace Analysis {
60 
61 //-------------------------------------------------------------------------
62 // Class : Transient
63 // Purpose : Transient analysis class
64 // Special Notes :
65 // Creator : Richard Schiek, SNL, Electrical and Microsystem Modeling
66 // Creation Date : 01/24/08
67 //-------------------------------------------------------------------------
68 class Transient : public AnalysisBase
69 {
70  public:
71  Transient( AnalysisManager * anaManagerPtr );
72 
73  virtual ~Transient() {};
74 
75  bool setAnalysisParams(const N_UTL_OptionBlock & paramsBlock);
76 
77  bool run();
78  bool init();
79  bool loopProcess();
80  bool processSuccessfulDCOP();
81  bool processFailedDCOP();
82  bool processSuccessfulStep();
83  bool processFailedStep();
84  bool finish();
85  bool handlePredictor();
86  bool resetForStepAnalysis();
87  bool resetForHB();
88  void outputQueuedData();
89  bool finalVerboseOutput();
90 
91  void printStepHeader(std::ostream &os);
92  void printProgress(std::ostream &os);
93 
94 
95  // mixed-signal specific
96  void preStepDetails (double maxTimeStepFromHabanero);
97  bool mixedSignalStep();
98  bool finalizeStep ();
99 
100  // Two Level specific
101  bool twoLevelStep();
102 
103  void setDCOPFlag(bool flag) { dcopFlag_ = flag; }
104  bool getDCOPFlag() { return dcopFlag_; }
105 
106  int getDCStats() { return dcStats; }
107  int getTranStats() { return tranStats; }
108 
109  private:
110 
111  // 05/26/09 Coffey,Schiek,Mei: We moved these functions from AnalysisManager ----v
114  std::vector<double> outputInterpolationTimes_;
115  void computeOutputInterpolationTimes_(double currTime);
116  void updateOutputTime_(double currTime);
117  bool testOutputTime_();
118 
119  void noopOutputs ();
120  void tranopOutputs ();
121  void tranStepOutputs ();
122  // 05/26/09 Coffey,Schiek,Mei: We moved these functions from AnalysisManager ----^
123 
124  void takeAnIntegrationStep_();
125 
126  bool retakeAndAcceptTimeStep( double aTimeStep );
127 
128  // a flag to indicate of the simulation is paused
129  bool isPaused;
130  bool dcopFlag_; // true if this is a DCOP calculation.
131 
132  double startDCOPtime, endTRANtime; // startTRANtime
133  bool gui_; // command line arg -gui is present
134 
135  bool historyTrackingOn_; // bool to indicate if history tracking is on.
136 
137  // These are used to track the minimum estimated error over tol. of failed
138  // time steps so that if we're going to exit with a time step too small error,
139  // we can have the option of accepting whatever step had the minimum error.
143  // Timing/loop count info
144  // int dcStats;
145  //
146  // for handling expressions given for a time dependent max time step
149  RefCountPtr<N_UTL_ExpressionData> maxTimeStepExpressionRCPtr_;
150 
151  // here we store stats on the last few time steps
152  // to report if Xyce fails. A user can use this info
153  // to figure how how to make the simulation work.
154  // The number of items saved is set in the constructor
156  N_UTL_FixedQueue<double> timeQueue_;
157  N_UTL_FixedQueue<double> timeStepQueue_;
158  N_UTL_FixedQueue<int> stepStatusQueue_;
159  N_UTL_FixedQueue<double> estErrorOverTolQueue_;
160  N_UTL_FixedQueue<int> nonlinearSolverStatusQueue_;
161  N_UTL_FixedQueue<int> nonlinearSolverNumIterationsQueue_;
162  N_UTL_FixedQueue<double> nonlinearSolverMaxNormQueue_;
163  N_UTL_FixedQueue<double> nonlinearSolverMaxNormIndexQueue_;
164  // N_UTL_FixedQueue<double> nonlinearSolverNormQueue_;
165 
166  // solution variable names vector, used in outputting Queued data.
167  std::vector<std::string> nameVec_;
168 
169  bool firstTime;
171  double startSimTime;
172  int dcStats;
174 
175  RefCountPtr< N_IO_RestartMgr > restartMgrRCPtr_;
176 
177  // Sensitivity data. This will need a refactor to work in transient, but for
178  // now this needs to be here to compile.
179  std::vector<double> objectiveVec_;
180  std::vector<double> dOdpVec_;
181  std::vector<double> dOdpAdjVec_;
182  std::vector<double> scaled_dOdpVec_;
183  std::vector<double> scaled_dOdpAdjVec_;
184 };
185 
186 } // namespace Analysis
187 } // namespace Xyce
188 
190 
191 #endif // Xyce_N_ANP_Transient_h