Xyce  6.1
N_DEV_MESFET.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_MESFET.h,v $
27 //
28 // Purpose : MESFET transistor 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.78 $
40 //
41 // Revision Date : $Date: 2015/04/08 19:18:24 $
42 //
43 // Current Owner : $Author: tvrusso $
44 //-----------------------------------------------------------------------------
45 
46 #ifndef Xyce_N_DEV_MESFET_h
47 #define Xyce_N_DEV_MESFET_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 MESFET {
58 
59 class Model;
60 class Instance;
61 
62 struct Traits : public DeviceTraits<Model, Instance>
63 {
64  static const char *name() {return "MESFET";}
65  static const char *deviceTypeName() {return "Z level 1";}
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 //--------------- Class Instance ----------------------------------
76 //-----------------------------------------------------------------------------
77 // Class : Instance
78 // Purpose :
79 // Special Notes :
80 // Creator : pmc
81 // Creation Date : 11/16/2003
82 //-----------------------------------------------------------------------------
83 class Instance : public DeviceInstance
84 {
85  friend class ParametricData<Instance>;
86  friend class Model;
87  friend class Traits;
88  friend class Master;
89 
90 public:
91  Instance(
92  const Configuration & configuration,
93  const InstanceBlock & instance_block,
94  Model & model,
95  const FactoryBlock & factory_block);
96 
97  ~Instance();
98 
99 private:
100  Instance(const Instance &);
101  Instance &operator=(const Instance &);
102 
103 public:
104  void registerLIDs( const std::vector<int> & intLIDVecRef,
105  const std::vector<int> & extLIDVecRef );
106  void registerStateLIDs( const std::vector<int> & staLIDVecRef );
107  void registerStoreLIDs(const std::vector<int> & stoLIDVecRef);
108 
109  void loadNodeSymbols(Util::SymbolTable &symbol_table) const; // override
110 
111  const std::vector< std::vector<int> > & jacobianStamp() const;
112  void registerJacLIDs( const std::vector< std::vector<int> > & jacLIDVec );
113 
114  // load functions, residual:
115  bool loadDAEQVector ();
116  bool loadDAEFVector ();
117 
118  // load functions, Jacobian:
119  bool loadDAEdQdx ();
120  bool loadDAEdFdx ();
121 
122  void setupPointers ();
123 
124  bool updateIntermediateVars ();
125  bool updatePrimaryState ();
126 
127  bool processParams ();
128  bool updateTemperature(const double & temp_tmp);
129 
130  inline bool isConverged();
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 tMESb; // 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 tAlpha; // saturation voltage parameter
176  double tRD; // temp. corr. drain resistance
177  double tRS; // temp. corr. source resistance
178  double vt; // set in updateTemperature to CONSTKoverQ*temp
179 
180  int dNode; // number of drain node
181  int gNode; // number of gate node
182  int sNode; // number of source node
183  int dpNode; // internal drain node
184  int spNode; // internal source node
185  double Vgs; // voltage G-S
186  double Vgd; // voltage G-D
187  double gm; // transconductance
188  double gds; // dc conductance D-S
189  double ggs; // dc conductance G-S
190  double ggd; // dc conductance G-D
191  double cdrain; // channel current
192  double cd; // drain current
193  double cg; // total dc gate current
194  double cgd; // dc gate-drain current
195  double corDepCap; // joining point of fwd bias dep. cap.
196  double vcrit; // critical voltage
197  double f1; // coeff. of capacitance polynomial exponent
198  double f2;
199  double f3;
200  double Bfac; // doping profile parameter
201  double p; // power dissipated by the MESFET
202 
205 
206  // Solution variables and intermediate quantities
207  // drain,source,gate, drainprime and sourceprime voltages
208  double Vd;
209  double Vs;
210  double Vg;
211  double Vdp;
212  double Vsp;
213 
214  // voltage drops between pairs of nodes
215  double Vddp; // drain-drain'
216  double Vssp; // source-source'
217  double Vgsp; // gate-source'
218  double Vgdp; // gate-drain'
219  double Vdpsp; //drop across channel
220 
221  // vector local indices
222  int li_Drain;
226  int li_Gate;
227 
228  /////////////////////////////////////////////////////////////////
229  // Jacobian matrix indices:
230  // This is a 5x5 matrix block, of which 15 entries are nonzero:
231  //
232  // ----------------------------------------------------
233  // | #NZ | | |
234  // | entries | | V_d V_g V_s V_d' V_s' |
235  // ----------------------------------------------------
236  // | 2 | KCL_d | a b |
237  // | 3 | KCL_g | c e f |
238  // | 2 | KCL_s | g h |
239  // | 4 | KCL_d'| m n p q |
240  // | 4 | KCL_s'| r s u v |
241  // ----------------------------------------------------
242  // 15 total
243 
244  ////////////////////////////////////////////////////////////////////
245  // Offset variables corresponding to the above declared indices.
246 
247  // Jacobian Matrix Offset:
248 
249  // V_d Row:
252 
253  // V_g Row:
257 
258  // V_s Row:
261 
262  // V_d' Row:
267 
268  // V_s' Row:
273 
274 
275 #ifndef Xyce_NONPOINTER_MATRIX_LOAD
276  ////////////////////////////////////////////////////////////////////
277  // dFdx Matrix Ptr:
278  // V_d Row:
279  double * f_DrainEquDrainNodePtr; // a
281 
282  // V_g Row:
283  double * f_GateEquGateNodePtr; // c
286 
287  // V_s Row:
290 
291  // V_d' Row:
296 
297  // V_s' Row:
302 
303  ////////////////////////////////////////////////////////////////////
304  // dQdx Matrix Ptr:
305 
306  // V_d Row:
307  double * q_DrainEquDrainNodePtr; // a
309 
310  // V_g Row:
311  double * q_GateEquGateNodePtr; // c
314 
315  // V_s Row:
318 
319  // V_d' Row:
324 
325  // V_s' Row:
330 #endif
331 
332  ////////////////////////////////////////////////////////////////////
333  // 3f5 State Variables & related quantities:
334  // voltage drops
335  double vgs;
336  double vgd;
337  double vds;
338 
339  // "original" versions of various voltage drop variables:
340  double vgs_orig;
341  double vgd_orig;
342  double vds_orig;
343 
344  // "old" versions of various voltage drop variables:
345  double vgs_old;
346  double vgd_old;
347  double vds_old;
348 
349  int mode; // device mode : 1 = normal, -1 = inverse
350 
351  //gate-source capacitor
352  double capgs; // value
353  double qgs; // charge
354  double cqgs; // trans. G-S current
355  double gcgs; // conductance, d(cqgs)/dVgs
356 
357  // gate-drain capacitor
358  double capgd; // value
359  double qgd; // charge
360  double cqgd; // trans. G-D current
361  double gcgd; // conductance, d(cqgd)/dVgd
362 
363  // current through source and drain resistors
364  double Isource;
365  double Idrain;
366 
367  // local indices
373 
378 };
379 
380 //------------------- Class Model ---------------------------------
381 //-----------------------------------------------------------------------------
382 // Class : Model
383 // Purpose :
384 // Special Notes :
385 // Creator : pmc
386 // Creation Date : 11/16/2003
387 //-----------------------------------------------------------------------------
388 class Model : public DeviceModel
389 {
390  typedef std::vector<Instance *> InstanceVector;
391 
392  friend class ParametricData<Model>;
393  friend class Instance;
394  friend class Traits;friend class Master;
395 
396 public:
397  Model(
398  const Configuration & configuration,
399  const ModelBlock & MB,
400  const FactoryBlock & factory_block);
401  ~Model();
402 
403 private:
404  Model();
405  Model(const Model &);
406  Model &operator=(const Model &);
407 
408 public:
409  virtual void forEachInstance(DeviceInstanceOp &op) const /* override */;
410 
411  virtual std::ostream &printOutInstances(std::ostream &os) const;
412  bool processParams ();
413  bool processInstanceParams ();
414 
415 
416 public:
417  void addInstance(Instance *instance)
418  {
419  instanceContainer.push_back(instance);
420  }
421 
422 private:
423  std::vector<Instance*> instanceContainer;
424 
425 private:
426 
427  //user-specified parameters
428  double AF; // flicker noise exponent, default=1
429  double B; // doping tail parameter, default=1
430  double ALPHA; // saturation voltage paramter, default=2
431  double BETA; // transconductance paramter (A/V^2), default=1.0E-4
432  double CGS; // zero-bias G-S junction capacitance (F), default=5pf
433  double CGD; // zero-bias G-D junction capacitance (F), default=1pf
434  double FC; // coeff. for forward-bias depletion cap., default=0.5
435  double IS; // gate junction saturation current (A), default=1.0E-14
436  double KF; // flicker noise coefficient, default=0
437  double LAMBDA; // channel-length modulation parameter (1/V), default=0
438  double PB; // gate junction potential (V), default=1
439  double RD; // drain ohmic resistance (ohms), default=0
440  double RS; // source ohmic resistance (ohms), default=0
441  double TNOM; // parameter measurement temperature (C), default=27
442  double VTO; // threshhold voltage (V), default=-2.0
443  double fNcoef; // default=0;
444  double fNexp; // default=1;
445 
446 
447  int dtype; // device type: 1 = NJF, -1 = PJF
448 };
449 
450 //-----------------------------------------------------------------------------
451 // Function : Instance:isConverged ()
452 // Purpose : Return whether a MOSFET device has done something that
453 // should be interpreted as invalidating other convergence
454 // tests
455 // In case of mesfet, just do it if the limiter function
456 // pnjlim changed anything.
457 // This actually agrees with how the Check flag
458 // is used in Spice3F5 mesfetload.c
459 // Special Notes :
460 // Scope : public
461 // Creator : Tom Russo, SNL, Component Information and Models
462 // Creation Date : 03/22/05
463 //-----------------------------------------------------------------------------
465 {
466  return (!limitedFlag);
467 }
468 
469 //-----------------------------------------------------------------------------
470 // Class : Master
471 // Purpose :
472 // Special Notes :
473 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
474 // Creation Date : 11/26/08
475 //-----------------------------------------------------------------------------
476 class Master : public DeviceMaster<Traits>
477 {
478  friend class Instance;
479  friend class Model;
480 
481 public:
483  const Configuration & configuration,
484  const FactoryBlock & factory_block,
485  const SolverState & ss1,
486  const DeviceOptions & do1)
487  : DeviceMaster<Traits>(configuration, factory_block, ss1, do1)
488  {}
489 
490  virtual bool updateState (double * solVec, double * staVec, double * stoVec);
491 
492  virtual bool loadDAEVectors (double * solVec, double * fVec, double * qVec, double * bVec, double * storeLeadF, double * storeLeadQ, double * leadF, double * leadQ, double * junctionV);
493  virtual bool loadDAEMatrices (Linear::Matrix & dFdx, Linear::Matrix & dQdx);
494 };
495 
496 void registerDevice();
497 
498 } // namespace MESFET
499 } // namespace Device
500 } // namespace Xyce
501 
502 #endif
Master(const Configuration &configuration, const FactoryBlock &factory_block, const SolverState &ss1, const DeviceOptions &do1)
Definition: N_DEV_MESFET.h:482
static std::vector< std::vector< int > > jacMap2_DC_SC
Definition: N_DEV_MESFET.h:150
static const char * deviceTypeName()
Definition: N_DEV_MESFET.h:65
static std::vector< std::vector< int > > jacStamp_SC
Definition: N_DEV_MESFET.h:142
static std::vector< std::vector< int > > jacStamp_DC
Definition: N_DEV_MESFET.h:141
std::vector< Instance * > instanceContainer
Definition: N_DEV_MESFET.h:423
Pure virtual class to augment a linear system.
virtual bool loadDAEMatrices(Linear::Matrix &dFdx, Linear::Matrix &dQdx)
Populates the device's Jacobian object with these pointers.
void loadNodeSymbols(Util::SymbolTable &symbol_table) const
Populates and returns the store name map.
Definition: N_DEV_MESFET.C:663
static Device * factory(const Configuration &configuration, const FactoryBlock &factory_block)
bool updateTemperature(const double &temp_tmp)
void registerJacLIDs(const std::vector< std::vector< int > > &jacLIDVec)
Definition: N_DEV_MESFET.C:781
static std::vector< int > jacMap_DC
Definition: N_DEV_MESFET.h:146
void registerStateLIDs(const std::vector< int > &staLIDVecRef)
Definition: N_DEV_MESFET.C:687
static std::vector< std::vector< int > > jacStamp
Definition: N_DEV_MESFET.h:143
virtual bool updateState(double *solVec, double *staVec, double *stoVec)
Updates the devices state information.
static std::vector< std::vector< int > > jacMap2
Definition: N_DEV_MESFET.h:153
DeviceMaster instantiates a device as described by the device traits T.
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.
The FactoryBlock contains parameters needed by the device, instance and model creation functions...
static std::vector< std::vector< int > > jacMap2_SC
Definition: N_DEV_MESFET.h:152
static void loadInstanceParameters(ParametricData< Instance > &instance_parameters)
Definition: N_DEV_MESFET.C:70
The Device class is an interface for device implementations.
Definition: N_DEV_Device.h:101
void addInstance(Instance *instance)
Definition: N_DEV_MESFET.h:417
Instance & operator=(const Instance &)
static std::vector< int > jacMap_DC_SC
Definition: N_DEV_MESFET.h:145
Class Configuration contains device configuration data.
void registerStoreLIDs(const std::vector< int > &stoLIDVecRef)
Definition: N_DEV_MESFET.C:733
virtual std::ostream & printOutInstances(std::ostream &os) const
Definition: N_DEV_MESFET.C:276
const std::vector< std::vector< int > > & jacobianStamp() const
Definition: N_DEV_MESFET.C:760
static std::vector< std::vector< int > > jacMap2_DC
Definition: N_DEV_MESFET.h:151
static void loadModelParameters(ParametricData< Model > &model_parameters)
Definition: N_DEV_MESFET.C:82
static std::vector< int > jacMap
Definition: N_DEV_MESFET.h:148
bool processInstanceParams()
processInstanceParams
Definition: N_DEV_MESFET.C:343
Instance(const Configuration &configuration, const InstanceBlock &instance_block, Model &model, const FactoryBlock &factory_block)
Definition: N_DEV_MESFET.C:367
virtual void forEachInstance(DeviceInstanceOp &op) const
Apply a device instance "op" to all instances associated with this model.
Definition: N_DEV_MESFET.C:314
static std::vector< int > jacMap_SC
Definition: N_DEV_MESFET.h:147
ModelBlock represents a .MODEL line from the netlist.
The DeviceTraits template describes the configuration of a device.
Model & operator=(const Model &)
Manages parameter binding for class C.
Definition: N_DEV_Pars.h:214
InstanceBlock represent a device instance line from the netlist.
void registerLIDs(const std::vector< int > &intLIDVecRef, const std::vector< int > &extLIDVecRef)
Definition: N_DEV_MESFET.C:601
static const char * name()
Definition: N_DEV_MESFET.h:64
std::vector< Instance * > InstanceVector
Definition: N_DEV_MESFET.h:390
static std::vector< std::vector< int > > jacStamp_DC_SC
Definition: N_DEV_MESFET.h:140
bool processParams()
processParams
Definition: N_DEV_MESFET.C:329