Xyce  6.1
N_ANP_NOISE.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-NOISE04-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_NOISE.h,v $
27 //
28 // Purpose : NOISE 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 : Eric Keiter
34 //
35 // Creation Date : 01/11
36 //
37 // Revision Information:
38 // ---------------------
39 //
40 // Revision Number: $Revision: 1.18 $
41 // Revision Date : $Date: 2015/10/27 19:24:39 $
42 // Current Owner : $Author: tvrusso $
43 //-----------------------------------------------------------------------------
44 
45 #ifndef Xyce_N_ANP_NOISE_h
46 #define Xyce_N_ANP_NOISE_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 : NOISE
70 // Purpose : NOISE analysis class
71 // Special Notes :
72 // Creator : Eric Keiter
73 // Creation Date : 12/8/2014
74 //-------------------------------------------------------------------------
75 class NOISE: public AnalysisBase, public Util::ListenerAutoSubscribe<StepEvent>
76 {
77  public:
78  NOISE(
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  ~NOISE();
87 
88  void notify(const StepEvent &event);
89 
91  {
92  return tiaParams_;
93  }
94 
96  {
97  return tiaParams_;
98  }
99 
100  bool setAnalysisParams(const Util::OptionBlock & paramsBlock);
101  bool setTimeIntegratorOptions(const Util::OptionBlock &option_block);
102 
103  bool getDCOPFlag() const;
104 
105 protected:
106  bool doRun();
107  bool doInit();
108  bool doLoopProcess();
110  bool doProcessFailedStep();
111  bool doFinish();
112  bool doHandlePredictor();
113 
114 public:
115  void printStepHeader(std::ostream &os)
116  {}
117 
118  void printProgress(std::ostream &os)
119  {}
120 
121 private:
122  int setupSweepParam_();
123 
124  bool updateCurrentFreq_(int stepNumber);
125 
126  bool createACLinearSystem_();
127 
128  bool resetACLinearSystem_();
129 
130  bool solveACLinearSystem_();
131 
132  bool solveDirectNOISE_();
133 
135  bool solveAdjointNOISE_();
136  void setupAdjointRHS_();
137 
138  double noiseIntegral( double noizDens, double lnNdens, double lnNlstDens,
139  double delLnFreq, double delFreq, double lnFreq, double lnLastFreq);
140 
141  void processOutputNodes ();
142 
143  void hackTecplotOutput();
144 
145 private:
148  Linear::System & linearSystem_;
150  Topo::Topology & topology_;
151  IO::InitialConditionsManager & initialConditionsManager_;
154 
155  // AC B-vectors
156  Linear::Vector * bVecRealPtr;
157  Linear::Vector * bVecImagPtr;
158 
159  // NOISE B-vectors
160  Linear::Vector * bNoiseVecRealPtr;
161  Linear::Vector * bNoiseVecImagPtr;
162 
166  std::string outputNode1_;
167  std::string outputNode2_;
168  std::string specifiedSource_;
170 
171  std::vector<int> noiseSweepFailures_;
172 
173  bool stepFlag_;
174  std::string type_;
175  double np_;
176  double fStart_;
177  double fStop_;
178 
179  double stepMult_;
180  double fstep_;
183 
184  double delFreq_;
185  double lastFreq_;
186  double currentFreq_;
187  double lnFreq_;
188  double lnLastFreq_;
189  double delLnFreq_;
190 
191  double GainSqInv_;
192  double lnGainInv_;
193 
196 
199 
200  Linear::Matrix * C_;
201  Linear::Matrix * G_;
202  Linear::BlockMatrix * ACMatrix_;
203  Linear::BlockVector * B_;
204  Linear::BlockVector * X_;
205  Linear::BlockVector * saved_AC_X_;
206 
207  Amesos_BaseSolver * blockSolver_;
208  Epetra_LinearProblem * blockProblem_;
209 
210  std::vector<std::string> outputVarNames_;
211  std::vector<int> outputVarGIDs_;
212 
213  std::vector<Xyce::Analysis::NoiseData*> noiseDataVec_;
214 
215  std::vector<double> objectiveVec_;
216  std::vector<double> dOdpVec_;
217  std::vector<double> dOdpAdjVec_;
218  std::vector<double> scaled_dOdpVec_;
219  std::vector<double> scaled_dOdpAdjVec_;
220 };
221 
222 bool registerNOISEFactory(FactoryBlock &factory_block);
223 
224 } // namespace Analysis
225 } // namespace Xyce
226 
227 #endif // Xyce_N_ANP_NOISE_h
const TimeIntg::TIAParams & getTIAParams() const
Definition: N_ANP_NOISE.h:90
std::vector< double > dOdpVec_
Definition: N_ANP_NOISE.h:216
Linear::Matrix * G_
Definition: N_ANP_NOISE.h:201
Nonlinear::Manager & nonlinearManager_
Definition: N_ANP_NOISE.h:149
std::vector< double > scaled_dOdpAdjVec_
Definition: N_ANP_NOISE.h:219
TimeIntg::TIAParams tiaParams_
Definition: N_ANP_NOISE.h:153
Pure virtual class to augment a linear system.
unsigned int stepNumber
Time-integration step number counter.
Linear::Vector * bNoiseVecImagPtr
Definition: N_ANP_NOISE.h:161
Epetra_LinearProblem * blockProblem_
Definition: N_ANP_NOISE.h:208
Linear::BlockVector * saved_AC_X_
Definition: N_ANP_NOISE.h:205
Linear::Matrix * C_
Definition: N_ANP_NOISE.h:200
std::vector< double > objectiveVec_
Definition: N_ANP_NOISE.h:215
std::string specifiedSource_
Definition: N_ANP_NOISE.h:168
std::vector< int > noiseSweepFailures_
Definition: N_ANP_NOISE.h:171
NOISE(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_NOISE.C:176
Linear::Vector * bVecImagPtr
Definition: N_ANP_NOISE.h:157
Linear::BlockMatrix * ACMatrix_
Definition: N_ANP_NOISE.h:202
Linear::BlockVector * B_
Definition: N_ANP_NOISE.h:203
AnalysisManager & analysisManager_
Definition: N_ANP_NOISE.h:146
TimeIntg::TIAParams & getTIAParams()
Definition: N_ANP_NOISE.h:95
IO::InitialConditionsManager & initialConditionsManager_
Definition: N_ANP_NOISE.h:151
The FactoryBlock contains parameters needed by the analysis creation functions.
bool getDCOPFlag() const
Definition: N_ANP_NOISE.C:382
bool updateCurrentFreq_(int stepNumber)
Definition: N_ANP_NOISE.C:1484
Linear::BlockVector * X_
Definition: N_ANP_NOISE.h:204
Linear::Vector * bNoiseVecRealPtr
Definition: N_ANP_NOISE.h:160
std::vector< Xyce::Analysis::NoiseData * > noiseDataVec_
Definition: N_ANP_NOISE.h:213
bool registerNOISEFactory(FactoryBlock &factory_block)
Definition: N_ANP_NOISE.C:1920
Loader::Loader & loader_
Definition: N_ANP_NOISE.h:147
std::vector< double > scaled_dOdpVec_
Definition: N_ANP_NOISE.h:218
void notify(const StepEvent &event)
Definition: N_ANP_NOISE.C:274
bool setTimeIntegratorOptions(const Util::OptionBlock &option_block)
Definition: N_ANP_NOISE.C:134
Amesos_BaseSolver * blockSolver_
Definition: N_ANP_NOISE.h:207
Linear::Vector * bVecRealPtr
Definition: N_ANP_NOISE.h:156
Topo::Topology & topology_
Definition: N_ANP_NOISE.h:150
std::vector< std::string > outputVarNames_
Definition: N_ANP_NOISE.h:210
void printProgress(std::ostream &os)
Definition: N_ANP_NOISE.h:118
std::string outputNode2_
Definition: N_ANP_NOISE.h:167
std::string outputNode1_
Definition: N_ANP_NOISE.h:166
std::vector< int > outputVarGIDs_
Definition: N_ANP_NOISE.h:211
bool setAnalysisParams(const Util::OptionBlock &paramsBlock)
Definition: N_ANP_NOISE.C:298
OutputMgrAdapter & outputManagerAdapter_
Definition: N_ANP_NOISE.h:152
void printStepHeader(std::ostream &os)
Definition: N_ANP_NOISE.h:115
void resetAdjointNOISELinearSystem_()
Definition: N_ANP_NOISE.C:1070
double noiseIntegral(double noizDens, double lnNdens, double lnNlstDens, double delLnFreq, double delFreq, double lnFreq, double lnLastFreq)
Definition: N_ANP_NOISE.C:1342
std::vector< double > dOdpAdjVec_
Definition: N_ANP_NOISE.h:217
Linear::System & linearSystem_
Definition: N_ANP_NOISE.h:148