Xyce  6.1
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-2015 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.90.2.1 $
40 //
41 // Revision Date : $Date: 2015/04/02 18:20:11 $
42 //
43 // Current Owner : $Author: tvrusso $
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  void loadNodeSymbols(Util::SymbolTable &symbol_table) const; // override
108 
109  const std::vector< std::vector<int> > & jacobianStamp() const;
110  void registerJacLIDs( const std::vector< std::vector<int> > & jacLIDVec );
111 
112  // load functions, residual:
113  bool loadDAEQVector ();
114  bool loadDAEFVector ();
115 
116  // load functions, Jacobian:
117  bool loadDAEdQdx ();
118  bool loadDAEdFdx ();
119 
120  void setupPointers ();
121 
122  bool updateIntermediateVars ();
123  bool updatePrimaryState ();
124 
125  bool processParams ();
126  bool updateTemperature(const double & temp_tmp);
127 
128 #ifndef Xyce_ERK_JFET_CONV_TEST
129  inline bool isConverged();
130 #endif
131 
132 public:
133  // Getters and setters
135  {
136  return model_;
137  }
138 
139 private:
140  static std::vector< std::vector<int> > jacStamp_DC_SC;
141  static std::vector< std::vector<int> > jacStamp_DC;
142  static std::vector< std::vector<int> > jacStamp_SC;
143  static std::vector< std::vector<int> > jacStamp;
144 
145  static std::vector<int> jacMap_DC_SC;
146  static std::vector<int> jacMap_DC;
147  static std::vector<int> jacMap_SC;
148  static std::vector<int> jacMap;
149 
150  static std::vector< std::vector<int> > jacMap2_DC_SC;
151  static std::vector< std::vector<int> > jacMap2_DC;
152  static std::vector< std::vector<int> > jacMap2_SC;
153  static std::vector< std::vector<int> > jacMap2;
154 
155 
156  Model & model_; //< Owning model
157 
158  bool limitedFlag; // device convergence.
159  bool off; // non-zero indicates device is off for dc analysis
160  int ic; // initial VDS, VGS vector
161  double area; // area factor
162  double ic_vds; // initial D-S voltage
163  double ic_vgs; // initial G-S voltage
164  double temp; // instance temperature
165  double drainCond; // drain conductance
166  double sourceCond; // source conductance
167  double tCGS; // temp. corr. gate-source capacitance
168  double tCGD; // temp. corr. gate-drain capacitance
169  double tIS; // temp. corr. saturation current
170  double tPB; // temp. corr. gate potential
171  double tJFETb; // temp. corr. dopinng tail parameter
172  double tBeta; // temp. corr. Beta
173  double tvt0; // temp. corr. vt0
174  double tLambda; // temp. corr. Lambda
175  double tDelta; // temp. corr. Delta
176  double tTheta; // temp. corr. Theta
177  double tRD; // temp. corr. drain resistance
178  double tRS; // temp. corr. source resistance
179  double vt; // set in updateTemperature to CONSTKoverQ*temp
180 
181  int dNode; // number of drain node
182  int gNode; // number of gate node
183  int sNode; // number of source node
184  int dpNode; // internal drain node
185  int spNode; // internal source node
186  double Vgs; // voltage G-S
187  double Vgd; // voltage G-D
188  double gm; // transconductance
189  double gds; // dc conductance D-S
190  double ggs; // dc conductance G-S
191  double ggd; // dc conductance G-D
192  double cdrain; // channel current
193 
194  double cdTRAN; // drain current, dc + tran terms
195  double cgTRAN; // gate current, dc + tran terms
196  double cgdTRAN; // gate-drain current, dc + tran terms
197 
198  double cd; // drain current
199  double cg; // total dc gate current
200  double cgd; // dc gate-drain current
201 
202  double corDepCap; // joining point of fwd bias dep. cap.
203  double vcrit; // critical voltage
204  double f1; // coeff. of capacitance polynomial exponent
205  double f2;
206  double f3;
207  double Bfac; // doping profile parameter
208  double p; // power dissipated by the JFET
209 
210  // Solution variables and intermediate quantities
211  // drain,source,gate, drainprime and sourceprime voltages
212  double Vd;
213  double Vs;
214  double Vg;
215  double Vdp;
216  double Vsp;
217 
218  // voltage drops between pairs of nodes
219  double Vddp; // drain-drain'
220  double Vssp; // source-source'
221  double Vgsp; // gate-source'
222  double Vgdp; // gate-drain'
223  double Vdpsp; //drop across channel
224 
225  // vector local indices
226  int li_Drain;
230  int li_Gate;
231 
232  /////////////////////////////////////////////////////////////////
233  // Jacobian matrix indices:
234  // This is a 5x5 matrix block, of which 15 entries are nonzero:
235  //
236  // ----------------------------------------------------
237  // | #NZ | | |
238  // | entries | | V_d V_g V_s V_d' V_s' |
239  // ----------------------------------------------------
240  // | 2 | KCL_d | a b |
241  // | 3 | KCL_g | c e f |
242  // | 2 | KCL_s | g h |
243  // | 4 | KCL_d'| m n p q |
244  // | 4 | KCL_s'| r s u v |
245  // ----------------------------------------------------
246  // 15 total
247 
248  ////////////////////////////////////////////////////////////////////
249  // Offset variables corresponding to the above declared indices.
250 
251  // Jacobian Matrix Offset:
252 
253  // V_d Row:
256 
257  // V_g Row:
261 
262  // V_s Row:
265 
266  // V_d' Row:
271 
272  // V_s' Row:
277 
278 #ifndef Xyce_NONPOINTER_MATRIX_LOAD
279  ////////////////////////////////////////////////////////////////////
280  // dFdx Matrix Ptr:
281  // V_d Row:
282  double * f_DrainEquDrainNodePtr; // a
284 
285  // V_g Row:
286  double * f_GateEquGateNodePtr; // c
289 
290  // V_s Row:
293 
294  // V_d' Row:
299 
300  // V_s' Row:
305 
306  ////////////////////////////////////////////////////////////////////
307  // dQdx Matrix Ptr:
308 
309  // V_d Row:
310  double * q_DrainEquDrainNodePtr; // a
312 
313  // V_g Row:
314  double * q_GateEquGateNodePtr; // c
317 
318  // V_s Row:
321 
322  // V_d' Row:
327 
328  // V_s' Row:
333 #endif
334 
335  ////////////////////////////////////////////////////////////////////
336  // 3f5 State Variables & related quantities:
337  // voltage drops
338  double vgs;
339  double vgd;
340  double vds;
341 
342  // "original" versions of various voltage drop variables:
343  double vgs_orig;
344  double vgd_orig;
345  double vds_orig;
346 
347  // "old" versions of various voltage drop variables:
348  double vgs_old;
349  double vgd_old;
350  double vds_old;
351 
352  int mode; // device mode : 1 = normal, -1 = inverse
353 
354  //gate-source capacitor
355  double gCAPgs; // conductance for old-DAE
356  double capgs; // value
357  double qgs; // charge
358  double cqgs; // trans. G-S current
359  double gcgs; // conductance, d(cqgs)/dVgs
360 
361  // gate-drain capacitor
362  double gCAPgd; // conductance for old-DAE
363  double capgd; // value
364  double qgd; // charge
365  double cqgd; // trans. G-D current
366  double gcgd; // conductance, d(cqgd)/dVgd
367 
368  // current through source and drain JFETs
369  double Isource;
370  double Idrain;
371 
372  // local indices
375  int li_store_dev_id; // lead current for drain
376  int li_store_dev_is; // lead current for source
377  int li_store_dev_ig; // lead current for gate
378 
383 };
384 
385 //-----------------------------------------------------------------------------
386 // Class : Model
387 // Purpose :
388 // Special Notes :
389 // Creator : pmc
390 // Creation Date : 11/16/2003
391 //-----------------------------------------------------------------------------
392 class Model : public DeviceModel
393 {
394  typedef std::vector<Instance *> InstanceVector;
395 
396  friend class ParametricData<Model>;
397  friend class Instance;
398  friend class Traits;friend class Master;
399 
400 public:
401  Model(
402  const Configuration & configuration,
403  const ModelBlock & MB,
404  const FactoryBlock & factory_block);
405  ~Model();
406 
407 private:
408  Model();
409  Model(const Model &);
410  Model &operator=(const Model &);
411 
412 public:
413  virtual void forEachInstance(DeviceInstanceOp &op) const /* override */;
414 
415  virtual std::ostream &printOutInstances(std::ostream &os) const;
416  bool processParams ();
417  bool processInstanceParams ();
418 
419 
420 public:
421  void addInstance(Instance *instance)
422  {
423  instanceContainer.push_back(instance);
424  }
425 
426 private:
427  std::vector<Instance*> instanceContainer;
428 
429 private:
430 
431  //user-specified parameters
432  double AF; // flicker noise exponent, default=1
433  double B; // doping tail parameter, default=1
434  double BETA; // transconductance paramter (A/V^2), default=1.0E-4
435  double CGS; // zero-bias G-S junction capacitance (F), default=5pf
436  double CGD; // zero-bias G-D junction capacitance (F), default=1pf
437  double FC; // coeff. for forward-bias depletion cap., default=0.5
438  double IS; // gate junction saturation current (A), default=1.0E-14
439  double KF; // flicker noise coefficient, default=0
440  double LAMBDA; // channel-length modulation parameter (1/V), default=0
441  double PB; // gate junction potential (V), default=1
442  double RD; // drain ohmic resistance (ohms), default=0
443  double RS; // source ohmic resistance (ohms), default=0
444  double TNOM; // parameter measurement temperature (C), default=27
445  double VTO; // threshhold voltage (V), default=-2.0
446  double DELTA; // saturation voltage parameter
447  double THETA; // gate voltage mobility parameter
448  double fNcoef; // default=0;
449  double fNexp; // default=1;
450 
451 
452  int dtype; // device type: 1 = NJF, -1 = PJF
453 };
454 
455 #ifndef Xyce_ERK_JFET_CONV_TEST
456 //-----------------------------------------------------------------------------
457 // Function : Instance:isConverged ()
458 // Purpose : Return whether a MOSFET device has done something that
459 // should be interpreted as invalidating other convergence
460 // tests
461 // In case of jfet, just do it if the limiter function
462 // pnjlim changed anything.
463 // This actually agrees with how the Check flag
464 // is used in Spice3F5 jfetload.c
465 // Special Notes :
466 // Scope : public
467 // Creator : Tom Russo, SNL, Component Information and Models
468 // Creation Date : 03/22/05
469 //-----------------------------------------------------------------------------
471 {
472  return (!limitedFlag);
473 }
474 #endif
475 
476 //-----------------------------------------------------------------------------
477 // Class : Master
478 // Purpose :
479 // Special Notes :
480 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
481 // Creation Date : 11/26/08
482 //-----------------------------------------------------------------------------
483 class Master : public DeviceMaster<Traits>
484 {
485  friend class Instance;
486  friend class Model;
487 
488 public:
490  const Configuration & configuration,
491  const FactoryBlock & factory_block,
492  const SolverState & ss1,
493  const DeviceOptions & do1)
494  : DeviceMaster<Traits>(configuration, factory_block, ss1, do1)
495  {}
496 
497  virtual bool updateState (double * solVec, double * staVec, double * stoVec);
498 
499  // new DAE stuff:
500  // new DAE load functions, residual:
501  virtual bool loadDAEVectors (double * solVec, double * fVec, double * qVec, double * bVec, double * storeLeadF, double * storeLeadQ, double * leadF, double * leadQ, double * junctionV);
502 
503  // new DAE load functions, Jacobian:
504  virtual bool loadDAEMatrices (Linear::Matrix & dFdx, Linear::Matrix & dQdx);
505 };
506 
507 void registerDevice();
508 
509 } // namespace JFET
510 } // namespace Device
511 } // namespace Xyce
512 
513 #endif
double * q_SourcePrimeEquSourceNodePtr
Definition: N_DEV_JFET.h:330
Master(const Configuration &configuration, const FactoryBlock &factory_block, const SolverState &ss1, const DeviceOptions &do1)
Definition: N_DEV_JFET.h:489
Instance(const Configuration &configuration, const InstanceBlock &instance_block, Model &model, const FactoryBlock &factory_block)
Definition: N_DEV_JFET.C:372
static std::vector< int > jacMap_SC
Definition: N_DEV_JFET.h:147
bool updateTemperature(const double &temp_tmp)
Definition: N_DEV_JFET.C:1746
Pure virtual class to augment a linear system.
virtual std::ostream & printOutInstances(std::ostream &os) const
Definition: N_DEV_JFET.C:280
static const char * deviceTypeName()
Definition: N_DEV_JFET.h:65
virtual void forEachInstance(DeviceInstanceOp &op) const
Apply a device instance "op" to all instances associated with this model.
Definition: N_DEV_JFET.C:318
Instance & operator=(const Instance &)
static std::vector< std::vector< int > > jacStamp
Definition: N_DEV_JFET.h:143
double * f_SourceEquSourcePrimeNodePtr
Definition: N_DEV_JFET.h:292
double * f_DrainPrimeEquSourcePrimeNodePtr
Definition: N_DEV_JFET.h:298
static std::vector< int > jacMap_DC
Definition: N_DEV_JFET.h:146
static std::vector< std::vector< int > > jacStamp_SC
Definition: N_DEV_JFET.h:142
static std::vector< std::vector< int > > jacStamp_DC
Definition: N_DEV_JFET.h:141
double * q_SourcePrimeEquDrainPrimeNodePtr
Definition: N_DEV_JFET.h:331
static bool isLinearDevice()
Definition: N_DEV_JFET.h:68
double * q_SourceEquSourcePrimeNodePtr
Definition: N_DEV_JFET.h:320
double * f_DrainPrimeEquDrainPrimeNodePtr
Definition: N_DEV_JFET.h:297
std::vector< Instance * > instanceContainer
Definition: N_DEV_JFET.h:427
static bool modelRequired()
Definition: N_DEV_JFET.h:67
DeviceMaster instantiates a device as described by the device traits T.
double * f_SourcePrimeEquSourceNodePtr
Definition: N_DEV_JFET.h:302
The FactoryBlock contains parameters needed by the device, instance and model creation functions...
void registerStoreLIDs(const std::vector< int > &stoLIDVecRef)
Definition: N_DEV_JFET.C:766
double * q_SourcePrimeEquSourcePrimeNodePtr
Definition: N_DEV_JFET.h:332
virtual bool loadDAEVectors(double *solVec, double *fVec, double *qVec, double *bVec, double *storeLeadF, double *storeLeadQ, double *leadF, double *leadQ, double *junctionV)
Populates the device's ExternData object with these pointers.
Definition: N_DEV_JFET.C:1931
static std::vector< std::vector< int > > jacMap2_DC
Definition: N_DEV_JFET.h:151
double * q_DrainPrimeEquDrainPrimeNodePtr
Definition: N_DEV_JFET.h:325
bool processParams()
processParams
Definition: N_DEV_JFET.C:333
static void loadModelParameters(ParametricData< Model > &model_parameters)
Definition: N_DEV_JFET.C:82
static std::vector< std::vector< int > > jacMap2_DC_SC
Definition: N_DEV_JFET.h:150
The Device class is an interface for device implementations.
Definition: N_DEV_Device.h:101
const std::vector< std::vector< int > > & jacobianStamp() const
Definition: N_DEV_JFET.C:792
static std::vector< std::vector< int > > jacStamp_DC_SC
Definition: N_DEV_JFET.h:140
static std::vector< int > jacMap
Definition: N_DEV_JFET.h:148
Class Configuration contains device configuration data.
virtual bool loadDAEMatrices(Linear::Matrix &dFdx, Linear::Matrix &dQdx)
Populates the device's Jacobian object with these pointers.
Definition: N_DEV_JFET.C:2030
static void loadInstanceParameters(ParametricData< Instance > &instance_parameters)
Definition: N_DEV_JFET.C:70
static std::vector< int > jacMap_DC_SC
Definition: N_DEV_JFET.h:145
std::vector< Instance * > InstanceVector
Definition: N_DEV_JFET.h:394
void registerStateLIDs(const std::vector< int > &staLIDVecRef)
Definition: N_DEV_JFET.C:719
void registerLIDs(const std::vector< int > &intLIDVecRef, const std::vector< int > &extLIDVecRef)
Definition: N_DEV_JFET.C:633
bool processInstanceParams()
processInstanceParams
Definition: N_DEV_JFET.C:347
double * f_SourcePrimeEquSourcePrimeNodePtr
Definition: N_DEV_JFET.h:304
static Device * factory(const Configuration &configuration, const FactoryBlock &factory_block)
Definition: N_DEV_JFET.C:2168
virtual bool updateState(double *solVec, double *staVec, double *stoVec)
Updates the devices state information.
Definition: N_DEV_JFET.C:1903
void addInstance(Instance *instance)
Definition: N_DEV_JFET.h:421
void registerJacLIDs(const std::vector< std::vector< int > > &jacLIDVec)
Definition: N_DEV_JFET.C:813
Model & operator=(const Model &)
static const char * name()
Definition: N_DEV_JFET.h:64
ModelBlock represents a .MODEL line from the netlist.
The DeviceTraits template describes the configuration of a device.
double * f_SourcePrimeEquDrainPrimeNodePtr
Definition: N_DEV_JFET.h:303
Manages parameter binding for class C.
Definition: N_DEV_Pars.h:214
InstanceBlock represent a device instance line from the netlist.
void loadNodeSymbols(Util::SymbolTable &symbol_table) const
Populates and returns the store name map.
Definition: N_DEV_JFET.C:695
double * q_DrainPrimeEquSourcePrimeNodePtr
Definition: N_DEV_JFET.h:326
static std::vector< std::vector< int > > jacMap2
Definition: N_DEV_JFET.h:153
static std::vector< std::vector< int > > jacMap2_SC
Definition: N_DEV_JFET.h:152