Xyce  6.1
N_LOA_CktLoader.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_LOA_CktLoader.h,v $
27 //
28 // Purpose : This file contains class definitions for the loader
29 // services package.
30 //
31 // Special Notes :
32 //
33 // Creator : Eric R. Keiter, SNL, Parallel Computational Sciences
34 //
35 // Creation Date : 05/26/00
36 //
37 // Revision Information:
38 // ---------------------
39 //
40 // Revision Number: $Revision: 1.127 $
41 //
42 // Revision Date : $Date: 2015/07/11 23:40:29 $
43 //
44 // Current Owner : $Author: erkeite $
45 //-----------------------------------------------------------------------------
46 
47 #ifndef Xyce_LOA_CktLoader_H
48 #define Xyce_LOA_CktLoader_H
49 
50 #include <N_LAS_fwd.h>
51 #include <N_PDS_fwd.h>
52 #include <N_UTL_fwd.h>
53 
54 #include <N_LOA_Loader.h>
55 
56 namespace Xyce {
57 namespace Loader {
58 
59 //-----------------------------------------------------------------------------
60 // Class : CktLoader
61 // Purpose :
62 // Special Notes :
63 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
64 // Creation Date : 5/03/00
65 //-----------------------------------------------------------------------------
66 class CktLoader : public Loader
67 {
68 public:
69  CktLoader(
70  Device::DeviceMgr & device_manager);
71 
72  virtual ~CktLoader();
73 
74  // Method which is called to load the new-DAE contributions to the nonlinear Jacobian matrix.
75  bool loadDAEMatrices(
76  Linear::Vector * tmpSolVectorPtr,
77  Linear::Vector * tmpStaVectorPtr,
78  Linear::Vector * tmpStaDerivVectorPtr,
79  Linear::Vector * tmpStoVectorPtr,
80  Linear::Matrix * tmpdQdxMatrixPtr,
81  Linear::Matrix * tmpdFdxMatrixPtr);
82 
83  // Method which is called to load the new-DAE vectors, which contribute
84  // to the nonlinear residual (RHS) vector.
85  bool loadDAEVectors(
86  Linear::Vector * nextSolVectorPtr,
87  Linear::Vector * currSolVectorPtr,
88  Linear::Vector * lastSolVectorPtr,
89  Linear::Vector * nextStaVectorPtr,
90  Linear::Vector * currStaVectorPtr,
91  Linear::Vector * lastStaVectorPtr,
92  Linear::Vector * StaDerivVectorPtr,
93  Linear::Vector * nextStoVectorPtr,
94  Linear::Vector * currStoVectorPtr,
95  Linear::Vector * lastStoVectorPtr,
96  Linear::Vector * stoLeadCurrQVectorPtr,
97  Linear::Vector * nextLeadFVectorPtr,
98  Linear::Vector * currLeadFVectorPtr,
99  Linear::Vector * lastLeadFVectorPtr,
100  Linear::Vector * nextLeadQVectorPtr,
101  Linear::Vector * nextJunctionVVectorPtr,
102  Linear::Vector * currJunctionVVectorPtr,
103  Linear::Vector * lastJunctionVVectorPtr,
104  Linear::Vector * QVectorPtr,
105  Linear::Vector * FVectorPtr,
106  Linear::Vector * BVectorPtr,
107  Linear::Vector * dFdxdVpVectorPtr,
108  Linear::Vector * dQdxdVpVectorPtr);
109 
110  // Method is called to load the mask to be used in calculating error norms.
111  bool loadDeviceErrorWeightMask(Linear::Vector * deviceMask) const;
112 
113  // Initializes the nonlinear problem.
114  bool initializeProblem(
115  Linear::Vector * nextSolVectorPtr,
116  Linear::Vector * currSolVectorPtr,
117  Linear::Vector * lastSolVectorPtr,
118  Linear::Vector * nextStaVectorPtr,
119  Linear::Vector * currStaVectorPtr,
120  Linear::Vector * lastStaVectorPtr,
121  Linear::Vector * StateDerivVectorPtr,
122  Linear::Vector * nextStoVectorPtr,
123  Linear::Vector * currStoVectorPtr,
124  Linear::Vector * lastStoVectorPtr,
125  Linear::Vector * QVectorPtr,
126  Linear::Vector * FVectorPtr,
127  Linear::Vector * BVectorPtr,
128  Linear::Vector * dFdxdVpVectorPtr,
129  Linear::Vector * dQdxdVpVectorPtr) const;
130 
131  bool updateState(
132  Linear::Vector * nextSolVectorPtr,
133  Linear::Vector * currSolVectorPtr,
134  Linear::Vector * lastSolVectorPtr,
135  Linear::Vector * nextStaVectorPtr,
136  Linear::Vector * currStaVectorPtr,
137  Linear::Vector * lastStaVectorPtr,
138  Linear::Vector * nextStoVectorPtr,
139  Linear::Vector * currStoVectorPtr,
140  Linear::Vector * lastStoVectorPtr);
141 
142  bool loadBVectorsforAC (Linear::Vector * bVecRealPtr,
143  Linear::Vector * bVecImagPtr);
144 
145  int getNumNoiseSources();
146 
147  int getNumNoiseDevices();
148 
149  void setupNoiseSources(std::vector<Xyce::Analysis::NoiseData*> & noiseDataVec);
150 
151  void getNoiseSources(std::vector<Xyce::Analysis::NoiseData*> & noiseDataVec);
152 
153  bool getBMatrixEntriesforMOR(std::vector<int>& bMatEntriesVec, std::vector<int>& bMatPosEntriesVec);
154 
155  // Function for setting the initial guess.
156  bool setInitialGuess(Linear::Vector * solVectorPtr);
157 
158  // Function for setting a single parameter value.
159  bool setParam(std::string & name, double val, bool overrideOriginal=false);
160 
161  // Function for getting a single parameter value.
162  virtual double getParamAndReduce(Parallel::Machine comm, const std::string & name) const;
163 
164  // Method which is called to update the sources.
165  bool updateSources();
166 
167  // Get the voltage limiter flag:
168  bool getLimiterFlag ();
169 
170  // Gets the double DC Operating Point flag - used for PDE devices.
171  bool isPDESystem() const;
172  bool outputPlotFiles() const;
173  bool finishOutput() const;
174 
175  // two-level newton functions:
176  int enablePDEContinuation();
177  bool disablePDEContinuation ();
178 
179  void getNumInterfaceNodes (std::vector<int> & numINodes);
180  bool loadCouplingRHS(int iSubProblem, int iCouple, Linear::Vector * dfdvPtr);
181  bool calcCouplingTerms (int iSubProblem, int iCouple, const Linear::Vector * dxdvPtr);
182  // Gets the time integration required breakpoint times (in a vector).
183  bool getBreakPoints(std::vector< Util::BreakPoint > & breakPointTimes) const;
184 
185  // Accessor which returns the maximum time step size (in seconds).
186  double getMaxTimeStepSize();
187 
188  // Get block size from device options for block gainscale homotopy
189  int getHomotopyBlockSize() const;
190 
191  // Get convergence info from devices
192  bool allDevicesConverged(Parallel::Machine comm);
193 
194  // Get convergence info from inner-solves
195  bool innerDevicesConverged(Parallel::Machine comm);
196 
199 
200  void acceptStep();
201 
202  virtual bool getInitialQnorm (std::vector<TimeIntg::TwoLevelError> & tleVec );
203 
204  virtual bool getInnerLoopErrorSums (std::vector<TimeIntg::TwoLevelError> & tleVec) const;
205 
206  bool updateStateArrays ();
207  bool startTimeStep(
208  bool beginIntegrationFlag,
209  double nextTimeStep,
210  double nextTime,
211  int currentOrder);
212  void setExternalSolverState(bool external_initJctFlag);
213 
214  // Function for determining if an analytic sensitivity (df/dp or dqdp) is available.
215  virtual bool analyticSensitivitiesAvailable(std::string & name);
216 
217  virtual void getAnalyticSensitivities(
218  std::string & name,
219  std::vector<double> & dfdpVec,
220  std::vector<double> & dqdpVec,
221  std::vector<double> & dbdpVec,
222  std::vector<int> & FindicesVec,
223  std::vector<int> & QindicesVec,
224  std::vector<int> & BindicesVec) const;
225 
226  // voltage limiter toggle functions
227  virtual bool getVoltageLimiterStatus();
228  virtual void setVoltageLimiterStatus(bool voltageLimterStatus);
229 
230 public:
231  Device::DeviceMgr & deviceManager_; ///< Device manager
232 };
233 
234 } // namespace Loader
235 } // namespace Xyce
236 
237 #endif
bool setParam(std::string &name, double val, bool overrideOriginal=false)
Device::DeviceMgr & deviceManager_
Device manager.
void setupNoiseSources(std::vector< Xyce::Analysis::NoiseData * > &noiseDataVec)
virtual bool getInitialQnorm(std::vector< TimeIntg::TwoLevelError > &tleVec)
bool updateState(Linear::Vector *nextSolVectorPtr, Linear::Vector *currSolVectorPtr, Linear::Vector *lastSolVectorPtr, Linear::Vector *nextStaVectorPtr, Linear::Vector *currStaVectorPtr, Linear::Vector *lastStaVectorPtr, Linear::Vector *nextStoVectorPtr, Linear::Vector *currStoVectorPtr, Linear::Vector *lastStoVectorPtr)
virtual bool analyticSensitivitiesAvailable(std::string &name)
bool initializeProblem(Linear::Vector *nextSolVectorPtr, Linear::Vector *currSolVectorPtr, Linear::Vector *lastSolVectorPtr, Linear::Vector *nextStaVectorPtr, Linear::Vector *currStaVectorPtr, Linear::Vector *lastStaVectorPtr, Linear::Vector *StateDerivVectorPtr, Linear::Vector *nextStoVectorPtr, Linear::Vector *currStoVectorPtr, Linear::Vector *lastStoVectorPtr, Linear::Vector *QVectorPtr, Linear::Vector *FVectorPtr, Linear::Vector *BVectorPtr, Linear::Vector *dFdxdVpVectorPtr, Linear::Vector *dQdxdVpVectorPtr) const
bool getBMatrixEntriesforMOR(std::vector< int > &bMatEntriesVec, std::vector< int > &bMatPosEntriesVec)
Pure virtual class to augment a linear system.
bool calcCouplingTerms(int iSubProblem, int iCouple, const Linear::Vector *dxdvPtr)
bool loadCouplingRHS(int iSubProblem, int iCouple, Linear::Vector *dfdvPtr)
virtual void setVoltageLimiterStatus(bool voltageLimterStatus)
CktLoader(Device::DeviceMgr &device_manager)
void getNoiseSources(std::vector< Xyce::Analysis::NoiseData * > &noiseDataVec)
virtual void getAnalyticSensitivities(std::string &name, std::vector< double > &dfdpVec, std::vector< double > &dqdpVec, std::vector< double > &dbdpVec, std::vector< int > &FindicesVec, std::vector< int > &QindicesVec, std::vector< int > &BindicesVec) const
virtual bool getInnerLoopErrorSums(std::vector< TimeIntg::TwoLevelError > &tleVec) const
virtual double getParamAndReduce(Parallel::Machine comm, const std::string &name) const
bool allDevicesConverged(Parallel::Machine comm)
bool loadBVectorsforAC(Linear::Vector *bVecRealPtr, Linear::Vector *bVecImagPtr)
bool setInitialGuess(Linear::Vector *solVectorPtr)
void getNumInterfaceNodes(std::vector< int > &numINodes)
bool loadDAEMatrices(Linear::Vector *tmpSolVectorPtr, Linear::Vector *tmpStaVectorPtr, Linear::Vector *tmpStaDerivVectorPtr, Linear::Vector *tmpStoVectorPtr, Linear::Matrix *tmpdQdxMatrixPtr, Linear::Matrix *tmpdFdxMatrixPtr)
bool loadDAEVectors(Linear::Vector *nextSolVectorPtr, Linear::Vector *currSolVectorPtr, Linear::Vector *lastSolVectorPtr, Linear::Vector *nextStaVectorPtr, Linear::Vector *currStaVectorPtr, Linear::Vector *lastStaVectorPtr, Linear::Vector *StaDerivVectorPtr, Linear::Vector *nextStoVectorPtr, Linear::Vector *currStoVectorPtr, Linear::Vector *lastStoVectorPtr, Linear::Vector *stoLeadCurrQVectorPtr, Linear::Vector *nextLeadFVectorPtr, Linear::Vector *currLeadFVectorPtr, Linear::Vector *lastLeadFVectorPtr, Linear::Vector *nextLeadQVectorPtr, Linear::Vector *nextJunctionVVectorPtr, Linear::Vector *currJunctionVVectorPtr, Linear::Vector *lastJunctionVVectorPtr, Linear::Vector *QVectorPtr, Linear::Vector *FVectorPtr, Linear::Vector *BVectorPtr, Linear::Vector *dFdxdVpVectorPtr, Linear::Vector *dQdxdVpVectorPtr)
void stepSuccess(Xyce::Analysis::TwoLevelMode analysis)
bool loadDeviceErrorWeightMask(Linear::Vector *deviceMask) const
void setExternalSolverState(bool external_initJctFlag)
bool startTimeStep(bool beginIntegrationFlag, double nextTimeStep, double nextTime, int currentOrder)
virtual bool getVoltageLimiterStatus()
bool innerDevicesConverged(Parallel::Machine comm)
bool outputPlotFiles() const
void stepFailure(Xyce::Analysis::TwoLevelMode analysis)
int getHomotopyBlockSize() const
bool getBreakPoints(std::vector< Util::BreakPoint > &breakPointTimes) const