Xyce  6.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
N_DEV_Capacitor.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_Capacitor.h,v $
27 //
28 // Purpose :
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.123.2.2 $
40 //
41 // Revision Date : $Date: 2014/03/06 21:33:44 $
42 //
43 // Current Owner : $Author: tvrusso $
44 //-----------------------------------------------------------------------------
45 
46 #ifndef Xyce_N_DEV_Capacitor_h
47 #define Xyce_N_DEV_Capacitor_h
48 
49 #include <N_DEV_fwd.h>
50 #include <N_DEV_Configuration.h>
51 #include <N_DEV_DeviceMaster.h>
52 #include <N_DEV_DeviceInstance.h>
53 #include <N_DEV_DeviceModel.h>
54 
55 namespace Xyce {
56 namespace Device {
57 namespace Capacitor {
58 
59 class Model;
60 class Instance;
61 
62 struct Traits : public DeviceTraits<Model, Instance>
63 {
64  static const char *name() {return "Capacitor";}
65  static const char *deviceTypeName() {return "C level 1";}
66 
67  static const int numNodes() {return 2;}
68  static const char *primaryParameter() {return "C";}
69  static const char *instanceDefaultParameter() {return "C";}
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 : Capacitor::Instance
79 // Special Notes : A capacitor will have two circuit nodes.
80 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
81 // Creation Date : 3/16/00
82 //-----------------------------------------------------------------------------
83 /// Capacitor instance
84 ///
85 /// This class refers to a single instance of the capacitor device. It
86 /// contains indicies into the matrix equation. See the comments for the
87 /// Resistor::Instance class for more details.
88 ///
89 class Instance : public DeviceInstance
90 {
91  friend class ParametricData<Instance>;
92  friend class Model;
93  friend class Traits;
94  friend class Master;
95 
96 public:
97  Instance(
98  const Configuration & configuration,
99  const InstanceBlock & instance_block,
100  Model & model,
101  const FactoryBlock & factory_block);
102 
103  ~Instance();
104 
105 private:
106  Instance(const Instance &);
107  Instance &operator=(const Instance &);
108 
109 public:
110  void registerLIDs( const std::vector<int> & intLIDVecRef, const std::vector<int> & extLIDVecRef );
111  void registerStateLIDs( const std::vector<int> & staLIDVecRef );
112  void registerStoreLIDs( const std::vector<int> & stoLIDVecRef );
113 
114  std::map<int,std::string> & getIntNameMap ();
115  std::map<int,std::string> & getStoreNameMap();
116 
117  const std::vector< std::vector<int> > & jacobianStamp() const;
118  void registerJacLIDs( const std::vector< std::vector<int> > & jacLIDVec );
119 
120  bool processParams ();
121  bool updateTemperature(const double & temp_tmp);
122 
123  bool updateIntermediateVars () { return true; };
124  bool updatePrimaryState ();
125 
126  bool setIC ();
127 
128  // load functions, residual:
129  bool loadDAEQVector ();
130  bool loadDAEFVector ();
131 
132  // load functions, Jacobian:
133  bool loadDAEdQdx ();
134  bool loadDAEdFdx ();
135 
136  void setupPointers();
137 
138  void varTypes( std::vector<char> & varTypeVec );
139 
140  // Getters and setters
142  {
143  return model_;
144  }
145 
146 private:
147  Model & model_; //< Owning model
148 
149  // Stuff for handling solution-variable-dependent capacitance
150  Util::Expression * expPtr;
152 
153  std::vector<double> expVarDerivs;
154 
155  // user-specified parameters:
156  double C; // User specified capacitance. (Farads)
157  double IC; // Optional initial value capacitor voltage (V).
158 
159  // These are for the semiconductor capacitor
160  double length; // capacitor length
161  double width; // capacitor width
162  double temp; // temperature of this instance
163 
164  // Genie 121412. temperature dependence parameters
165  // these can override values specified in the model
166  double tempCoeff1; // first order temperature coeff.
167  double tempCoeff2; // second order temperature coeff.
168 
169  // flags used to tell if the user has specified one of these values
170  // on the command line.
173 
174  // These are for the age-aware capacitor
175  double age; ///< age in hours
176  double ageCoef; ///< degradation coeficient.
177  double baseCap; ///< the baseline capacitance before aging
178 
179  bool tempGiven;
180  bool ICGiven;
182 
183  // state variables:
184  double q0; ///< charge in the capacitor
185  // now held in the store vector at li_store_dev_i
186  double vcap; // voltage drop across capacitor
187 
188  //local id's (offsets)
189  int li_Pos;
190  int li_Neg;
191  int li_Bra; ///< for the "voltage source" when IC is specified
192 
194 
195  std::vector<int> li_dQdXState;
196  std::vector<int> li_dCdXState;
199 
201 
202  // Offsets for Jacobian
207 
208  // offsets for when C is solution-variable dependent
209  std::vector<int> APosEquDepVarOffsets;
210  std::vector<int> ANegEquDepVarOffsets;
211 
217 
218 #ifndef Xyce_NONPOINTER_MATRIX_LOAD
219  // Pointers for Jacobian
224 
230 
231  std::vector<double *> qPosEquDepVarsPtrs;
232  std::vector<double *> qNegEquDepVarsPtrs;
233 #endif
234 
235  std::vector< std::vector<int> > jacStamp;
236  std::vector< std::vector<int> > jacStamp_IC;
237 };
238 
239 //-----------------------------------------------------------------------------
240 // Class : Model
241 // Purpose :
242 // Special Notes :
243 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
244 // Creation Date : 3/16/00
245 //-----------------------------------------------------------------------------
246 /// Capacitor Model class
247 ///
248 class Model : public DeviceModel
249 {
250  typedef std::vector<Instance *> InstanceVector;
251 
252  friend class ParametricData<Model>;
253  friend class Instance;
254  friend class Traits;
255  friend class Master;
256 
257 public:
258  Model(
259  const Configuration & configuration,
260  const ModelBlock & model_block,
261  const FactoryBlock & factory_block);
262  ~Model();
263 
264 private:
265  Model();
266  Model(const Model &);
267  Model &operator=(const Model &);
268 
269 public:
270  bool processParams ();
271  bool processInstanceParams ();
272  virtual void forEachInstance(DeviceInstanceOp &op) const /* override */;
273 
274  virtual std::ostream &printOutInstances(std::ostream &os) const;
275 
276 public:
277  void addInstance(Instance *instance)
278  {
279  instanceContainer.push_back(instance);
280  }
281 
283  {
284  return instanceContainer;
285  }
286 
288  {
289  return instanceContainer;
290  }
291 
292 private:
293  std::vector<Instance*> instanceContainer;
294 
295 private:
296 
297  // for the semiconductor capacitor
298  double cj; // junction bottom capacitance
299  double cjsw; // junction sidewall capacitance
300  double defWidth; // default width
301  double narrow; // narrowing due to side etching
302  double tempCoeff1; // first order temperature coeff.
303  double tempCoeff2; // second order temperature coeff.
304  double baseCap;
305  double tnom;
306 
307  bool tnomGiven;
308 };
309 
310 //-----------------------------------------------------------------------------
311 // Class : Master
312 // Purpose :
313 // Special Notes :
314 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
315 // Creation Date : 11/26/08
316 //-----------------------------------------------------------------------------
317 ///
318 /// Capacitor Master class
319 ///
320 /// The "master" class is the one that contains the updateState, loadDAEVectors
321 /// and loadDAEMatrices methods that are actually called when it is time to
322 /// compute and load device contributions.
323 ///
324 /// The default implementations of these methods in the DeviceMaster
325 /// template class simply loops over all instances and calls their
326 /// updatePrimaryState, loadDAEFVector/loadDAEQVector, and
327 /// loadDAEdFdx/loadDAEdQdx methods, respectively.
328 ///
329 /// For efficiency, the Capacitor class reimplements these methods to do the
330 /// work directly, instead of calling instance-level functions.
331 ///
332 class Master : public DeviceMaster<Traits>
333 {
334  friend class Instance;
335  friend class Model;
336 
337 public:
339  const Configuration & configuration,
340  const FactoryBlock & factory_block,
341  const SolverState & ss1,
342  const DeviceOptions & do1)
343  : DeviceMaster<Traits>(configuration, factory_block, ss1, do1)
344  {}
345 
346  virtual bool updateState (double * solVec, double * staVec, double * stoVec);
347 
348  // load functions:
349  virtual bool loadDAEVectors (double * solVec, double * fVec, double * qVec, double * storeLeadF, double * storeLeadQ);
350  virtual bool loadDAEMatrices (N_LAS_Matrix & dFdx, N_LAS_Matrix & dQdx);
351 };
352 
353 void registerDevice();
354 
355 } // namespace Capacitor
356 } // namespace Device
357 } // namespace Xyce
358 
362 
363 #endif // Xyce_N_DEV_Capacitor_h
364