Xyce  6.1
N_ANP_OutputMgrAdapter.C
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_OutputMgrAdapter.C,v $
27 //
28 // Purpose :
29 //
30 // Special Notes :
31 //
32 // Creator : Richard Schiek, SNL, Electrical and Microsystem Modeling
33 //
34 // Creation Date : 01/24/08
35 //
36 // Revision Information:
37 // ---------------------
38 //
39 // Revision Number: $Revision: 1.59 $
40 //
41 // Revision Date : $Date: 2015/11/03 17:27:14 $
42 //
43 // Current Owner : $Author: peshola $
44 //-----------------------------------------------------------------------------
45 #include <Xyce_config.h>
46 
47 #include <N_ANP_OutputMgrAdapter.h>
48 
49 #include <N_ANP_NoiseData.h>
50 
51 #include <N_DEV_DeviceMgr.h>
52 #include <N_IO_FourierMgr.h>
53 #include <N_IO_InitialConditions.h>
54 #include <N_IO_MeasureManager.h>
55 #include <N_IO_Objective.h>
56 #include <N_IO_OutputMgr.h>
57 #include <N_IO_OutputROM.h>
58 #include <N_IO_RestartMgr.h>
59 #include <N_DEV_Op.h>
60 
61 namespace Xyce {
62 namespace Analysis {
63 
64 //-----------------------------------------------------------------------------
65 // Function : OutputMgrAdapter::OutputMgrAdapter( )
66 // Purpose : constructor
67 // Special Notes :
68 // Scope : public
69 // Creator :
70 // Creation Date :
71 //-----------------------------------------------------------------------------
73  Parallel::Machine comm,
74  IO::OutputMgr & output_manager,
75  IO::Measure::Manager & measure_manager,
76  IO::FourierMgr & fourier_manager,
77  IO::ObjectiveManager & objective_manager,
78  Device::DeviceMgr & device_manager)
79  : comm_(comm),
80  outputManager_(output_manager),
81  measureManager_(measure_manager),
82  fourierManager_(fourier_manager),
83  objectiveManager_(objective_manager),
84  deviceManager_(device_manager),
85  tempOp_(new Device::ArtificialParameterOp("TEMP", deviceManager_, *(*deviceManager_.getArtificialParameterMap().find("TEMP")).second, "TEMP")),
86  stepSweepVector_(),
87  dcSweepVector_(),
88  stepAnalysisStepNumber_(0),
89  stepAnalysisMaxSteps_(0),
90  dcAnalysisStepNumber_(0),
91  dcAnalysisMaxSteps_(0)
92 {}
93 
95 {
96  delete tempOp_;
97 }
98 
99 void
101  const StepEvent & event)
102 {
103  if (event.state_ == StepEvent::STEP_STARTED)
104  stepAnalysisStepNumber_ = event.count_;
105  else if (event.state_ == StepEvent::INITIALIZE)
106  stepAnalysisMaxSteps_ = event.count_;
107 }
108 
109 
110 void
112  const Analysis::SweepVector & sweep_vector)
113 {
114  stepSweepVector_ = sweep_vector;
115 }
116 
117 void
119  const Analysis::SweepVector & sweep_vector)
120 {
121  dcSweepVector_ = sweep_vector;
122 }
123 
124 void
126  Parallel::Communicator & parallel_communicator,
127  Topo::Topology & topology,
128  Analysis::AnalysisManager & analysis_manager,
129  const std::string & job_name,
130  bool pack,
131  double current_time) const
132 {
133  IO::dumpRestartData(
134  parallel_communicator,
135  topology,
136  analysis_manager,
138  job_name,
139  pack,
140  current_time);
141 }
142 
143 
144 void
146  double time,
147  Linear::Vector & currSolutionPtr,
148  Linear::Vector & stateVecPtr,
149  Linear::Vector & storeVecPtr,
150  Linear::Vector & lead_current_vector,
151  Linear::Vector & junction_voltage_vector,
152  Linear::Vector & lead_current_dqdt_vector,
153  std::vector<double> & objectiveVec_,
154  std::vector<double> & dOdpVec_,
155  std::vector<double> & dOdpAdjVec_,
156  std::vector<double> & scaled_dOdpVec_,
157  std::vector<double> & scaled_dOdpAdjVec_,
158  bool skipPrintLineOutput)
159 {
160  fourierManager_.updateFourierData(comm_, time, &currSolutionPtr, &stateVecPtr, &storeVecPtr, &lead_current_vector, &junction_voltage_vector, &lead_current_dqdt_vector);
161 
162  measureManager_.updateTranMeasures(comm_, time, &currSolutionPtr, &stateVecPtr, &storeVecPtr, &lead_current_vector, &junction_voltage_vector, &lead_current_dqdt_vector);
163 
164  // Device::ArtificialParameterOp *op = new Device::ArtificialParameterOp("TEMP", deviceManager_, *(*deviceManager_.getArtificialParameterMap().find("TEMP")).second, "TEMP");
165  Util::Op::OpData op_data;
166  double temp = (*tempOp_)(comm_, op_data).real();
167 
168  outputManager_.output(
169  comm_, time, temp, // getParamAndReduce(comm_, deviceManager_, "TEMP"),
172  currSolutionPtr, stateVecPtr, storeVecPtr, lead_current_vector, junction_voltage_vector, lead_current_dqdt_vector, objectiveVec_,
173  dOdpVec_, dOdpAdjVec_, scaled_dOdpVec_, scaled_dOdpAdjVec_,
174  skipPrintLineOutput);
175 
176  // transient values for the objective function call.
177  double arg1 = time;
178  double arg2 = 0.0;
179 
180  objectiveManager_.outputObjective(comm_, outputManager_.getOpBuilderManager(), outputManager_, outputManager_.getCircuitTime(), arg1, arg2, currSolutionPtr, stateVecPtr, storeVecPtr);
181 }
182 
183 void
185  int dcStepNumber,
186  Linear::Vector & currSolutionPtr,
187  Linear::Vector & stateVecPtr,
188  Linear::Vector & storeVecPtr,
189  Linear::Vector & lead_current_vector,
190  Linear::Vector & junction_voltage_vector,
191  Linear::Vector & lead_current_dqdt_vector,
192  std::vector<double> & objectiveVec_,
193  std::vector<double> & dOdpVec_,
194  std::vector<double> & dOdpAdjVec_,
195  std::vector<double> & scaled_dOdpVec_,
196  std::vector<double> & scaled_dOdpAdjVec_)
197 {
198  measureManager_.updateDCMeasures(comm_, dcSweepVector_, &currSolutionPtr, &stateVecPtr, &storeVecPtr, &lead_current_vector, &junction_voltage_vector, &lead_current_dqdt_vector);
199 
200  Util::Op::OpData op_data;
201  double temp = (*tempOp_)(comm_, op_data).real();
202 
203  outputManager_.output(
204  comm_, 0.0, temp, // getParamAndReduce(comm_, deviceManager_, "TEMP"),
206  dcStepNumber, dcAnalysisMaxSteps_, dcSweepVector_,
207  currSolutionPtr, stateVecPtr, storeVecPtr, lead_current_vector, junction_voltage_vector, lead_current_dqdt_vector, objectiveVec_,
208  dOdpVec_, dOdpAdjVec_, scaled_dOdpVec_, scaled_dOdpAdjVec_);
209 
210  // dc values for the objective function call.
211  double arg1 = 0.0;
212  double arg2 = 0.0;
213 
214  if (dcSweepVector_.size() > 0)
215  arg1 = dcSweepVector_[0].currentVal;
216  if (dcSweepVector_.size() > 1)
217  arg2 = dcSweepVector_[1].currentVal;
218 
219  objectiveManager_.outputObjective(comm_, outputManager_.getOpBuilderManager(), outputManager_, outputManager_.getCircuitTime(), arg1, arg2, currSolutionPtr, stateVecPtr, storeVecPtr);
220 }
221 
222 void
224 {
225  outputManager_.finishOutput();
226 }
227 
228 void
230  double time,
231  const std::vector<double> & fast_time_points,
232  const Linear::BlockVector & solution_vector)
233 {
234  outputManager_.outputMPDE(comm_, time, fast_time_points, solution_vector);
235 }
236 
237 void
239  const std::vector<double> & timePoints,
240  const std::vector<double> & freqPoints,
241  const Linear::BlockVector & timeDomainSolutionVec,
242  const Linear::BlockVector & freqDomainSolutionVecReal,
243  const Linear::BlockVector & freqDomainSolutionVecImaginary,
244  const Linear::BlockVector & timeDomainStoreVec,
245  const Linear::BlockVector & freqDomainStoreVecReal,
246  const Linear::BlockVector & freqDomainStoreVecImaginary,
247  const Linear::BlockVector & timeDomainLeadCurrentVec,
248  const Linear::BlockVector & freqDomainLeadCurrentVecReal,
249  const Linear::BlockVector & freqDomainLeadCurrentVecImaginary,
250  const Linear::BlockVector & timeDomainJunctionVoltageVec,
251  const Linear::BlockVector & freqDomainJunctionVoltageVecReal,
252  const Linear::BlockVector & freqDomainJunctionVoltageVecImaginary )
253 
254 {
255  outputManager_.outputHB(
256  comm_,
258  timePoints, freqPoints,
259  timeDomainSolutionVec, freqDomainSolutionVecReal, freqDomainSolutionVecImaginary,
260  timeDomainStoreVec, freqDomainStoreVecReal, freqDomainStoreVecImaginary,
261  timeDomainLeadCurrentVec, freqDomainLeadCurrentVecReal, freqDomainLeadCurrentVecImaginary,
262  timeDomainJunctionVoltageVec, freqDomainJunctionVoltageVecReal, freqDomainJunctionVoltageVecImaginary );
263 }
264 
265 void
267  double frequency,
268  const Linear::Vector & solnVecRealPtr,
269  const Linear::Vector & solnVecImaginaryPtr)
270 {
271  measureManager_.updateACMeasures(comm_, frequency, &solnVecRealPtr, &solnVecImaginaryPtr);
272 
273  outputManager_.outputAC(comm_, frequency, solnVecRealPtr, solnVecImaginaryPtr);
274 
275 }
276 void
278  double frequency,
279  double totalOutputNoiseDens_, double totalInputNoiseDens_,
280  const std::vector<Xyce::Analysis::NoiseData*> & noiseDataVec_)
281 {
282 
283  outputManager_.outputNoise(comm_, frequency,
284  totalOutputNoiseDens_, totalInputNoiseDens_, noiseDataVec_);
285 }
286 
287 // void
288 // OutputMgrAdapter::outputROM(
289 // const Teuchos::SerialDenseMatrix<int, double> & Ghat,
290 // const Teuchos::SerialDenseMatrix<int, double> & Chat,
291 // const Teuchos::SerialDenseMatrix<int, double> & Bhat,
292 // const Teuchos::SerialDenseMatrix<int, double> & Lhat )
293 // {
294 // IO::outputROM(comm_, outputManager_.getNetlistFilename(), Ghat, Chat, Bhat, Lhat );
295 // }
296 
297 // void
298 // OutputMgrAdapter::outputROM(
299 // const Linear::Matrix & Ghat,
300 // const Linear::Matrix & Chat,
301 // const Teuchos::SerialDenseMatrix<int, double> & Bhat,
302 // const Teuchos::SerialDenseMatrix<int, double> & Lhat )
303 // {
304 // IO::outputROM(comm_, outputManager_.getNetlistFilename(), Ghat, Chat, Bhat, Lhat );
305 // }
306 
307 double
309 {
310  return outputManager_.getInitialOutputInterval();
311 }
312 
313 const IO::IntervalVector &
315 {
316  return outputManager_.getOutputIntervals();
317 }
318 
319 void
321  const std::vector<std::string> & paramNames,
322  const std::vector<double> & paramVals,
323  Linear::Vector & solnVecPtr )
324 {
325  outputManager_.outputHomotopy (comm_, paramNames, paramVals, solnVecPtr);
326 }
327 
328 } // namespace Analysis
329 } // namespace Xyce
void outputAC(double freq, const Linear::Vector &solnVecRealPtr, const Linear::Vector &solnVecImaginaryPtr)
Pure virtual class to augment a linear system.
void dumpRestart(Parallel::Communicator &parallel_communicator, Topo::Topology &topology, Analysis::AnalysisManager &analysis_manager, const std::string &job_name, bool pack, double current_time) const
OutputMgrAdapter(Parallel::Machine comm, IO::OutputMgr &output_manager, IO::Measure::Manager &measure_manager, IO::FourierMgr &fourier_manager, IO::ObjectiveManager &objective_manager, Device::DeviceMgr &device_manager)
void outputHomotopy(const std::vector< std::string > &paramNames, const std::vector< double > &paramVals, Linear::Vector &solnVecPtr)
void setStepSweepVector(const Analysis::SweepVector &sweep_vector)
void outputMPDE(double time, const std::vector< double > &fast_time_points, const Linear::BlockVector &solution_vector)
Device::DeviceMgr & deviceManager_
Definition: N_ANP_HB.C:2199
void notify(const StepEvent &event)
void setDCSweepVector(const Analysis::SweepVector &sweep_vector)
void dcOutput(int dcStepNumber, Linear::Vector &currSolutionPtr, Linear::Vector &stateVecPtr, Linear::Vector &storeVecPtr, Linear::Vector &lead_current_vector, Linear::Vector &junction_voltage_vector, Linear::Vector &lead_current_dqdt_vector, std::vector< double > &objectiveVec_, std::vector< double > &dOdpVec_, std::vector< double > &dOdpAdjVec_, std::vector< double > &scaled_dOdpVec_, std::vector< double > &scaled_dOdpAdjVec_)
std::vector< SweepParam > SweepVector
Definition: N_ANP_fwd.h:94
const IO::IntervalVector & getOutputIntervals() const
void outputNoise(double freq, double totalOutputNoiseDens_, double totalInputNoiseDens_, const std::vector< Xyce::Analysis::NoiseData * > &noiseDataVec_)
void outputHB(const std::vector< double > &timePoints, const std::vector< double > &freqPoints, const Linear::BlockVector &timeDomainSolnVec, const Linear::BlockVector &freqDomainSolnVecReal, const Linear::BlockVector &freqDomainSolnVecImaginary, const Linear::BlockVector &timeDomainStoreVec, const Linear::BlockVector &freqDomainStoreVecReal, const Linear::BlockVector &freqDomainStoreVecImaginary, const Linear::BlockVector &timeDomainLeadCurrentVec, const Linear::BlockVector &freqDomainLeadCurrentVecReal, const Linear::BlockVector &freqDomainLeadCurrentVecImaginary, const Linear::BlockVector &timeDomainJunctionVoltageVec, const Linear::BlockVector &freqDomainJunctionVoltageVecReal, const Linear::BlockVector &freqDomainJunctionVoltageVecImaginary)
void tranOutput(double time, Linear::Vector &currSolutionPtr, Linear::Vector &stateVecPtr, Linear::Vector &storeVecPtr, Linear::Vector &lead_current_vector, Linear::Vector &junction_voltage_vector, Linear::Vector &lead_current_dqdt_vector, std::vector< double > &objectiveVec_, std::vector< double > &dOdpVec_, std::vector< double > &dOdpAdjVec_, std::vector< double > &scaled_dOdpVec_, std::vector< double > &scaled_dOdpAdjVec_, bool skipPrintLineOutput=false)