Xyce  6.1
N_DEV_Inductor.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_DEV_Inductor.h,v $
27 //
28 // Purpose : Inductor classes.
29 //
30 // Special Notes :
31 //
32 // Creator : Eric R. Keiter, SNL, Parallel Computational Sciences
33 //
34 // Creation Date : 02/28/00
35 //
36 // Revision Information:
37 // ---------------------
38 //
39 // Revision Number: $Revision: 1.140.2.1 $
40 //
41 // Revision Date : $Date: 2015/04/02 18:20:10 $
42 //
43 // Current Owner : $Author: tvrusso $
44 //-----------------------------------------------------------------------------
45 
46 #ifndef Xyce_N_DEV_Inductor_h
47 #define Xyce_N_DEV_Inductor_h
48 
49 // ---------- Xyce Includes ----------
50 #include <N_DEV_Configuration.h>
51 #include <N_DEV_DeviceMaster.h>
52 #include <N_DEV_DeviceBlock.h>
53 #include <N_DEV_DeviceInstance.h>
54 #include <N_DEV_DeviceModel.h>
55 
56 namespace Xyce {
57 namespace Device {
58 namespace Inductor {
59 
60 class Model;
61 class Instance;
62 
63 /// sensitivity functor
65 {
66  public:
68  baseSensitivity() {};
69 
70  virtual ~indSensitivity() {};
71 
72  virtual void operator()(
73  const ParameterBase &entity,
74  const std::string &name,
75  std::vector<double> & dfdp,
76  std::vector<double> & dqdp,
77  std::vector<double> & dbdp,
78  std::vector<int> & Findices,
79  std::vector<int> & Qindices,
80  std::vector<int> & Bindices
81  ) const ;
82 };
83 
85 
86 struct Traits : public DeviceTraits<Model, Instance>
87 {
88  static const char *name() {return "Inductor";}
89  static const char *deviceTypeName() {return "L level 1";}
90  static int numNodes() {return 2;}
91  static const char *primaryParameter() {return "L";}
92  static const char *instanceDefaultParameter() {return "L";}
93  static bool isLinearDevice() {return true;}
94 
95  static Device *factory(const Configuration &configuration, const FactoryBlock &factory_block);
96  static void loadModelParameters(ParametricData<Model> &model_parameters);
97  static void loadInstanceParameters(ParametricData<Instance> &instance_parameters);
98 };
99 
100 //-----------------------------------------------------------------------------
101 // Class : Instance
102 // Purpose : This is class refers to a single instance of the
103 // inductor device. It has two nodes associated with it, a
104 // positive and a negative node. See the InductorInstance
105 // class for a more detailed explanation.
106 // Special Notes :
107 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
108 // Creation Date : 3/16/00
109 //-----------------------------------------------------------------------------
110 
111 class Instance : public DeviceInstance
112 {
113  friend class ParametricData<Instance>;
114  friend class Model;
115  friend class Traits;friend class Master;
116  friend class indSensitivity;
117 
118 public:
119  Instance(
120  const Configuration & configuration,
121  const InstanceBlock & instance_block,
122  Model & model,
123  const FactoryBlock & factory_block);
124 
125  ~Instance();
126 
127 private:
128  Instance(const Instance &);
129  Instance &operator=(const Instance &);
130 
131 public:
132  void registerLIDs( const std::vector<int> & intLIDVecRef,
133  const std::vector<int> & extLIDVecRef );
134  void registerStateLIDs( const std::vector<int> & staLIDVecRef );
135 
136  void registerBranchDataLIDs(const std::vector<int> & branchLIDVecRef);
137  void loadNodeSymbols(Util::SymbolTable &symbol_table) const; // override
138 
139  const std::vector< std::vector<int> > & jacobianStamp() const;
140  void registerJacLIDs( const std::vector< std::vector<int> > & jacLIDVec );
141 
142  bool processParams ();
143  bool updateTemperature(const double & temp_tmp);
144 
145  bool updateIntermediateVars () { return true; };
146  bool updatePrimaryState ();
147  bool updateSecondaryState ();
148 
149  bool setIC ();
150 
151  void varTypes( std::vector<char> & varTypeVec );
152 
153  // load functions, residual:
154  bool loadDAEQVector ();
155  bool loadDAEFVector ();
156 
157  void auxDAECalculations ();
158 
159  // load functions, Jacobian:
160  bool loadDAEdQdx ();
161  bool loadDAEdFdx ();
162 
163  void setupPointers();
164 
165 public:
166  // iterator reference to the inductor model which owns this instance.
167  // Getters and setters
169  {
170  return model_;
171  }
172 
173 private:
174  static std::vector< std::vector<int> > jacStamp_BASE;
175 
176 
177  Model & model_; //< Owning model
178 
179  // parameter variables
180  double L; // User specified inductance.
181  double IC; // Initial condition: initial, time-zero inductor current(A)
182  bool ICGiven;
183  double baseL; // the baseline inductance before temperature effects
184  double temp; // temperature of this instance
185  bool tempGiven;
186 
187  // Genie 121412. temperature dependence parameters
188  // these can override values specified in the model
189  double tempCoeff1; // first order temperature coeff.
190  double tempCoeff2; // second order temperature coeff.
191 
192  // flags used to tell if the user has specified one of these values
193  // on the command line.
196 
197  // state variables
198  double f0; // most recent value for the flux through the inductor.
199 
200  // local state indices (offsets)
202 
203  // local solution indices (offsets)
204  int li_Pos;
205  int li_Neg;
206  int li_Bra;
207 
208  int li_branch_data; ///< Index for lead current and junction voltage (for power calculations)
209 
210  // Matrix equation index variables:
211  std::vector<int> xLBraVar_J;
212  std::vector<int> li_LBra;
213 
214  int ABraEquLBraVar_I; // Row index for the branch current
215  // contribution of inductors this instance
216  // is coupled to.
217 
218  // Offset variables for all of the above index variables.
219  int ABraEquPosNodeOffset; // Offset, pos. node voltage contribution,
220  // branch current equ.
221 
222  int ABraEquNegNodeOffset; // Offset, neg. node voltage contribution,
223  // branch current equ.
224 
225  int ABraEquBraVarOffset; // Offset, branch current variable
226  // contribution, branch current equation.
227 
228  int APosEquBraVarOffset; // Offset, branch current variable
229  // contribution, KCL equation of the pos node
230 
231  int ANegEquBraVarOffset; // Offset, branch current variable
232  // contribution, KCL equation of the neg node
233 
235 
237 
239 
241 
243 
244 #ifndef Xyce_NONPOINTER_MATRIX_LOAD
245  // Pointer variables for the Jacobian matrices
252 #endif
253 
254 };
255 
256 //-----------------------------------------------------------------------------
257 // Class : Model
258 // Purpose :
259 // Special Notes :
260 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
261 // Creation Date : 3/16/00
262 //-----------------------------------------------------------------------------
263 class Model : public DeviceModel
264 {
265  typedef std::vector<Instance *> InstanceVector;
266 
267  friend class ParametricData<Model>;
268  friend class Instance;
269  friend class Traits;friend class Master;
270  friend class indSensitivity;
271 
272 public:
273  Model(
274  const Configuration & configuration,
275  const ModelBlock & MB,
276  const FactoryBlock & factory_block);
277  ~Model();
278 
279 private:
280  Model();
281  Model(const Model &);
282  Model &operator=(const Model &);
283 
284 public:
285  virtual void forEachInstance(DeviceInstanceOp &op) const /* override */;
286 
287  virtual std::ostream &printOutInstances(std::ostream &os) const;
288  virtual bool processParams ();
289  virtual bool processInstanceParams ();
290 
291 
292 public:
293  void addInstance(Instance *instance)
294  {
295  instanceContainer.push_back(instance);
296  }
297 
298 private:
299  std::vector<Instance*> instanceContainer;
300 
301 private:
302 
303  double inductanceMultiplier; // User specified inductance multiplier.
304  double IC; // Initial condition: initial, time-zero inductor current(A)
305  double tempCoeff1; // first order temperature coeff.
306  double tempCoeff2; // second order temperature coeff.
307  double baseL;
308  double tnom;
309  bool tc1Given;
310  bool tc2Given;
311  bool tnomGiven;
312 };
313 
314 //-----------------------------------------------------------------------------
315 // Class : Master
316 // Purpose :
317 // Special Notes :
318 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
319 // Creation Date : 11/26/08
320 //-----------------------------------------------------------------------------
321 class Master : public DeviceMaster<Traits>
322 {
323 public:
325  const Configuration & configuration,
326  const FactoryBlock & factory_block,
327  const SolverState & ss1,
328  const DeviceOptions & do1)
329  : DeviceMaster<Traits>(configuration, factory_block, ss1, do1)
330  {}
331 
332  virtual bool updateState (double * solVec, double * staVec, double * stoVec);
333  virtual bool updateSecondaryState (double * staDeriv, double * stoVec);
334 
335  virtual bool loadDAEVectors (double * solVec, double * fVec, double * qVec, double * bVec, double * storeLeadF, double * storeLeadQ, double * leadF, double * leadQ, double * junctionV);
336  virtual bool loadDAEMatrices (Linear::Matrix & dFdx, Linear::Matrix & dQdx);
337 };
338 
339 void registerDevice();
340 
341 } // namespace Inductor
342 } // namespace Device
343 } // namespace Xyce
344 
345 #endif
int li_branch_data
Index for lead current and junction voltage (for power calculations)
std::vector< Instance * > InstanceVector
void registerBranchDataLIDs(const std::vector< int > &branchLIDVecRef)
Register the local store IDs.
static void loadInstanceParameters(ParametricData< Instance > &instance_parameters)
Pure virtual class to augment a linear system.
Base class for all parameters.
Definition: N_DEV_Pars.h:169
virtual void forEachInstance(DeviceInstanceOp &op) const
Apply a device instance "op" to all instances associated with this model.
const std::vector< std::vector< int > > & jacobianStamp() const
static std::vector< std::vector< int > > jacStamp_BASE
virtual bool loadDAEVectors(double *solVec, double *fVec, double *qVec, double *bVec, double *storeLeadF, double *storeLeadQ, double *leadF, double *leadQ, double *junctionV)
Populates the device's ExternData object with these pointers.
void registerJacLIDs(const std::vector< std::vector< int > > &jacLIDVec)
void varTypes(std::vector< char > &varTypeVec)
DeviceMaster instantiates a device as described by the device traits T.
void registerLIDs(const std::vector< int > &intLIDVecRef, const std::vector< int > &extLIDVecRef)
The FactoryBlock contains parameters needed by the device, instance and model creation functions...
virtual bool processParams()
processParams
void loadNodeSymbols(Util::SymbolTable &symbol_table) const
Populates and returns the store name map.
Instance(const Configuration &configuration, const InstanceBlock &instance_block, Model &model, const FactoryBlock &factory_block)
virtual bool loadDAEMatrices(Linear::Matrix &dFdx, Linear::Matrix &dQdx)
Populates the device's Jacobian object with these pointers.
virtual std::ostream & printOutInstances(std::ostream &os) const
Master(const Configuration &configuration, const FactoryBlock &factory_block, const SolverState &ss1, const DeviceOptions &do1)
static const char * primaryParameter()
The Device class is an interface for device implementations.
Definition: N_DEV_Device.h:101
void registerStateLIDs(const std::vector< int > &staLIDVecRef)
bool updateTemperature(const double &temp_tmp)
static indSensitivity indSens
Class Configuration contains device configuration data.
static void loadModelParameters(ParametricData< Model > &model_parameters)
void addInstance(Instance *instance)
static const char * deviceTypeName()
Model & operator=(const Model &)
static const char * name()
static const char * instanceDefaultParameter()
Base sensitivity functor.
Definition: N_DEV_Pars.h:148
static Device * factory(const Configuration &configuration, const FactoryBlock &factory_block)
ModelBlock represents a .MODEL line from the netlist.
The DeviceTraits template describes the configuration of a device.
Manages parameter binding for class C.
Definition: N_DEV_Pars.h:214
virtual bool updateSecondaryState(double *staDeriv, double *stoVec)
Updates the devices secondary state information.
InstanceBlock represent a device instance line from the netlist.
virtual bool updateState(double *solVec, double *staVec, double *stoVec)
Updates the devices state information.
virtual void operator()(const ParameterBase &entity, const std::string &name, std::vector< double > &dfdp, std::vector< double > &dqdp, std::vector< double > &dbdp, std::vector< int > &Findices, std::vector< int > &Qindices, std::vector< int > &Bindices) const
std::vector< Instance * > instanceContainer
virtual bool processInstanceParams()
processInstanceParams
Instance & operator=(const Instance &)