Xyce  6.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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-2014 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.129.2.1 $
40 //
41 // Revision Date : $Date: 2014/02/26 20:16:30 $
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 struct Traits : public DeviceTraits<Model, Instance>
64 {
65  static const char *name() {return "Inductor";}
66  static const char *deviceTypeName() {return "L level 1";}
67  static const int numNodes() {return 2;}
68  static const char *primaryParameter() {return "L";}
69  static const char *instanceDefaultParameter() {return "L";}
70  static const bool isLinearDevice() {return true;}
71 
72  static Device *factory(const Configuration &configuration, const FactoryBlock &factory_block);
73  static void loadModelParameters(ParametricData<Model> &model_parameters);
74  static void loadInstanceParameters(ParametricData<Instance> &instance_parameters);
75 };
76 
77 //-----------------------------------------------------------------------------
78 // Class : Instance
79 // Purpose : This is class refers to a single instance of the
80 // inductor device. It has two nodes associated with it, a
81 // positive and a negative node. See the InductorInstance
82 // class for a more detailed explanation.
83 // Special Notes :
84 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
85 // Creation Date : 3/16/00
86 //-----------------------------------------------------------------------------
87 
88 class Instance : public DeviceInstance
89 {
90  friend class ParametricData<Instance>;
91  friend class Model;
92  friend class Traits;friend class Master;
93 
94 public:
95  Instance(
96  const Configuration & configuration,
97  const InstanceBlock & instance_block,
98  Model & model,
99  const FactoryBlock & factory_block);
100 
101  ~Instance();
102 
103 private:
104  Instance(const Instance &);
105  Instance &operator=(const Instance &);
106 
107 public:
108  void registerLIDs( const std::vector<int> & intLIDVecRef,
109  const std::vector<int> & extLIDVecRef );
110  void registerStateLIDs( const std::vector<int> & staLIDVecRef );
111 
112  std::map<int,std::string> & getIntNameMap ();
113 
114  const std::vector< std::vector<int> > & jacobianStamp() const;
115  void registerJacLIDs( const std::vector< std::vector<int> > & jacLIDVec );
116 
117  bool processParams ();
118  bool updateTemperature(const double & temp_tmp);
119 
120  bool updateIntermediateVars () { return true; };
121  bool updatePrimaryState ();
122  bool updateSecondaryState ();
123 
124  bool setIC ();
125 
126  void varTypes( std::vector<char> & varTypeVec );
127 
128  // load functions, residual:
129  bool loadDAEQVector ();
130  bool loadDAEFVector ();
131 
132  void auxDAECalculations ();
133 
134  // load functions, Jacobian:
135  bool loadDAEdQdx ();
136  bool loadDAEdFdx ();
137 
138  void setupPointers();
139 
140 public:
141  // iterator reference to the inductor model which owns this instance.
142  // Getters and setters
144  {
145  return model_;
146  }
147 
148 private:
149  static std::vector< std::vector<int> > jacStamp_BASE;
150 
151 
152  Model & model_; //< Owning model
153 
154  // parameter variables
155  double L; // User specified inductance.
156  double IC; // Initial condition: initial, time-zero inductor current(A)
157  bool ICGiven;
158  double baseL; // the baseline inductance before temperature effects
159  double temp; // temperature of this instance
160  bool tempGiven;
161 
162  // Genie 121412. temperature dependence parameters
163  // these can override values specified in the model
164  double tempCoeff1; // first order temperature coeff.
165  double tempCoeff2; // second order temperature coeff.
166 
167  // flags used to tell if the user has specified one of these values
168  // on the command line.
171 
172  // state variables
173  double f0; // most recent value for the flux through the inductor.
174 
175  // local state indices (offsets)
177 
178  // local solution indices (offsets)
179  int li_Pos;
180  int li_Neg;
181  int li_Bra;
182 
183  // Matrix equation index variables:
184  std::vector<int> xLBraVar_J;
185  std::vector<int> li_LBra;
186 
187  int ABraEquLBraVar_I; // Row index for the branch current
188  // contribution of inductors this instance
189  // is coupled to.
190 
191  // Offset variables for all of the above index variables.
192  int ABraEquPosNodeOffset; // Offset, pos. node voltage contribution,
193  // branch current equ.
194 
195  int ABraEquNegNodeOffset; // Offset, neg. node voltage contribution,
196  // branch current equ.
197 
198  int ABraEquBraVarOffset; // Offset, branch current variable
199  // contribution, branch current equation.
200 
201  int APosEquBraVarOffset; // Offset, branch current variable
202  // contribution, KCL equation of the pos node
203 
204  int ANegEquBraVarOffset; // Offset, branch current variable
205  // contribution, KCL equation of the neg node
206 
208 
210 
212 
214 
216 
217 #ifndef Xyce_NONPOINTER_MATRIX_LOAD
218  // Pointer variables for the Jacobian matrices
225 #endif
226 
227 };
228 
229 //-----------------------------------------------------------------------------
230 // Class : Model
231 // Purpose :
232 // Special Notes :
233 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
234 // Creation Date : 3/16/00
235 //-----------------------------------------------------------------------------
236 class Model : public DeviceModel
237 {
238  typedef std::vector<Instance *> InstanceVector;
239 
240  friend class ParametricData<Model>;
241  friend class Instance;
242  friend class Traits;friend class Master;
243 
244 public:
245  Model(
246  const Configuration & configuration,
247  const ModelBlock & MB,
248  const FactoryBlock & factory_block);
249  ~Model();
250 
251 private:
252  Model();
253  Model(const Model &);
254  Model &operator=(const Model &);
255 
256 public:
257  virtual void forEachInstance(DeviceInstanceOp &op) const /* override */;
258 
259  virtual std::ostream &printOutInstances(std::ostream &os) const;
260  virtual bool processParams ();
261  virtual bool processInstanceParams ();
262 
263 
264 public:
265  void addInstance(Instance *instance)
266  {
267  instanceContainer.push_back(instance);
268  }
269 
271  {
272  return instanceContainer;
273  }
274 
276  {
277  return instanceContainer;
278  }
279 
280 private:
281  std::vector<Instance*> instanceContainer;
282 
283 private:
284 
285  double L; // User specified inductance.
286  double IC; // Initial condition: initial, time-zero inductor current(A)
287  double tempCoeff1; // first order temperature coeff.
288  double tempCoeff2; // second order temperature coeff.
289  double baseL;
290  double tnom;
291  bool tc1Given;
292  bool tc2Given;
293  bool tnomGiven;
294 };
295 
296 //-----------------------------------------------------------------------------
297 // Class : Master
298 // Purpose :
299 // Special Notes :
300 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
301 // Creation Date : 11/26/08
302 //-----------------------------------------------------------------------------
303 class Master : public DeviceMaster<Traits>
304 {
305 public:
307  const Configuration & configuration,
308  const FactoryBlock & factory_block,
309  const SolverState & ss1,
310  const DeviceOptions & do1)
311  : DeviceMaster<Traits>(configuration, factory_block, ss1, do1)
312  {}
313 
314  virtual bool updateState (double * solVec, double * staVec, double * stoVec);
315  virtual bool updateSecondaryState (double * staDeriv, double * stoVec);
316 
317  virtual bool loadDAEVectors (double * solVec, double * fVec, double * qVec, double * storeLeadF, double * storeLeadQ);
318  virtual bool loadDAEMatrices (N_LAS_Matrix & dFdx, N_LAS_Matrix & dQdx);
319 };
320 
321 void registerDevice();
322 
323 } // namespace Inductor
324 } // namespace Device
325 } // namespace Xyce
326 
330 
331 #endif