Xyce  6.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
N_DEV_Diode.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_Diode.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.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_Diode_h
47 #define Xyce_N_DEV_Diode_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 #include <N_DEV_Param.h>
57 
58 namespace Xyce {
59 namespace Device {
60 namespace Diode {
61 
62 class Model;
63 class Instance;
64 
65 struct Traits : public DeviceTraits<Model, Instance>
66 {
67  static const char *name() {return "Diode";}
68  static const char *deviceTypeName() {return "D level 1,2";}
69  static const int numNodes() {return 2;}
70  static const bool modelRequired() {return true;}
71  static const bool isLinearDevice() {return false;}
72 
73  static Device *factory(const Configuration &configuration, const FactoryBlock &factory_block);
74  static void loadModelParameters(ParametricData<Model> &model_parameters);
75  static void loadInstanceParameters(ParametricData<Instance> &instance_parameters);
76 };
77 
78 //-----------------------------------------------------------------------------
79 // Class : Instance
80 //
81 // Purpose : This class represents a single instance of the diode
82 // device. It mainly contains indices and pointers into
83 // the matrix equation (see the resistor instance class for
84 // more details).
85 //
86 // The diode will have 1 internal node, in addition to the
87 // nodes which are connected to it. This is so that it
88 // can be placed in series with a resistor that represents
89 // the resistance of intrinsic Si.
90 //
91 // Special Notes :
92 // Creator : Eric Keiter, Parallel Computational Sciences
93 // Creation Date : 02/28/00
94 //-----------------------------------------------------------------------------
95 class Instance : public DeviceInstance
96 {
97  friend class ParametricData<Instance>;
98  friend class Model;
99  friend class Traits;friend class Master;
100 
101 public:
102  Instance(
103  const Configuration & configuration,
104  const InstanceBlock & instance_block,
105  Model & model,
106  const FactoryBlock & factory_block);
107 
108  ~Instance();
109 
110 private:
111  Instance(const Instance &);
112  Instance &operator=(const Instance &);
113 
114 public:
115  void registerLIDs( const std::vector<int> & intLIDVecRef,
116  const std::vector<int> & extLIDVecRef );
117  void registerStateLIDs( const std::vector<int> & staLIDVecRef );
118  void registerStoreLIDs( const std::vector<int> & stoLIDVecRef);
119 
120  std::map<int,std::string> & getIntNameMap ();
121  std::map<int, std::string> & getStoreNameMap ();
122 
123  const std::vector< std::vector<int> > & jacobianStamp() const;
124  void registerJacLIDs( const std::vector< std::vector<int> > & jacLIDVec );
125 
126  bool processParams ();
127  bool updateTemperature ( const double & temp = -999.0 );
128  bool lambertWCurrent (double Isat, double Vte, double RS);
129  bool lambertWBreakdownCurrent (double Isat, double Vte, double RS);
130  bool lambertWLinearReverseBias (double Isat, double Vte, double RS);
131 
132  bool updateIntermediateVars ();
133  bool updatePrimaryState ();
134 
135  // load functions, residual:
136  bool loadDAEQVector ();
137  bool loadDAEFVector ();
138 
139  // load functions, Jacobian:
140  bool loadDAEdQdx ();
141  bool loadDAEdFdx ();
142 
143  void setupPointers();
144 
145 public:
146  // iterator reference to the diode model which owns this instance.
147  // Getters and setters
149  {
150  return model_;
151  }
152 
153 private:
154  static std::vector< std::vector<int> > jacStamp_RS;
155  static std::vector< std::vector<int> > jacStamp;
156 
157  static std::vector<int> jacMap_RS;
158  static std::vector<int> jacMap;
159 
160  static std::vector< std::vector<int> > jacMap2_RS;
161  static std::vector< std::vector<int> > jacMap2;
162 
163 
164  Model & model_; //< Owning model
165 
166  int off;
167  double Area;
168  double InitCond;
169  double Temp;
172 
173  double tJctPot;
174  double tJctCap;
175  double tDepCap;
176  double tSatCur;
177  double tVcrit;
178  double tF1;
179  double tBrkdwnV;
180  double tSatCurR;
181  double tIKF;
182  double tRS;
183  double tCOND;
184  double tIRF;
185 
186  double Id; //diode current
187  double Gd; //diode conductivity
188  double Cd; //depletion capacitance
189  double Gcd; //dep cap conductivity
190  double Qd; //capacitor charge
191  double Icd; //capacitor current
192  double Gspr;
193  //double LeadCurrent;
194 
195  double Vpp;
196  double Vp;
197  double Vn;
198  double Vc;
199 
200  double Vd;
201  double Vd_old;
202  double Vd_orig;
203 
205 
206  // end of intermediate variables
207 
208  // state variables:
209  double q0; // charge in the capacitor
210  double i0; // current throught the capacitor
211 
212  //local indices (offsets)
213  // int li_QState;
214 
215  // for voltage limiting
217 
218  // for lead current
220 
221  int li_Pos;
222  int li_Neg;
223  int li_Pri;
224 
225  // Matrix equation local offset variables
233 
234 #ifndef Xyce_NONPOINTER_MATRIX_LOAD
235  // Matrix equation local pointer variables
243 
251 #endif
252 
253 
254  // Flags
257 };
258 
259 //-----------------------------------------------------------------------------
260 // Class : Model
261 // Purpose :
262 // Special Notes :
263 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
264 // Creation Date : 02/28/00
265 //-----------------------------------------------------------------------------
266 class Model : public DeviceModel
267 {
268  typedef std::vector<Instance *> InstanceVector;
269 
270  friend class ParametricData<Model>;
271  friend class Instance;
272  friend class Traits;friend class Master;
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  bool processParams ();
291  bool processInstanceParams ();
292 
293 
294 public:
295  void addInstance(Instance *instance)
296  {
297  instanceContainer.push_back(instance);
298  }
299 
301  {
302  return instanceContainer;
303  }
304 
306  {
307  return instanceContainer;
308  }
309 
310 private:
311  std::vector<Instance*> instanceContainer;
312 
313 private:
314 
315  double IS; // saturation current (A)
316  double RS; // ohmic resistance (ohms)
317  double COND; // corresponding conductance
318  double N; // emission coefficient
319  double ISR; // recombination saturation current (A)
320  double NR; // emission coefficient for ISR
321  double IKF; // high-injection knee current (A)
322  double TT; // transit time (sec)
323  double CJO; // zero-bias junction capacitance (F)
324  double VJ; // built-in junction potential (V)
325  double M; // grading coefficient
326  double EG; // activation energy (eV).
327  // For Si, EG = 1.11
328  // Ge, EG = 0.67
329  // Sbd, EG = 0.69
330  double XTI; // isaturation-current temp. exp
331  double TIKF; // IKF temperature coeff.
332  double TBV1; // BV linear temperature coeff.
333  double TBV2; // BV quadratic temperature coeff.
334  double TRS1; // RS linear temperature coeff.
335  double TRS2; // RS quadratic temperature coeff.
336  double FC; // coefficient for forward-bias depletion capacitance
337  // formula
338  double BV; // reverse breakdown voltage
339  double IBV; // current at breakdown voltage (A)
340  double IRF; // adjustment for linear portion of reverse current
341  double NBV; // reverse breakdown ideality factor
342  double IBVL; // low-level current at breakdown voltage (A)
343  double NBVL; // low-level reverse breakdown ideality factor
344  double F2;
345  double F3;
346  double TNOM; // parameter measurement temperature (C)
347  double KF; // flicker noise coefficient
348  double AF; // flicker noise exponent
349 
350  bool BVGiven;
351 };
352 
353 //-----------------------------------------------------------------------------
354 // Class : Master
355 // Purpose :
356 // Special Notes :
357 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
358 // Creation Date : 11/26/08
359 //-----------------------------------------------------------------------------
360 class Master : public DeviceMaster<Traits>
361 {
362  friend class Instance;
363  friend class Model;
364 
365 public:
367  const Configuration & configuration,
368  const FactoryBlock & factory_block,
369  const SolverState & ss1,
370  const DeviceOptions & do1)
371  : DeviceMaster<Traits>(configuration, factory_block, ss1, do1)
372  {}
373 
374  virtual bool updateState (double * solVec, double * staVec, double * stoVec);
375 
376  // new DAE stuff:
377  // new DAE load functions, residual:
378  virtual bool loadDAEVectors (double * solVec, double * fVec, double * qVec, double * storeLeadF, double * storeLeadQ);
379 
380  // new DAE load functions, Jacobian:
381  virtual bool loadDAEMatrices (N_LAS_Matrix & dFdx, N_LAS_Matrix & dQdx);
382 };
383 
384 void registerDevice();
385 
386 } // namespace Diode
387 } // namespace Device
388 } // namespace Xyce
389 
393 
394 #endif
395