Xyce  6.1
N_ANP_HB.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-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_HB.h,v $
27 //
28 // Purpose : HB 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 : Todd Coffey, 1414, Ting Mei 1437
34 //
35 // Creation Date : 07/23/08
36 //
37 // Revision Information:
38 // ---------------------
39 //
40 // Revision Number: $Revision: 1.99 $
41 // Revision Date : $Date: 2015/10/27 19:24:39 $
42 // Current Owner : $Author: tvrusso $
43 //-----------------------------------------------------------------------------
44 
45 #ifndef Xyce_N_ANP_HB_h
46 #define Xyce_N_ANP_HB_h
47 
48 #include <vector>
49 
50 #include <Teuchos_SerialDenseMatrix.hpp>
51 #include <Teuchos_RCP.hpp>
52 
53 #include <N_ANP_fwd.h>
54 #include <N_LOA_fwd.h>
55 #include <N_LAS_fwd.h>
56 #include <N_TOP_fwd.h>
57 
58 #include <N_ANP_AnalysisBase.h>
59 #include <N_ANP_StepEvent.h>
60 #include <N_ANP_RegisterAnalysis.h>
61 #include <N_UTL_DFTInterfaceDecl.hpp>
62 #include <N_UTL_FFTInterface.hpp>
63 #include <N_UTL_Listener.h>
64 #include <N_UTL_OptionBlock.h>
65 #include <N_MPDE_Discretization.h>
66 
67 namespace Xyce {
68 namespace Analysis {
69 
70 //-------------------------------------------------------------------------
71 // Class : HB
72 // Purpose : HB analysis class
73 // Special Notes :
74 // Creator : Richard Schiek, SNL, Electrical and Microsystem Modeling
75 // Creation Date : 01/24/08
76 //-------------------------------------------------------------------------
77 class HB : public AnalysisBase, public Util::ListenerAutoSubscribe<StepEvent>
78 {
79 public:
80  HB(
81  AnalysisManager & analysis_manager,
82  Linear::System & linear_system,
83  Nonlinear::Manager & nonlinear_manager,
84  Loader::Loader & loader,
85  Device::DeviceMgr & device_manager,
86  Linear::Builder & builder,
87  Topo::Topology & topology,
88  IO::InitialConditionsManager & initial_conditions_manager,
89  IO::RestartMgr & restart_manager);
90 
91  virtual ~HB();
92 
93  void notify(const StepEvent &event);
94 
96  {
97  static TimeIntg::TIAParams s_tiaParams;
98 
99  return s_tiaParams;
100  }
101 
103  {
104  static TimeIntg::TIAParams s_tiaParams;
105 
106  return s_tiaParams;
107  }
108 
109  // Method to set HB options
110  bool setAnalysisParams(const Util::OptionBlock & option_block);
111  bool setHBIntParams(const Util::OptionBlock & option_block);
112 
113  // Method to set HB linear solver / preconditioning options
114  bool setHBLinSol(const Util::OptionBlock & option_block, Linear::Builder &builder);
115 
116  // Method to set non-HB linear solver / preconditioning options (needed for .STEP)
117  bool setLinSol(const Util::OptionBlock & option_block);
118 
119  int getDoubleDCOPStep() const;
120 
121  bool getDCOPFlag() const;
122 
123 protected:
124  bool doRun();
125  bool doInit();
126  bool doLoopProcess();
128  bool doProcessFailedStep();
129  bool doFinish();
130  bool doHandlePredictor();
131  bool finalVerboseOutput();
132 
133 private:
134  bool processSuccessfulDCOP();
135  bool processFailedDCOP();
136 
137 public:
138  bool isAnalysis( int analysis_type ) const;
139 
140  // Transform the current solution vector for time domain and frequency domain output
141  void prepareHBOutput(Linear::Vector & solnVecPtr,
142  std::vector<double> & timePoints,
143  std::vector<double> & freqPoints,
144  Teuchos::RCP<Linear::BlockVector> & timeDomainSolnVec,
145  Teuchos::RCP<Linear::BlockVector> & freqDomainSolnVecReal,
146  Teuchos::RCP<Linear::BlockVector> & freqDomainSolnVecImaginary,
147  Teuchos::RCP<Linear::BlockVector> & timeDomainStoreVec,
148  Teuchos::RCP<Linear::BlockVector> & freqDomainStoreVecReal,
149  Teuchos::RCP<Linear::BlockVector> & freqDomainStoreVecImaginary,
150  Teuchos::RCP<Linear::BlockVector> & timeDomainLeadCurrentVec,
151  Teuchos::RCP<Linear::BlockVector> & freqDomainLeadCurrentVecReal,
152  Teuchos::RCP<Linear::BlockVector> & freqDomainLeadCurrentVecImaginary,
153  Teuchos::RCP<Linear::BlockVector> & timeDomainJunctionVoltageVec,
154  Teuchos::RCP<Linear::BlockVector> & freqDomainJunctionVoltageVecReal,
155  Teuchos::RCP<Linear::BlockVector> & freqDomainJunctionVoltageVecImaginary ) ;
156 
157 private:
158 
159  // Add in solver info and timing info from current analysisObject_
160  void accumulateStatistics_(AnalysisBase &analysis);
161 
162  bool runTol(TimeIntg::TIAParams &tia_params);
163  bool runStartupPeriods(const TimeIntg::TIAParams &tia_params);
164  bool runTransientIC(const TimeIntg::TIAParams &tia_params);
165  bool interpolateIC(double initial_time);
166 
167  bool setFreqPoints_();
168 
169  bool setInitialGuess();
170 
171  bool setTimePoints_();
172 
173  bool createFT_();
174 
175 
176  bool updateIFT_( std::vector<double>& tPoints);
177 private:
180  Linear::System & linearSystem_;
183  Linear::Builder & builder_;
184  Topo::Topology & topology_;
185  IO::InitialConditionsManager & initialConditionsManager_;
186  IO::RestartMgr & restartManager_;
187  N_PDS_Manager * pdsMgrPtr_;
189  Loader::HBLoader * hbLoaderPtr_; /// HB loader, builder, system, and DFT
190  Teuchos::RCP<Linear::HBBuilder> hbBuilderPtr_;
191  Linear::System * hbLinearSystem_;
192 
193  bool isPaused; ///< Flag to indicate of the simulation is paused
194 
195  double startDCOPtime; /// Timing/loop count info
196  double endTRANtime;
197 
198  bool isTransient_; ///< Current analysis state flags
199 
200  bool test_; ///< Testing Flag
201 
202  int size_; /// Problem Size
203 
204  std::vector<double> freqs_;
206 
207  std::vector<int> numPosFreqs;
208  std::vector<int> numFreqs_;
209 
210  double period_; /// Periodicity Information
211 
212  // Number of fast time periods to integrate over and IGNORE before
213  // getting initial conditions for HB. Default is zero.
216 
218 
219 // Transient assisted HB.
220  int taHB_;
221 
225 
226  std::string method_;
227 
229 
230  Teuchos::RCP<N_UTL_FFTInterface<std::vector<double> > > ftInterface_;
231  std::vector<double> ftInData_, ftOutData_, iftInData_, iftOutData_;
232 
233  N_MPDE_Discretization::Type fastTimeDisc_;
234  int fastTimeDiscOrder_; // remove
235  std::vector<double> fastTimes_;
236  std::vector<double> timeSteps_;
237  std::vector<double> freqPoints_;
238  Teuchos::RCP<N_MPDE_Discretization> mpdeDiscPtr_;
239 
240  // Fourier matrices
241  Teuchos::RCP<N_UTL_DFTInterfaceDecl<std::vector<double> > > dftInterface_;
242  Teuchos::SerialDenseMatrix<int,double> idftMatrix_, dftMatrix_;
243 
244  // Linear solver and nonlinear solver options
245  Util::OptionBlock saved_lsHBOB_;
246  Util::OptionBlock saved_lsOB_;
247 
248  // An analysis-dependent preconditioner factory.
249  Linear::HBPrecondFactory * precFactory_;
250 
251  // Local storage vectors
252  Teuchos::RCP<Linear::Vector> dcOpSolVecPtr_;
253  Teuchos::RCP<Linear::Vector> dcOpStateVecPtr_;
254  Teuchos::RCP<Linear::Vector> dcOpQVecPtr_;
255  Teuchos::RCP<Linear::Vector> dcOpStoreVecPtr_;
256 
257  std::vector<double> goodTimePoints_;
258  std::vector<Teuchos::RCP<Linear::Vector> > goodSolutionVec_;
259  std::vector<Teuchos::RCP<Linear::Vector> > goodStateVec_;
260  std::vector<Teuchos::RCP<Linear::Vector> > goodQVec_;
261  std::vector<Teuchos::RCP<Linear::Vector> > goodStoreVec_;
262 
263  // HB initial condition
264  Teuchos::RCP<Linear::BlockVector> HBICVectorPtr_;
265  Teuchos::RCP<Linear::BlockVector> HBICVectorFreqPtr_;
266  Teuchos::RCP<Linear::BlockVector> HBICStateVectorPtr_; ///< HB initial state condition
267  Teuchos::RCP<Linear::BlockVector> HBICQVectorPtr_; ///< HB initial Q condition
268  Teuchos::RCP<Linear::BlockVector> HBICStoreVectorPtr_; ///< HB initial store condition
269 
270  // HB statistics
272 
274 };
275 
276 bool registerHBFactory(FactoryBlock &factory_block);
277 
278 } // namespace Analysis
279 } // namespace Xyce
280 
281 #endif // Xyce_N_ANP_HB_h
282 
void accumulateStatistics_(AnalysisBase &analysis)
Definition: N_ANP_HB.C:1098
Util::OptionBlock saved_lsHBOB_
Definition: N_ANP_HB.h:245
Linear::HBPrecondFactory * precFactory_
Definition: N_ANP_HB.h:249
bool processFailedDCOP()
Definition: N_ANP_HB.C:595
AnalysisBase * currentAnalysisObject_
Definition: N_ANP_HB.h:188
Teuchos::RCP< Linear::BlockVector > HBICQVectorPtr_
HB initial Q condition.
Definition: N_ANP_HB.h:267
Teuchos::RCP< N_MPDE_Discretization > mpdeDiscPtr_
Definition: N_ANP_HB.h:238
Linear::Builder & builder_
Definition: N_ANP_HB.h:183
Teuchos::SerialDenseMatrix< int, double > dftMatrix_
Definition: N_ANP_HB.h:242
Loader::Loader & loader_
Definition: N_ANP_HB.h:179
std::vector< double > freqs_
Problem Size.
Definition: N_ANP_HB.h:204
Teuchos::RCP< Linear::Vector > dcOpStateVecPtr_
Definition: N_ANP_HB.h:253
std::vector< int > numFreqs_
Definition: N_ANP_HB.h:208
bool startUpPeriodsGiven_
Definition: N_ANP_HB.h:215
IO::InitialConditionsManager & initialConditionsManager_
Definition: N_ANP_HB.h:185
Pure virtual class to augment a linear system.
std::vector< double > freqPoints_
Definition: N_ANP_HB.h:237
bool test_
Testing Flag.
Definition: N_ANP_HB.h:200
bool isTransient_
Current analysis state flags.
Definition: N_ANP_HB.h:198
bool setAnalysisParams(const Util::OptionBlock &option_block)
Definition: N_ANP_HB.C:642
double startDCOPtime
Definition: N_ANP_HB.h:195
std::string method_
Definition: N_ANP_HB.h:226
std::vector< double > iftOutData_
Definition: N_ANP_HB.h:231
Teuchos::RCP< Linear::Vector > dcOpSolVecPtr_
Definition: N_ANP_HB.h:252
bool isAnalysis(int analysis_type) const
Definition: N_ANP_HB.C:812
std::vector< double > timeSteps_
Definition: N_ANP_HB.h:236
bool isPaused
Flag to indicate of the simulation is paused.
Definition: N_ANP_HB.h:193
AnalysisManager & analysisManager_
Definition: N_ANP_HB.h:178
std::vector< double > ftInData_
Definition: N_ANP_HB.h:231
Teuchos::SerialDenseMatrix< int, double > idftMatrix_
Definition: N_ANP_HB.h:242
N_PDS_Manager * pdsMgrPtr_
Definition: N_ANP_HB.h:187
std::vector< double > ftOutData_
Definition: N_ANP_HB.h:231
Teuchos::RCP< Linear::HBBuilder > hbBuilderPtr_
HB loader, builder, system, and DFT.
Definition: N_ANP_HB.h:190
bool updateIFT_(std::vector< double > &tPoints)
Definition: N_ANP_HB.C:1581
Device::DeviceMgr & deviceManager_
Definition: N_ANP_HB.h:182
std::vector< Teuchos::RCP< Linear::Vector > > goodStateVec_
Definition: N_ANP_HB.h:259
bool doLoopProcess()
Definition: N_ANP_HB.C:500
Linear::System * hbLinearSystem_
Definition: N_ANP_HB.h:191
bool interpolateIC(double initial_time)
Definition: N_ANP_HB.C:1879
bool runStartupPeriods(const TimeIntg::TIAParams &tia_params)
Definition: N_ANP_HB.C:1730
bool setLinSol(const Util::OptionBlock &option_block)
Definition: N_ANP_HB.C:775
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)
Definition: N_ANP_HB.C:825
std::vector< Teuchos::RCP< Linear::Vector > > goodStoreVec_
Definition: N_ANP_HB.h:261
Teuchos::RCP< Linear::Vector > dcOpStoreVecPtr_
Definition: N_ANP_HB.h:255
Teuchos::RCP< Linear::BlockVector > HBICVectorPtr_
Definition: N_ANP_HB.h:264
bool doProcessFailedStep()
Definition: N_ANP_HB.C:582
int getDoubleDCOPStep() const
Definition: N_ANP_HB.C:230
bool resetForStepCalledBefore_
Definition: N_ANP_HB.h:273
Teuchos::RCP< Linear::BlockVector > HBICStoreVectorPtr_
HB initial store condition.
Definition: N_ANP_HB.h:268
std::vector< int > numPosFreqs
Definition: N_ANP_HB.h:207
The FactoryBlock contains parameters needed by the analysis creation functions.
Teuchos::RCP< N_UTL_DFTInterfaceDecl< std::vector< double > > > dftInterface_
Definition: N_ANP_HB.h:241
int startUpPeriods_
Periodicity Information.
Definition: N_ANP_HB.h:214
TimeIntg::TIAParams & getTIAParams()
Definition: N_ANP_HB.h:102
bool runTol(TimeIntg::TIAParams &tia_params)
Definition: N_ANP_HB.C:1620
N_MPDE_Discretization::Type fastTimeDisc_
Definition: N_ANP_HB.h:233
Teuchos::RCP< Linear::Vector > dcOpQVecPtr_
Definition: N_ANP_HB.h:254
Teuchos::RCP< Linear::BlockVector > HBICVectorFreqPtr_
Definition: N_ANP_HB.h:265
const TimeIntg::TIAParams & getTIAParams() const
Definition: N_ANP_HB.h:95
Util::OptionBlock saved_lsOB_
Definition: N_ANP_HB.h:246
virtual ~HB()
Definition: N_ANP_HB.C:159
bool setFreqPoints_()
Definition: N_ANP_HB.C:1111
bool setInitialGuess()
Definition: N_ANP_HB.C:1515
std::vector< double > iftInData_
Definition: N_ANP_HB.h:231
bool getDCOPFlag() const
Definition: N_ANP_HB.C:246
Loader::HBLoader * hbLoaderPtr_
Definition: N_ANP_HB.h:189
Topo::Topology & topology_
Definition: N_ANP_HB.h:184
HB(AnalysisManager &analysis_manager, Linear::System &linear_system, Nonlinear::Manager &nonlinear_manager, Loader::Loader &loader, Device::DeviceMgr &device_manager, Linear::Builder &builder, Topo::Topology &topology, IO::InitialConditionsManager &initial_conditions_manager, IO::RestartMgr &restart_manager)
Definition: N_ANP_HB.C:101
StatCounts hbStatCounts_
Definition: N_ANP_HB.h:271
Teuchos::RCP< Linear::BlockVector > HBICStateVectorPtr_
HB initial state condition.
Definition: N_ANP_HB.h:266
std::vector< double > goodTimePoints_
Definition: N_ANP_HB.h:257
bool processSuccessfulDCOP()
Definition: N_ANP_HB.C:556
Linear::System & linearSystem_
Definition: N_ANP_HB.h:180
std::vector< Teuchos::RCP< Linear::Vector > > goodQVec_
Definition: N_ANP_HB.h:260
IO::RestartMgr & restartManager_
Definition: N_ANP_HB.h:186
bool doProcessSuccessfulStep()
Definition: N_ANP_HB.C:569
bool setHBIntParams(const Util::OptionBlock &option_block)
Definition: N_ANP_HB.C:682
bool runTransientIC(const TimeIntg::TIAParams &tia_params)
Definition: N_ANP_HB.C:1811
Teuchos::RCP< N_UTL_FFTInterface< std::vector< double > > > ftInterface_
Definition: N_ANP_HB.h:230
bool setTimePoints_()
Definition: N_ANP_HB.C:1356
std::vector< Teuchos::RCP< Linear::Vector > > goodSolutionVec_
Definition: N_ANP_HB.h:258
bool setHBLinSol(const Util::OptionBlock &option_block, Linear::Builder &builder)
Definition: N_ANP_HB.C:791
Nonlinear::Manager & nonlinearManager_
Definition: N_ANP_HB.h:181
double endTRANtime
Timing/loop count info.
Definition: N_ANP_HB.h:196
bool finalVerboseOutput()
Definition: N_ANP_HB.C:628
bool doHandlePredictor()
Definition: N_ANP_HB.C:615
std::vector< double > fastTimes_
Definition: N_ANP_HB.h:235
void notify(const StepEvent &event)
Definition: N_ANP_HB.C:174
bool registerHBFactory(FactoryBlock &factory_block)
Definition: N_ANP_HB.C:2340