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.83.2.1 $
41 // Revision Date : $Date: 2015/04/02 18:20:06 $
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_UTL_DFTInterfaceDecl.hpp>
61 #include <N_UTL_FFTInterface.hpp>
62 #include <N_UTL_Listener.h>
63 #include <N_MPDE_Discretization.h>
64 
65 namespace Xyce {
66 namespace Analysis {
67 
68 //-------------------------------------------------------------------------
69 // Class : HB
70 // Purpose : HB analysis class
71 // Special Notes :
72 // Creator : Richard Schiek, SNL, Electrical and Microsystem Modeling
73 // Creation Date : 01/24/08
74 //-------------------------------------------------------------------------
75 class HB : public AnalysisBase, public Util::ListenerAutoSubscribe<StepEvent>
76 {
77 public:
78  HB(
79  AnalysisManager &analysis_manager,
80  Linear::System &linear_system,
81  Nonlinear::Manager &nonlinear_manager,
82  Device::DeviceMgr &device_manager,
83  Linear::Builder &builder,
84  Topo::Topology &topology);
85 
86  virtual ~HB();
87 
88  void notify(const StepEvent &event);
89 
91  static TimeIntg::TIAParams s_tiaParams;
92 
93  return s_tiaParams;
94  }
95 
97  static TimeIntg::TIAParams s_tiaParams;
98 
99  return s_tiaParams;
100  }
101 
102  // Method to set HB options
103  bool setAnalysisParams(const Util::OptionBlock & option_block);
104  bool setHBIntParams(const Util::OptionBlock & option_block);
105 
106  // Method to set HB linear solver / preconditioning options
107  bool setHBLinSol(const Util::OptionBlock & option_block, Linear::Builder &builder);
108 
109  // Method to set non-HB linear solver / preconditioning options (needed for .STEP)
110  bool setLinSol(const Util::OptionBlock & option_block);
111 
112  int getDoubleDCOPStep() const;
113 
114  bool getDCOPFlag() const;
115 
116  bool doRun();
117  bool doInit();
118  bool doLoopProcess();
119  bool processSuccessfulDCOP();
120  bool processFailedDCOP();
122  bool doProcessFailedStep();
123  bool doFinish();
124  bool doHandlePredictor();
125  bool finalVerboseOutput();
126 
127  // Utility function for AnalysisManager to determine if a complex analysis type (like HB)
128  // is performing another type of analysis under the hood. This is necessary for populating
129  // the TimeIntg::TimeIntInfo struct. For straightforward analysis types, this method is not
130  // needed because the AnalysisManager already knows which analysis is being performed.
131  bool isAnalysis( int analysis_type ) const;
132 
133  // Transform the current solution vector for time domain and frequency domain output
134  void prepareHBOutput(Linear::Vector & solnVecPtr,
135  std::vector<double> & timePoints,
136  std::vector<double> & freqPoints,
137  Teuchos::RCP<Linear::BlockVector> & timeDomainSolnVec,
138  Teuchos::RCP<Linear::BlockVector> & freqDomainSolnVecReal,
139  Teuchos::RCP<Linear::BlockVector> & freqDomainSolnVecImaginary,
140  Teuchos::RCP<Linear::BlockVector> & timeDomainStoreVec,
141  Teuchos::RCP<Linear::BlockVector> & freqDomainStoreVecReal,
142  Teuchos::RCP<Linear::BlockVector> & freqDomainStoreVecImaginary,
143  Teuchos::RCP<Linear::BlockVector> & timeDomainLeadCurrentVec,
144  Teuchos::RCP<Linear::BlockVector> & freqDomainLeadCurrentVecReal,
145  Teuchos::RCP<Linear::BlockVector> & freqDomainLeadCurrentVecImaginary,
146  Teuchos::RCP<Linear::BlockVector> & timeDomainJunctionVoltageVec,
147  Teuchos::RCP<Linear::BlockVector> & freqDomainJunctionVoltageVecReal,
148  Teuchos::RCP<Linear::BlockVector> & freqDomainJunctionVoltageVecImaginary ) const;
149 
150 private:
151 
152  // Add in solver info and timing info from current analysisObject_
153  void accumulateStatistics_(AnalysisBase &analysis);
154 
155  bool runTol(TimeIntg::TIAParams &tia_params);
156  bool runStartupPeriods(const TimeIntg::TIAParams &tia_params);
157  bool runTransientIC(const TimeIntg::TIAParams &tia_params);
158  bool interpolateIC(double initial_time);
159 
160  bool setFreqPoints_();
161 
162  bool setInitialGuess();
163 
164  bool setTimePoints_();
165 
166  bool createFT_();
167 
168 private:
171  Linear::System & linearSystem_;
174  Linear::Builder & builder_;
175  Topo::Topology & topology_;
176  N_PDS_Manager * pdsMgrPtr_;
178  Loader::HBLoader * hbLoaderPtr_; /// HB loader, builder, system, and DFT
179  Teuchos::RCP<Linear::HBBuilder> hbBuilderPtr_;
180 
181  Linear::System * hbLinearSystem_;
182 
183  bool isPaused; ///< Flag to indicate of the simulation is paused
184 
185  double startDCOPtime; /// Timing/loop count info
186  double endTRANtime;
187 
188  bool isTransient_; ///< Current analysis state flags
189 
190  bool test_; ///< Testing Flag
191 
192  int size_; /// Problem Size
193 
194  std::vector<double> freqs_;
196 
197  std::vector<int> numPosFreqs;
198  std::vector<int> numFreqs_;
199 
200  double period_; /// Periodicity Information
201 
202  // Number of fast time periods to integrate over and IGNORE before
203  // getting initial conditions for HB. Default is zero.
206 
208 
209 // Transient assisted HB.
210  int taHB_;
211 
214 
215  std::string method_;
216 
218 
219  Teuchos::RCP<N_UTL_FFTInterface<std::vector<double> > > ftInterface_;
220  std::vector<double> ftInData_, ftOutData_, iftInData_, iftOutData_;
221 
222  N_MPDE_Discretization::Type fastTimeDisc_;
224  std::vector<double> fastTimes_;
225  std::vector<double> timeSteps_;
226  std::vector<double> freqPoints_;
227  Teuchos::RCP<N_MPDE_Discretization> mpdeDiscPtr_;
228 
229  // Fourier matrices
230 
231  Teuchos::RCP<N_UTL_DFTInterfaceDecl<std::vector<double> > > dftInterface_;
232  Teuchos::SerialDenseMatrix<int,double> idftMatrix_, dftMatrix_;
233 
234  // Linear solver and nonlinear solver options
235  Util::OptionBlock saved_lsHBOB_;
236  Util::OptionBlock saved_lsOB_;
237  // Util::OptionBlock saved_nlHBOB_;
238 
239  // An analysis-dependent preconditioner factory.
240  Linear::HBPrecondFactory * precFactory_;
241 
242  // Local storage vectors
243  Teuchos::RCP<Linear::Vector> dcOpSolVecPtr_;
244  Teuchos::RCP<Linear::Vector> dcOpStateVecPtr_;
245  Teuchos::RCP<Linear::Vector> dcOpQVecPtr_;
246  Teuchos::RCP<Linear::Vector> dcOpStoreVecPtr_;
247 
248  std::vector<double> goodTimePoints_;
249  std::vector<Teuchos::RCP<Linear::Vector> > goodSolutionVec_;
250  std::vector<Teuchos::RCP<Linear::Vector> > goodStateVec_;
251  std::vector<Teuchos::RCP<Linear::Vector> > goodQVec_;
252  std::vector<Teuchos::RCP<Linear::Vector> > goodStoreVec_;
253 
254  // HB initial condition
255  Teuchos::RCP<Linear::BlockVector> HBICVectorPtr_;
256  Teuchos::RCP<Linear::BlockVector> HBICVectorFreqPtr_;
257  Teuchos::RCP<Linear::BlockVector> HBICStateVectorPtr_; ///< HB initial state condition
258  Teuchos::RCP<Linear::BlockVector> HBICQVectorPtr_; ///< HB initial Q condition
259  Teuchos::RCP<Linear::BlockVector> HBICStoreVectorPtr_; ///< HB initial store condition
260 
261  // HB statistics
263 
265 };
266 
267 bool registerHBFactory(
268  const std::string & netlist_filename,
269  IO::PkgOptionsMgr & options_manager,
270  AnalysisManager & analysis_manager,
271  Linear::System & linear_system,
272  Nonlinear::Manager & nonlinear_manager,
273  Device::DeviceMgr & device_manager,
274  Linear::Builder & builder,
275  Topo::Topology & topology);
276 
277 } // namespace Analysis
278 } // namespace Xyce
279 
280 #endif // Xyce_N_ANP_HB_h
281 
void accumulateStatistics_(AnalysisBase &analysis)
Definition: N_ANP_HB.C:1023
Util::OptionBlock saved_lsHBOB_
Definition: N_ANP_HB.h:235
Linear::HBPrecondFactory * precFactory_
Definition: N_ANP_HB.h:240
bool processFailedDCOP()
Definition: N_ANP_HB.C:591
AnalysisBase * currentAnalysisObject_
Definition: N_ANP_HB.h:177
Teuchos::RCP< Linear::BlockVector > HBICQVectorPtr_
HB initial Q condition.
Definition: N_ANP_HB.h:258
Teuchos::RCP< N_MPDE_Discretization > mpdeDiscPtr_
Definition: N_ANP_HB.h:227
Linear::Builder & builder_
Definition: N_ANP_HB.h:174
Teuchos::SerialDenseMatrix< int, double > dftMatrix_
Definition: N_ANP_HB.h:232
Loader::Loader & loader_
Definition: N_ANP_HB.h:170
std::vector< double > freqs_
Problem Size.
Definition: N_ANP_HB.h:194
Teuchos::RCP< Linear::Vector > dcOpStateVecPtr_
Definition: N_ANP_HB.h:244
std::vector< int > numFreqs_
Definition: N_ANP_HB.h:198
HB(AnalysisManager &analysis_manager, Linear::System &linear_system, Nonlinear::Manager &nonlinear_manager, Device::DeviceMgr &device_manager, Linear::Builder &builder, Topo::Topology &topology)
Definition: N_ANP_HB.C:98
bool startUpPeriodsGiven_
Definition: N_ANP_HB.h:205
Pure virtual class to augment a linear system.
std::vector< double > freqPoints_
Definition: N_ANP_HB.h:226
bool test_
Testing Flag.
Definition: N_ANP_HB.h:190
bool isTransient_
Current analysis state flags.
Definition: N_ANP_HB.h:188
bool setAnalysisParams(const Util::OptionBlock &option_block)
Definition: N_ANP_HB.C:638
double startDCOPtime
Definition: N_ANP_HB.h:185
std::string method_
Definition: N_ANP_HB.h:215
std::vector< double > iftOutData_
Definition: N_ANP_HB.h:220
Teuchos::RCP< Linear::Vector > dcOpSolVecPtr_
Definition: N_ANP_HB.h:243
bool isAnalysis(int analysis_type) const
Definition: N_ANP_HB.C:803
std::vector< double > timeSteps_
Definition: N_ANP_HB.h:225
bool isPaused
Flag to indicate of the simulation is paused.
Definition: N_ANP_HB.h:183
AnalysisManager & analysisManager_
Definition: N_ANP_HB.h:169
std::vector< double > ftInData_
Definition: N_ANP_HB.h:220
Teuchos::SerialDenseMatrix< int, double > idftMatrix_
Definition: N_ANP_HB.h:232
N_PDS_Manager * pdsMgrPtr_
Definition: N_ANP_HB.h:176
std::vector< double > ftOutData_
Definition: N_ANP_HB.h:220
Teuchos::RCP< Linear::HBBuilder > hbBuilderPtr_
HB loader, builder, system, and DFT.
Definition: N_ANP_HB.h:179
Device::DeviceMgr & deviceManager_
Definition: N_ANP_HB.h:173
bool registerHBFactory(const std::string &netlist_filename, IO::PkgOptionsMgr &options_manager, AnalysisManager &analysis_manager, Linear::System &linear_system, Nonlinear::Manager &nonlinear_manager, Device::DeviceMgr &device_manager, Linear::Builder &builder, Topo::Topology &topology)
Definition: N_ANP_HB.C:2159
std::vector< Teuchos::RCP< Linear::Vector > > goodStateVec_
Definition: N_ANP_HB.h:250
bool doLoopProcess()
Definition: N_ANP_HB.C:499
Linear::System * hbLinearSystem_
Definition: N_ANP_HB.h:181
bool interpolateIC(double initial_time)
Definition: N_ANP_HB.C:1766
bool runStartupPeriods(const TimeIntg::TIAParams &tia_params)
Definition: N_ANP_HB.C:1607
bool setLinSol(const Util::OptionBlock &option_block)
Definition: N_ANP_HB.C:766
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< Teuchos::RCP< Linear::Vector > > goodStoreVec_
Definition: N_ANP_HB.h:252
Teuchos::RCP< Linear::Vector > dcOpStoreVecPtr_
Definition: N_ANP_HB.h:246
Teuchos::RCP< Linear::BlockVector > HBICVectorPtr_
Definition: N_ANP_HB.h:255
bool doProcessFailedStep()
Definition: N_ANP_HB.C:578
int getDoubleDCOPStep() const
Definition: N_ANP_HB.C:222
bool resetForStepCalledBefore_
Definition: N_ANP_HB.h:264
Teuchos::RCP< Linear::BlockVector > HBICStoreVectorPtr_
HB initial store condition.
Definition: N_ANP_HB.h:259
std::vector< int > numPosFreqs
Definition: N_ANP_HB.h:197
Teuchos::RCP< N_UTL_DFTInterfaceDecl< std::vector< double > > > dftInterface_
Definition: N_ANP_HB.h:231
int startUpPeriods_
Periodicity Information.
Definition: N_ANP_HB.h:204
TimeIntg::TIAParams & getTIAParams()
Definition: N_ANP_HB.h:96
bool runTol(TimeIntg::TIAParams &tia_params)
Definition: N_ANP_HB.C:1507
N_MPDE_Discretization::Type fastTimeDisc_
Definition: N_ANP_HB.h:222
Teuchos::RCP< Linear::Vector > dcOpQVecPtr_
Definition: N_ANP_HB.h:245
Teuchos::RCP< Linear::BlockVector > HBICVectorFreqPtr_
Definition: N_ANP_HB.h:256
const TimeIntg::TIAParams & getTIAParams() const
Definition: N_ANP_HB.h:90
Util::OptionBlock saved_lsOB_
Definition: N_ANP_HB.h:236
virtual ~HB()
Definition: N_ANP_HB.C:150
bool setFreqPoints_()
Definition: N_ANP_HB.C:1036
bool setInitialGuess()
Definition: N_ANP_HB.C:1440
std::vector< double > iftInData_
Definition: N_ANP_HB.h:220
bool getDCOPFlag() const
Definition: N_ANP_HB.C:238
Loader::HBLoader * hbLoaderPtr_
Definition: N_ANP_HB.h:178
Topo::Topology & topology_
Definition: N_ANP_HB.h:175
StatCounts hbStatCounts_
Definition: N_ANP_HB.h:262
Teuchos::RCP< Linear::BlockVector > HBICStateVectorPtr_
HB initial state condition.
Definition: N_ANP_HB.h:257
std::vector< double > goodTimePoints_
Definition: N_ANP_HB.h:248
bool processSuccessfulDCOP()
Definition: N_ANP_HB.C:552
Linear::System & linearSystem_
Definition: N_ANP_HB.h:171
std::vector< Teuchos::RCP< Linear::Vector > > goodQVec_
Definition: N_ANP_HB.h:251
bool doProcessSuccessfulStep()
Definition: N_ANP_HB.C:565
bool setHBIntParams(const Util::OptionBlock &option_block)
Definition: N_ANP_HB.C:678
bool runTransientIC(const TimeIntg::TIAParams &tia_params)
Definition: N_ANP_HB.C:1688
Teuchos::RCP< N_UTL_FFTInterface< std::vector< double > > > ftInterface_
Definition: N_ANP_HB.h:219
bool setTimePoints_()
Definition: N_ANP_HB.C:1281
std::vector< Teuchos::RCP< Linear::Vector > > goodSolutionVec_
Definition: N_ANP_HB.h:249
bool setHBLinSol(const Util::OptionBlock &option_block, Linear::Builder &builder)
Definition: N_ANP_HB.C:782
Nonlinear::Manager & nonlinearManager_
Definition: N_ANP_HB.h:172
double endTRANtime
Timing/loop count info.
Definition: N_ANP_HB.h:186
bool finalVerboseOutput()
Definition: N_ANP_HB.C:624
bool doHandlePredictor()
Definition: N_ANP_HB.C:611
std::vector< double > fastTimes_
Definition: N_ANP_HB.h:224
void notify(const StepEvent &event)
Definition: N_ANP_HB.C:165