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.142 $
40 //
41 // Revision Date : $Date: 2015/04/08 19:18:24 $
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  bool isLinearDevice() const { return true; };
133 
134  void registerLIDs( const std::vector<int> & intLIDVecRef,
135  const std::vector<int> & extLIDVecRef );
136  void registerStateLIDs( const std::vector<int> & staLIDVecRef );
137 
138  void registerBranchDataLIDs(const std::vector<int> & branchLIDVecRef);
139  void loadNodeSymbols(Util::SymbolTable &symbol_table) const; // override
140 
141  const std::vector< std::vector<int> > & jacobianStamp() const;
142  void registerJacLIDs( const std::vector< std::vector<int> > & jacLIDVec );
143 
144  bool processParams ();
145  bool updateTemperature(const double & temp_tmp);
146 
147  bool updateIntermediateVars () { return true; };
148  bool updatePrimaryState ();
149  bool updateSecondaryState ();
150 
151  bool setIC ();
152 
153  void varTypes( std::vector<char> & varTypeVec );
154 
155  // load functions, residual:
156  bool loadDAEQVector ();
157  bool loadDAEFVector ();
158 
159  void auxDAECalculations ();
160 
161  // load functions, Jacobian:
162  bool loadDAEdQdx ();
163  bool loadDAEdFdx ();
164 
165  void setupPointers();
166 
167 public:
168  // iterator reference to the inductor model which owns this instance.
169  // Getters and setters
171  {
172  return model_;
173  }
174 
175 private:
176  static std::vector< std::vector<int> > jacStamp_BASE;
177 
178 
179  Model & model_; //< Owning model
180 
181  // parameter variables
182  double L; // User specified inductance.
183  double IC; // Initial condition: initial, time-zero inductor current(A)
184  bool ICGiven;
185  double baseL; // the baseline inductance before temperature effects
186  double temp; // temperature of this instance
187  bool tempGiven;
188 
189  // Genie 121412. temperature dependence parameters
190  // these can override values specified in the model
191  double tempCoeff1; // first order temperature coeff.
192  double tempCoeff2; // second order temperature coeff.
193 
194  // flags used to tell if the user has specified one of these values
195  // on the command line.
198 
199  // state variables
200  double f0; // most recent value for the flux through the inductor.
201 
202  // local state indices (offsets)
204 
205  // local solution indices (offsets)
206  int li_Pos;
207  int li_Neg;
208  int li_Bra;
209 
210  int li_branch_data; ///< Index for lead current and junction voltage (for power calculations)
211 
212  // Matrix equation index variables:
213  std::vector<int> xLBraVar_J;
214  std::vector<int> li_LBra;
215 
216  int ABraEquLBraVar_I; // Row index for the branch current
217  // contribution of inductors this instance
218  // is coupled to.
219 
220  // Offset variables for all of the above index variables.
221  int ABraEquPosNodeOffset; // Offset, pos. node voltage contribution,
222  // branch current equ.
223 
224  int ABraEquNegNodeOffset; // Offset, neg. node voltage contribution,
225  // branch current equ.
226 
227  int ABraEquBraVarOffset; // Offset, branch current variable
228  // contribution, branch current equation.
229 
230  int APosEquBraVarOffset; // Offset, branch current variable
231  // contribution, KCL equation of the pos node
232 
233  int ANegEquBraVarOffset; // Offset, branch current variable
234  // contribution, KCL equation of the neg node
235 
237 
239 
241 
243 
245 
246 #ifndef Xyce_NONPOINTER_MATRIX_LOAD
247  // Pointer variables for the Jacobian matrices
254 #endif
255 
256 };
257 
258 //-----------------------------------------------------------------------------
259 // Class : Model
260 // Purpose :
261 // Special Notes :
262 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
263 // Creation Date : 3/16/00
264 //-----------------------------------------------------------------------------
265 class Model : public DeviceModel
266 {
267  typedef std::vector<Instance *> InstanceVector;
268 
269  friend class ParametricData<Model>;
270  friend class Instance;
271  friend class Traits;friend class Master;
272  friend class indSensitivity;
273 
274 public:
275  Model(
276  const Configuration & configuration,
277  const ModelBlock & MB,
278  const FactoryBlock & factory_block);
279  ~Model();
280 
281 private:
282  Model();
283  Model(const Model &);
284  Model &operator=(const Model &);
285 
286 public:
287  virtual void forEachInstance(DeviceInstanceOp &op) const /* override */;
288 
289  virtual std::ostream &printOutInstances(std::ostream &os) const;
290  virtual bool processParams ();
291  virtual bool processInstanceParams ();
292 
293 
294 public:
295  void addInstance(Instance *instance)
296  {
297  instanceContainer.push_back(instance);
298  }
299 
300 private:
301  std::vector<Instance*> instanceContainer;
302 
303 private:
304 
305  double inductanceMultiplier; // User specified inductance multiplier.
306  double IC; // Initial condition: initial, time-zero inductor current(A)
307  double tempCoeff1; // first order temperature coeff.
308  double tempCoeff2; // second order temperature coeff.
309  double baseL;
310  double tnom;
311  bool tc1Given;
312  bool tc2Given;
313  bool tnomGiven;
314 };
315 
316 //-----------------------------------------------------------------------------
317 // Class : Master
318 // Purpose :
319 // Special Notes :
320 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
321 // Creation Date : 11/26/08
322 //-----------------------------------------------------------------------------
323 class Master : public DeviceMaster<Traits>
324 {
325 public:
327  const Configuration & configuration,
328  const FactoryBlock & factory_block,
329  const SolverState & ss1,
330  const DeviceOptions & do1)
331  : DeviceMaster<Traits>(configuration, factory_block, ss1, do1)
332  {}
333 
334  virtual bool updateState (double * solVec, double * staVec, double * stoVec);
335  virtual bool updateSecondaryState (double * staDeriv, double * stoVec);
336 
337  virtual bool loadDAEVectors (double * solVec, double * fVec, double * qVec, double * bVec, double * storeLeadF, double * storeLeadQ, double * leadF, double * leadQ, double * junctionV);
338  virtual bool loadDAEMatrices (Linear::Matrix & dFdx, Linear::Matrix & dQdx);
339 };
340 
341 void registerDevice();
342 
343 } // namespace Inductor
344 } // namespace Device
345 } // namespace Xyce
346 
347 #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 &)