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