Xyce  6.1
N_ANP_AC.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_AC.h,v $
27 //
28 // Purpose : AC 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 : Ting Mei
34 //
35 // Creation Date : 01/11
36 //
37 // Revision Information:
38 // ---------------------
39 //
40 // Revision Number: $Revision: 1.50 $
41 // Revision Date : $Date: 2015/10/27 19:24:39 $
42 // Current Owner : $Author: tvrusso $
43 //-----------------------------------------------------------------------------
44 
45 #ifndef Xyce_N_ANP_AC_h
46 #define Xyce_N_ANP_AC_h
47 
48 #include <N_ANP_fwd.h>
49 #include <N_UTL_fwd.h>
50 #include <N_LAS_fwd.h>
51 #include <N_TOP_fwd.h>
52 
53 #include <N_ANP_AnalysisBase.h>
54 #include <N_ANP_RegisterAnalysis.h>
55 #include <N_ANP_StepEvent.h>
56 #include <N_TIA_TIAParams.h>
57 #include <N_UTL_FixedQueue.h>
58 #include <N_UTL_Listener.h>
59 #include <N_UTL_OptionBlock.h>
60 
61 // ---------- Forward Declarations ----------
62 class Amesos_BaseSolver;
63 class Epetra_LinearProblem;
64 
65 namespace Xyce {
66 namespace Analysis {
67 
68 //-------------------------------------------------------------------------
69 // Class : AC
70 // Purpose : AC analysis class
71 // Special Notes :
72 // Creator : Ting Mei
73 // Creation Date : 05/24/11
74 //-------------------------------------------------------------------------
75 class AC: public AnalysisBase, public Util::ListenerAutoSubscribe<StepEvent>
76 {
77 public:
78  AC(
79  AnalysisManager & analysis_manager,
80  Linear::System & linear_system,
81  Nonlinear::Manager & nonlinear_manager,
82  Loader::Loader & loader,
83  Topo::Topology & topology,
84  IO::InitialConditionsManager & initial_conditions_manager);
85 
86  virtual ~AC();
87 
88  void notify(const StepEvent &event);
89 
90  void setTIAParams(const TimeIntg::TIAParams &tia_params)
91  {
92  tiaParams_ = tia_params;
93  }
94 
96  {
97  return tiaParams_;
98  }
99 
101  {
102  return tiaParams_;
103  }
104 
105  bool setAnalysisParams(const Util::OptionBlock & paramsBlock);
106  bool setTimeIntegratorOptions(const Util::OptionBlock &option_block);
107 
108  bool getDCOPFlag() const;
109 
110 protected:
111  bool doRun();
112  bool doInit();
113  bool doLoopProcess();
115  bool doProcessFailedStep();
116  bool doFinish();
117  bool doHandlePredictor();
118 
119  void printStepHeader(std::ostream &os)
120  {}
121 
122  void printProgress(std::ostream &os)
123  {}
124 
125 private:
126  int setupSweepParam_();
127 
128  bool updateCurrentFreq_(int stepNumber);
129 
130  bool createLinearSystem_();
131 
133 
134  bool solveLinearSystem_();
135 
136 private:
139  Linear::System & linearSystem_;
141  Topo::Topology & topology_;
142  IO::InitialConditionsManager & initialConditionsManager_;
145 
146  Linear::Vector * bVecRealPtr;
147  Linear::Vector * bVecImagPtr;
148 
150 
151  std::vector<int> acSweepFailures_;
152 
153  bool stepFlag_;
154  std::string type_;
155  double np_;
156  double fStart_;
157  double fStop_;
158  double stepMult_;
159  double fstep_;
160 
161  double currentFreq_;
162 
163  Linear::Matrix * C_;
164  Linear::Matrix * G_;
165  Linear::BlockMatrix * ACMatrix_;
166  Linear::BlockVector * B_;
167  Linear::BlockVector * X_;
168 
169  Amesos_BaseSolver * blockSolver_;
170  Epetra_LinearProblem * blockProblem_;
171 
172  std::vector<double> objectiveVec_;
173  std::vector<double> dOdpVec_;
174  std::vector<double> dOdpAdjVec_;
175  std::vector<double> scaled_dOdpVec_;
176  std::vector<double> scaled_dOdpAdjVec_;
177 };
178 
179 bool registerACFactory(FactoryBlock &factory_block);
180 
181 } // namespace Analysis
182 } // namespace Xyce
183 
184 #endif // Xyce_N_ANP_AC_h
bool doProcessSuccessfulStep()
Definition: N_ANP_AC.C:639
bool doHandlePredictor()
Definition: N_ANP_AC.C:717
bool registerACFactory(FactoryBlock &factory_block)
Definition: N_ANP_AC.C:1062
bool getDCOPFlag() const
Definition: N_ANP_AC.C:271
bool createLinearSystem_()
Definition: N_ANP_AC.C:500
bool setAnalysisParams(const Util::OptionBlock &paramsBlock)
Definition: N_ANP_AC.C:226
bool doLoopProcess()
Definition: N_ANP_AC.C:388
Linear::Matrix * C_
Definition: N_ANP_AC.h:163
void setTIAParams(const TimeIntg::TIAParams &tia_params)
Definition: N_ANP_AC.h:90
Pure virtual class to augment a linear system.
TimeIntg::TIAParams tiaParams_
Definition: N_ANP_AC.h:144
TimeIntg::TIAParams & getTIAParams()
Definition: N_ANP_AC.h:100
unsigned int stepNumber
Time-integration step number counter.
bool doProcessFailedStep()
Definition: N_ANP_AC.C:670
double currentFreq_
Definition: N_ANP_AC.h:161
virtual ~AC()
Definition: N_ANP_AC.C:184
std::vector< int > acSweepFailures_
Definition: N_ANP_AC.h:151
bool setTimeIntegratorOptions(const Util::OptionBlock &option_block)
Definition: N_ANP_AC.C:108
Linear::Vector * bVecRealPtr
Definition: N_ANP_AC.h:146
Linear::BlockVector * B_
Definition: N_ANP_AC.h:166
int setupSweepParam_()
Definition: N_ANP_AC.C:771
Topo::Topology & topology_
Definition: N_ANP_AC.h:141
std::vector< double > scaled_dOdpVec_
Definition: N_ANP_AC.h:175
std::string type_
Definition: N_ANP_AC.h:154
std::vector< double > dOdpAdjVec_
Definition: N_ANP_AC.h:174
Amesos_BaseSolver * blockSolver_
Definition: N_ANP_AC.h:169
Nonlinear::Manager & nonlinearManager_
Definition: N_ANP_AC.h:140
AC(AnalysisManager &analysis_manager, Linear::System &linear_system, Nonlinear::Manager &nonlinear_manager, Loader::Loader &loader, Topo::Topology &topology, IO::InitialConditionsManager &initial_conditions_manager)
Definition: N_ANP_AC.C:139
OutputMgrAdapter & outputManagerAdapter_
Definition: N_ANP_AC.h:143
The FactoryBlock contains parameters needed by the analysis creation functions.
const TimeIntg::TIAParams & getTIAParams() const
Definition: N_ANP_AC.h:95
bool updateCurrentFreq_(int stepNumber)
Definition: N_ANP_AC.C:743
std::vector< double > scaled_dOdpAdjVec_
Definition: N_ANP_AC.h:176
IO::InitialConditionsManager & initialConditionsManager_
Definition: N_ANP_AC.h:142
Linear::BlockVector * X_
Definition: N_ANP_AC.h:167
Linear::System & linearSystem_
Definition: N_ANP_AC.h:139
bool updateLinearSystemFreq_()
Definition: N_ANP_AC.C:582
AnalysisManager & analysisManager_
Definition: N_ANP_AC.h:137
std::vector< double > objectiveVec_
Definition: N_ANP_AC.h:172
Linear::Vector * bVecImagPtr
Definition: N_ANP_AC.h:147
Linear::BlockMatrix * ACMatrix_
Definition: N_ANP_AC.h:165
void printProgress(std::ostream &os)
Definition: N_ANP_AC.h:122
std::vector< double > dOdpVec_
Definition: N_ANP_AC.h:173
bool solveLinearSystem_()
Definition: N_ANP_AC.C:608
void printStepHeader(std::ostream &os)
Definition: N_ANP_AC.h:119
Epetra_LinearProblem * blockProblem_
Definition: N_ANP_AC.h:170
void notify(const StepEvent &event)
Definition: N_ANP_AC.C:203
Loader::Loader & loader_
Definition: N_ANP_AC.h:138
Linear::Matrix * G_
Definition: N_ANP_AC.h:164