Xyce  6.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
N_DEV_JFET.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_JFET.h,v $
27 //
28 // Purpose : Junction field effect transistor (JFET) 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.85 $
40 //
41 // Revision Date : $Date: 2014/05/22 17:40:28 $
42 //
43 // Current Owner : $Author: erkeite $
44 //-----------------------------------------------------------------------------
45 
46 #ifndef Xyce_N_DEV_JFET_h
47 #define Xyce_N_DEV_JFET_h
48 
49 // ---------- Xyce Includes ----------
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 JFET {
58 
59 class Model;
60 class Instance;
61 
62 struct Traits : public DeviceTraits<Model, Instance>
63 {
64  static const char *name() {return "JFET";}
65  static const char *deviceTypeName() {return "J leve1 1,2";}
66  static int numNodes() {return 3;}
67  static bool modelRequired() {return true;}
68  static bool isLinearDevice() {return false;}
69 
70  static Device *factory(const Configuration &configuration, const FactoryBlock &factory_block);
71  static void loadModelParameters(ParametricData<Model> &model_parameters);
72  static void loadInstanceParameters(ParametricData<Instance> &instance_parameters);
73 };
74 
75 //-----------------------------------------------------------------------------
76 // Class : Instance
77 // Purpose :
78 // Special Notes :
79 // Creator : pmc
80 // Creation Date : 11/16/2003
81 //-----------------------------------------------------------------------------
82 class Instance : public DeviceInstance
83 {
84  friend class ParametricData<Instance>;
85  friend class Model;
86  friend class Traits;
87  friend class Master;
88 
89 public:
90  Instance(
91  const Configuration & configuration,
92  const InstanceBlock & instance_block,
93  Model & model,
94  const FactoryBlock & factory_block);
95  ~Instance();
96 
97 private:
98  Instance(const Instance &);
99  Instance &operator=(const Instance &);
100 
101 public:
102  void registerLIDs( const std::vector<int> & intLIDVecRef,
103  const std::vector<int> & extLIDVecRef );
104  void registerStateLIDs( const std::vector<int> & staLIDVecRef );
105  void registerStoreLIDs(const std::vector<int> & stoLIDVecRef);
106 
107  std::map<int,std::string> & getIntNameMap ();
108  std::map<int,std::string> & getStoreNameMap ();
109 
110  const std::vector< std::vector<int> > & jacobianStamp() const;
111  void registerJacLIDs( const std::vector< std::vector<int> > & jacLIDVec );
112 
113  // load functions, residual:
114  bool loadDAEQVector ();
115  bool loadDAEFVector ();
116 
117  // load functions, Jacobian:
118  bool loadDAEdQdx ();
119  bool loadDAEdFdx ();
120 
121  void setupPointers ();
122 
123  bool updateIntermediateVars ();
124  bool updatePrimaryState ();
125 
126  bool processParams ();
127  bool updateTemperature(const double & temp_tmp);
128 
129 #ifndef Xyce_ERK_JFET_CONV_TEST
130  inline bool isConverged();
131 #endif
132 
133 public:
134  // Getters and setters
136  {
137  return model_;
138  }
139 
140 private:
141  static std::vector< std::vector<int> > jacStamp_DC_SC;
142  static std::vector< std::vector<int> > jacStamp_DC;
143  static std::vector< std::vector<int> > jacStamp_SC;
144  static std::vector< std::vector<int> > jacStamp;
145 
146  static std::vector<int> jacMap_DC_SC;
147  static std::vector<int> jacMap_DC;
148  static std::vector<int> jacMap_SC;
149  static std::vector<int> jacMap;
150 
151  static std::vector< std::vector<int> > jacMap2_DC_SC;
152  static std::vector< std::vector<int> > jacMap2_DC;
153  static std::vector< std::vector<int> > jacMap2_SC;
154  static std::vector< std::vector<int> > jacMap2;
155 
156 
157  Model & model_; //< Owning model
158 
159  bool limitedFlag; // device convergence.
160  bool off; // non-zero indicates device is off for dc analysis
161  int ic; // initial VDS, VGS vector
162  double area; // area factor
163  double ic_vds; // initial D-S voltage
164  double ic_vgs; // initial G-S voltage
165  double temp; // instance temperature
166  double drainCond; // drain conductance
167  double sourceCond; // source conductance
168  double tCGS; // temp. corr. gate-source capacitance
169  double tCGD; // temp. corr. gate-drain capacitance
170  double tIS; // temp. corr. saturation current
171  double tPB; // temp. corr. gate potential
172  double tJFETb; // temp. corr. dopinng tail parameter
173  double tBeta; // temp. corr. Beta
174  double tvt0; // temp. corr. vt0
175  double tLambda; // temp. corr. Lambda
176  double tDelta; // temp. corr. Delta
177  double tTheta; // temp. corr. Theta
178  double tRD; // temp. corr. drain resistance
179  double tRS; // temp. corr. source resistance
180  double vt; // set in updateTemperature to CONSTKoverQ*temp
181 
182  int dNode; // number of drain node
183  int gNode; // number of gate node
184  int sNode; // number of source node
185  int dpNode; // internal drain node
186  int spNode; // internal source node
187  double Vgs; // voltage G-S
188  double Vgd; // voltage G-D
189  double gm; // transconductance
190  double gds; // dc conductance D-S
191  double ggs; // dc conductance G-S
192  double ggd; // dc conductance G-D
193  double cdrain; // channel current
194 
195  double cdTRAN; // drain current, dc + tran terms
196  double cgTRAN; // gate current, dc + tran terms
197  double cgdTRAN; // gate-drain current, dc + tran terms
198 
199  double cd; // drain current
200  double cg; // total dc gate current
201  double cgd; // dc gate-drain current
202 
203  double corDepCap; // joining point of fwd bias dep. cap.
204  double vcrit; // critical voltage
205  double f1; // coeff. of capacitance polynomial exponent
206  double f2;
207  double f3;
208  double Bfac; // doping profile parameter
209  double p; // power dissipated by the JFET
210 
211  // Solution variables and intermediate quantities
212  // drain,source,gate, drainprime and sourceprime voltages
213  double Vd;
214  double Vs;
215  double Vg;
216  double Vdp;
217  double Vsp;
218 
219  // voltage drops between pairs of nodes
220  double Vddp; // drain-drain'
221  double Vssp; // source-source'
222  double Vgsp; // gate-source'
223  double Vgdp; // gate-drain'
224  double Vdpsp; //drop across channel
225 
226  // vector local indices
227  int li_Drain;
231  int li_Gate;
232 
233  /////////////////////////////////////////////////////////////////
234  // Jacobian matrix indices:
235  // This is a 5x5 matrix block, of which 15 entries are nonzero:
236  //
237  // ----------------------------------------------------
238  // | #NZ | | |
239  // | entries | | V_d V_g V_s V_d' V_s' |
240  // ----------------------------------------------------
241  // | 2 | KCL_d | a b |
242  // | 3 | KCL_g | c e f |
243  // | 2 | KCL_s | g h |
244  // | 4 | KCL_d'| m n p q |
245  // | 4 | KCL_s'| r s u v |
246  // ----------------------------------------------------
247  // 15 total
248 
249  ////////////////////////////////////////////////////////////////////
250  // Offset variables corresponding to the above declared indices.
251 
252  // Jacobian Matrix Offset:
253 
254  // V_d Row:
257 
258  // V_g Row:
262 
263  // V_s Row:
266 
267  // V_d' Row:
272 
273  // V_s' Row:
278 
279 #ifndef Xyce_NONPOINTER_MATRIX_LOAD
280  ////////////////////////////////////////////////////////////////////
281  // dFdx Matrix Ptr:
282  // V_d Row:
283  double * f_DrainEquDrainNodePtr; // a
285 
286  // V_g Row:
287  double * f_GateEquGateNodePtr; // c
290 
291  // V_s Row:
294 
295  // V_d' Row:
300 
301  // V_s' Row:
306 
307  ////////////////////////////////////////////////////////////////////
308  // dQdx Matrix Ptr:
309 
310  // V_d Row:
311  double * q_DrainEquDrainNodePtr; // a
313 
314  // V_g Row:
315  double * q_GateEquGateNodePtr; // c
318 
319  // V_s Row:
322 
323  // V_d' Row:
328 
329  // V_s' Row:
334 #endif
335 
336  ////////////////////////////////////////////////////////////////////
337  // 3f5 State Variables & related quantities:
338  // voltage drops
339  double vgs;
340  double vgd;
341  double vds;
342 
343  // "original" versions of various voltage drop variables:
344  double vgs_orig;
345  double vgd_orig;
346  double vds_orig;
347 
348  // "old" versions of various voltage drop variables:
349  double vgs_old;
350  double vgd_old;
351  double vds_old;
352 
354 
355  int mode; // device mode : 1 = normal, -1 = inverse
356 
357  //gate-source capacitor
358  double gCAPgs; // conductance for old-DAE
359  double capgs; // value
360  double qgs; // charge
361  double cqgs; // trans. G-S current
362  double gcgs; // conductance, d(cqgs)/dVgs
363 
364  // gate-drain capacitor
365  double gCAPgd; // conductance for old-DAE
366  double capgd; // value
367  double qgd; // charge
368  double cqgd; // trans. G-D current
369  double gcgd; // conductance, d(cqgd)/dVgd
370 
371  // current through source and drain JFETs
372  double Isource;
373  double Idrain;
374 
375  // local indices
378  int li_store_dev_id; // lead current for drain
379  int li_store_dev_is; // lead current for source
380  int li_store_dev_ig; // lead current for gate
381 
386 };
387 
388 //-----------------------------------------------------------------------------
389 // Class : Model
390 // Purpose :
391 // Special Notes :
392 // Creator : pmc
393 // Creation Date : 11/16/2003
394 //-----------------------------------------------------------------------------
395 class Model : public DeviceModel
396 {
397  typedef std::vector<Instance *> InstanceVector;
398 
399  friend class ParametricData<Model>;
400  friend class Instance;
401  friend class Traits;friend class Master;
402 
403 public:
404  Model(
405  const Configuration & configuration,
406  const ModelBlock & MB,
407  const FactoryBlock & factory_block);
408  ~Model();
409 
410 private:
411  Model();
412  Model(const Model &);
413  Model &operator=(const Model &);
414 
415 public:
416  virtual void forEachInstance(DeviceInstanceOp &op) const /* override */;
417 
418  virtual std::ostream &printOutInstances(std::ostream &os) const;
419  bool processParams ();
420  bool processInstanceParams ();
421 
422 
423 public:
424  void addInstance(Instance *instance)
425  {
426  instanceContainer.push_back(instance);
427  }
428 
429 private:
430  std::vector<Instance*> instanceContainer;
431 
432 private:
433 
434  //user-specified parameters
435  double AF; // flicker noise exponent, default=1
436  double B; // doping tail parameter, default=1
437  double BETA; // transconductance paramter (A/V^2), default=1.0E-4
438  double CGS; // zero-bias G-S junction capacitance (F), default=5pf
439  double CGD; // zero-bias G-D junction capacitance (F), default=1pf
440  double FC; // coeff. for forward-bias depletion cap., default=0.5
441  double IS; // gate junction saturation current (A), default=1.0E-14
442  double KF; // flicker noise coefficient, default=0
443  double LAMBDA; // channel-length modulation parameter (1/V), default=0
444  double PB; // gate junction potential (V), default=1
445  double RD; // drain ohmic resistance (ohms), default=0
446  double RS; // source ohmic resistance (ohms), default=0
447  double TNOM; // parameter measurement temperature (C), default=27
448  double VTO; // threshhold voltage (V), default=-2.0
449  double DELTA; // saturation voltage parameter
450  double THETA; // gate voltage mobility parameter
451  double fNcoef; // default=0;
452  double fNexp; // default=1;
453 
454 
455  int dtype; // device type: 1 = NJF, -1 = PJF
456 };
457 
458 #ifndef Xyce_ERK_JFET_CONV_TEST
459 //-----------------------------------------------------------------------------
460 // Function : Instance:isConverged ()
461 // Purpose : Return whether a MOSFET device has done something that
462 // should be interpreted as invalidating other convergence
463 // tests
464 // In case of jfet, just do it if the limiter function
465 // pnjlim changed anything.
466 // This actually agrees with how the Check flag
467 // is used in Spice3F5 jfetload.c
468 // Special Notes :
469 // Scope : public
470 // Creator : Tom Russo, SNL, Component Information and Models
471 // Creation Date : 03/22/05
472 //-----------------------------------------------------------------------------
474 {
475  return (!limitedFlag);
476 }
477 #endif
478 
479 //-----------------------------------------------------------------------------
480 // Class : Master
481 // Purpose :
482 // Special Notes :
483 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
484 // Creation Date : 11/26/08
485 //-----------------------------------------------------------------------------
486 class Master : public DeviceMaster<Traits>
487 {
488  friend class Instance;
489  friend class Model;
490 
491 public:
493  const Configuration & configuration,
494  const FactoryBlock & factory_block,
495  const SolverState & ss1,
496  const DeviceOptions & do1)
497  : DeviceMaster<Traits>(configuration, factory_block, ss1, do1)
498  {}
499 
500  virtual bool updateState (double * solVec, double * staVec, double * stoVec);
501 
502  // new DAE stuff:
503  // new DAE load functions, residual:
504  virtual bool loadDAEVectors (double * solVec, double * fVec, double * qVec, double * bVec, double * storeLeadF, double * storeLeadQ);
505 
506  // new DAE load functions, Jacobian:
507  virtual bool loadDAEMatrices (N_LAS_Matrix & dFdx, N_LAS_Matrix & dQdx);
508 };
509 
510 void registerDevice();
511 
512 } // namespace JFET
513 } // namespace Device
514 } // namespace Xyce
515 
519 
520 #endif