Xyce  6.1
N_DEV_MOSFET1.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_MOSFET1.h,v $
27 //
28 // Purpose : Level 1 Metal-oxide-semiconductor field effect transistor
29 // (MOSFET) classes.
30 //
31 // Special Notes :
32 //
33 // Creator : Eric R. Keiter, SNL, Parallel Computational Sciences
34 //
35 // Creation Date : 02/28/00
36 //
37 // Revision Information:
38 // ---------------------
39 //
40 // Revision Number: $Revision: 1.149 $
41 //
42 // Revision Date : $Date: 2015/04/08 19:18:24 $
43 //
44 // Current Owner : $Author: tvrusso $
45 //-----------------------------------------------------------------------------
46 
47 #ifndef Xyce_N_DEV_MOSFET1_h
48 #define Xyce_N_DEV_MOSFET1_h
49 
50 // ---------- Xyce Includes ----------
51 #include <N_DEV_Configuration.h>
52 #include <N_DEV_DeviceMaster.h>
53 #include <N_DEV_DeviceInstance.h>
54 #include <N_DEV_DeviceModel.h>
55 #include <N_DEV_DeviceBlock.h>
56 
57 namespace Xyce {
58 namespace Device {
59 namespace MOSFET1 {
60 
61 class Model;
62 class Instance;
63 
64 struct Traits : public DeviceTraits<Model, Instance>
65 {
66  static const char *name() {return "MOSFET level 1";}
67  static const char *deviceTypeName() {return "M level 1";}
68  static int numNodes() {return 4;}
69  static bool modelRequired() {return true;}
70  static bool isLinearDevice() {return false;}
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 : Instance
79 // Purpose :
80 // Special Notes :
81 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
82 // Creation Date : 3/16/00
83 //-----------------------------------------------------------------------------
84 class Instance : public DeviceInstance
85 {
86  friend class ParametricData<Instance>;
87  friend class Model;
88  friend class Traits;friend class Master;
89 
90 public:
91 
92  Instance(
93  const Configuration & configuration,
94  const InstanceBlock & IB,
95  Model & Miter,
96  const FactoryBlock & factory_block);
97 
98  ~Instance();
99 
100 private:
101  Instance(const Instance &);
102  Instance &operator=(const Instance &);
103 
104 public:
105  void registerLIDs( const std::vector<int> & intLIDVecRef,
106  const std::vector<int> & extLIDVecRef );
107  void registerStateLIDs(const std::vector<int> & staLIDVecRef);
108  void registerStoreLIDs(const std::vector<int> & stoLIDVecRef);
109 
110  void loadNodeSymbols(Util::SymbolTable &symbol_table) const; // override
111 
112  const std::vector< std::vector<int> > & jacobianStamp() const;
113  void registerJacLIDs( const std::vector< std::vector<int> > & jacLIDVec );
114 
115  bool processParams ();
116 
117  bool updateTemperature(const double & temp_tmp);
118  bool updateIntermediateVars ();
119  bool updatePrimaryState ();
120 
121  int getNumNoiseSources () const;
122  void setupNoiseSources (Xyce::Analysis::NoiseData & noiseData);
123  void getNoiseSources (Xyce::Analysis::NoiseData & noiseData);
124 
125  void loadErrorWeightMask ();
126 
127  // load functions, residual:
128  bool loadDAEQVector ();
129  bool loadDAEFVector ();
130 
131  // load functions, Jacobian:
132  bool loadDAEdQdx ();
133  bool loadDAEdFdx ();
134 
135  void setupPointers();
136 
137  // Additional Public Declarations
138 
139  inline bool isConverged();
140 
141 public:
142  // Getters and setters
144  {
145  return model_;
146  }
147 
148 private:
149  static std::vector< std::vector<int> > jacStamp_DC_SC;
150  static std::vector< std::vector<int> > jacStamp_DC;
151  static std::vector< std::vector<int> > jacStamp_SC;
152  static std::vector< std::vector<int> > jacStamp;
153 
154  static std::vector<int> jacMap_DC_SC;
155  static std::vector<int> jacMap_DC;
156  static std::vector<int> jacMap_SC;
157  static std::vector<int> jacMap;
158 
159  static std::vector< std::vector<int> > jacMap2_DC_SC;
160  static std::vector< std::vector<int> > jacMap2_DC;
161  static std::vector< std::vector<int> > jacMap2_SC;
162  static std::vector< std::vector<int> > jacMap2;
163 
164 
165  Model & model_; //< Owning model
166 
167  // instance variables ripped -- bleeding and without anesthetic -- from
168  // 3f5, with obvious modifications to names (remove MOS1 prefix)
169  int states; // index into state table for this device
170  int dNode; // number of the gate node of the mosfet
171  int gNode; // number of the gate node of the mosfet
172  int sNode; // number of the source node of the mosfet
173  int bNode; // number of the bulk node of the mosfet
174  int dNodePrime; // number of the internal drain node of the mosfet
175  int sNodePrime; // number of the internal source node of the mosfet
176 
177 
178  bool OFF; // device initialized OFF (vbs=vgs=vds=0)
179 
180  double l; // the length of the channel region
181  double w; // the width of the channel region
182  double drainArea; // the area of the drain diffusion
183  double sourceArea; // the area of the source diffusion
184  double drainSquares; // the length of the drain in squares
185  double sourceSquares; // the length of the source in squares
188  double sourceConductance; //conductance of source(or 0):set in setup
189  double drainConductance; //conductance of drain(or 0):set in setup
190  double temp; // operating temperature of this instance
191  double numberParallel; // number simulated parallel mosfets
192 
193  double tTransconductance; // temperature corrected transconductance
194  double tSurfMob; // temperature corrected surface mobility
195  double tPhi; // temperature corrected Phi
196  double tVto; // temperature corrected Vto
197  double tSatCur; // temperature corrected saturation Cur.
198  double tSatCurDens; // temperature corrected saturation Cur. density
199  double tCbd; // temperature corrected B-D Capacitance
200  double tCbs; // temperature corrected B-S Capacitance
201  double tCj; // temperature corrected Bulk bottom Capacitance
202  double tCjsw; // temperature corrected Bulk side Capacitance
203  double tBulkPot; // temperature corrected Bulk potential
204  double tDepCap; // temperature adjusted transition point in
205  // the cureve matching Fc * Vj
206  double tVbi; // temperature adjusted Vbi
207 
208  double icVBS; // initial condition B-S voltage
209  double icVDS; // initial condition D-S voltage
210  double icVGS; // initial condition G-S voltage
211  double von;
212  double vdsat;
213  double sourceVcrit; // vcrit for pos. vds
214  double drainVcrit; // vcrit for neg. vds
215  double cd;
216  double cbs;
217  double cbd;
218  double gmbs;
219  double gm;
220  double gds;
221  double gbd;
222  double gbs;
223  double capbd;
224  double capbs;
225  double Cbd;
226  double Cbdsw;
227  double Cbs;
228  double Cbssw;
229  double f2d;
230  double f3d;
231  double f4d;
232  double f2s;
233  double f3s;
234  double f4s;
235  int mode; // device mode : 1 = normal, -1 = inverse
236  double mode_low;
237  double mode_high;
238 
239  bool limitedFlag; // for convergence testing.
240 
241  bool IC_GIVEN;
242 
243  //end of 3f5 outtakes
244 
245  ////////////////////////////////////////////////////////////////////
246  // these are intermediate variables added to the instance class instead
247  // of leaving them to be calculated repeatedly in the load function
248 
249  // some caluclated quantities
251  double DrainSatCur;
252  double SourceSatCur;
256  double OxideCap;
257 
258  // Solution variables and intermediate quantities
259  // drain,source,gate, bulk, drainprime and sourceprime voltages
260  double Vd;
261  double Vs;
262  double Vg;
263  double Vb;
264  double Vdp;
265  double Vsp;
266 
267  // KRS, 2/08/08: adding variables to represent the time derivatives of
268  // the above quantities (for MPDE compatibility). The "dot" means time
269  // derivative
270  double Vddot;
271  double Vsdot;
272  double Vgdot;
273  double Vbdot;
274  double Vdpdot;
275  double Vspdot;
276 
277 
278  // voltage drops between pairs of nodes
279  double Vddp; // drain-drain'
280  double Vssp; // source-source'
281  double Vbsp; // bulk-source'
282  double Vbdp; // bulk-drain'
283  double Vgsp; // gate-source'
284  double Vgdp; // gate-drain'
285  double Vgb; //gate-bulk
286  double Vdpsp; //drop across channel
287 
288  // the gate-drain voltage drop isn't actually a state variable, but it
289  // is calculated at the same time and in the same manner as the state
290  // vars. So here we go, sticking it in the instance class.
291  double vgd;
292 
293  // Some stuff from mos1temp that were local vars but used elsewhere
294  double vt; // set in updateTemperature to CONSTKoverQ*temp
295 
296 
297  // the variables capgs, capgd and capgb are the raw output of
298  // qmeyer. They get massaged into total capacitances in
299  // updateIntermediateVars, and get used in updatePrimaryState to get
300  // charges on the capacitors.
301 
302  double Capgs; // total gate-source capacitance
303  double Capgd; // total gate-drain capacitance
304  double Capgb; // total gate-bulk capacitance
305 
306  // current through source and drain resistors
307  double Isource;
308  double Idrain;
309 
310  double cdrain; // the channel current shouldn't be a local variable in */
311  // updateIntermediateVars!
312 
313  // these are calculated in loadRHS and used in the jacobian load
314  double Gm,Gmbs; // we do this so we don't really need the xnrm/xrev vars
315  double revsum; // described in comments at the end of
316  double nrmsum; // updateIntermediateVars (uIVB in remaining comments)
317  double cdreq;
318 
319  // end of intermediate variables that aren't state variables
320  ////////////////////////////
321  //
322  // vector indices
323  int li_Drain;
327  int li_Gate;
328  int li_Bulk;
329 
330  //KRS, 2/8/08: adding local indices for derivatives, too.
337 
338  ////////////////////////////////////////////////////////////////////
339  // The following verbatim from Level=1, which has the same jacobian
340  // structure
341  ////////////////////////////////////////////////////////////////////
342  // Jacobian matrix indices:
343  // This is a 6x6 matrix block, of which 22 entries are nonzero:
344  //
345  // ---------------------------------------------------------
346  // | #NZ | | |
347  // | entries | | V_d V_g V_s V_b V_d' V_s' |
348  // ---------------------------------------------------------
349  // | 2 | KCL_d | a b |
350  // | 4 | KCL_g | c d e f |
351  // | 2 | KCL_s | g h |
352  // | 4 | KCL_b | i j k l |
353  // | 5 | KCL_d'| m n o p q |
354  // | 5 | KCL_s'| r s t u v |
355  // ---------------------------------------------------------
356  // 22 total
357 
358  ////////////////////////////////////////////////////////////////////
359  // Offset variables corresponding to the above declared indices.
360 
361  //KRS, 3/6/08: Note that the above matrix stamp is NOT the matrix stamp
362  //for the new meyer stuff! The new Matrix stamp is 12x12 and is a little
363  //too large to put a diagram in here. I'll create some sort of memo/SAND
364  //report with the matrix structure...
365 
366  // Jacobian Matrix Offset:
367 
368  // V_d Row:
371 
372  // V_g Row:
377  // for new DAE/Meyer stuff:
382 
383  // V_s Row:
386 
387  // V_b Row:
392  // for new Meyer/DAE stuff
397 
398  // V_d' Row:
404  // for new Meyer/DAE stuff
408 
409  // V_s' Row:
415  // for new Meyer/DAE stuff
419 
420  //the remainder of these are all for new Meyer/DAE:
433 
434 #ifndef Xyce_NONPOINTER_MATRIX_LOAD
435  // F-Matrix Pointers:
436  // V_d Row:
437  double * f_DrainEquDrainNodePtr; // a
439 
440  // V_g Row:
441  double * f_GateEquGateNodePtr; // c
442  double * f_GateEquBulkNodePtr; // d
445  // for new DAE/Meyer stuff:
450 
451  // V_s Row:
454 
455  // V_b Row:
456  double * f_BulkEquGateNodePtr; // i
457  double * f_BulkEquBulkNodePtr; // j
460  // for new Meyer/DAE stuff
465 
466  // V_d' Row:
472  // for new Meyer/DAE stuff
476 
477  // V_s' Row:
483  // for new Meyer/DAE stuff
487 
488  //the remainder of these are all for new Meyer/DAE:
501 
502  // Q-Matrix Pointers:
503  // V_d Row:
504  double * q_DrainEquDrainNodePtr; // a
506 
507  // V_g Row:
508  double * q_GateEquGateNodePtr; // c
509  double * q_GateEquBulkNodePtr; // d
512  // for new DAE/Meyer stuff:
517 
518  // V_s Row:
521 
522  // V_b Row:
523  double * q_BulkEquGateNodePtr; // i
524  double * q_BulkEquBulkNodePtr; // j
527  // for new Meyer/DAE stuff
532 
533  // V_d' Row:
539  // for new Meyer/DAE stuff
543 
544  // V_s' Row:
550  // for new Meyer/DAE stuff
554 
555  //the remainder of these are all for new Meyer/DAE:
568 #endif
569 
570  ////////////////////////////////////////////////////////////////////
571  // 3f5 State Variables & related quantities:
572  // voltage drops
573  double vbd;
574  double vbs;
575  double vgs;
576  double vds;
577 
578  // "original" versions of various voltage drop variables:
579  double vgs_orig;
580  double vds_orig;
581  double vbs_orig;
582  double vbd_orig;
583  double vgd_orig;
584 
585  // "old" versions of various voltage drop variables:
586  double vgs_old;
587  double vds_old;
588  double vbs_old;
589  double vbd_old;
590  double vgd_old;
591 
592  // int newtonIter; // the Device class now has this, manager sets it.
593 
594  // meyer capacitances---KRS, 2/08/08: adding some variables to compute
595  // partial derivatives of these capacitances with respect to various
596  // voltage.
597  //gate-source capacitor
598  double capgs; //value
599  double dcapgsdvgs; //partial deriv. of capgs with respect to vgs
600  double dcapgsdvgb; //partial deriv. of capgs with respect to vgb
601  double dcapgsdvgd; //partial deriv. of capgs with respect to vgd
602  double qgs; // charge
603  // gate-drain capacitor
604  double capgd; //value
605  double dcapgddvgs; //partial deriv. of capgd with respect to vgs
606  double dcapgddvgb; //partial deriv. of capgd with respect to vgb
607  double dcapgddvgd; //partial deriv. of capgd with respect to vgd
608  double qgd; //charge
609  //gate-bulk capacitor
610  double capgb; //value
611  double dcapgbdvgs; //partial deriv. of capgb with respect to vgs
612  double dcapgbdvgb; //partial deriv. of capgb with respect to vgb
613  double dcapgbdvgd; //partial deriv. of capgb with respect to vgd
614  double qgb; //charge
615 
616  // diode capacitances
617  double qbd; // bulk-drain capacitor charge
618  double cqbd;// bulk-drain capacitor current
619 
620  double qbs; // bulk-source capacitor charge
621 
622  // indices into the state/store vector(s).
628 
629  // place in store vec for lead currents.
634 
638 
642 
645 
646  int blockHomotopyID; // For homotopy
647  double randomPerturb; // For homotopy
648 };
649 
650 
651 //-----------------------------------------------------------------------------
652 // Class : Model
653 // Purpose :
654 // Special Notes :
655 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
656 // Creation Date : 3/16/00
657 //-----------------------------------------------------------------------------
658 class Model : public DeviceModel
659 {
660  typedef std::vector<Instance *> InstanceVector;
661 
662  friend class ParametricData<Model>;
663  friend class Instance;
664  friend class Traits;friend class Master;
665 
666 public:
667  Model(
668  const Configuration & configuration,
669  const ModelBlock & MB,
670  const FactoryBlock & factory_block);
671  ~Model();
672 
673 private:
674  Model();
675  Model(const Model &);
676  Model &operator=(const Model &);
677 
678 public:
679  virtual void forEachInstance(DeviceInstanceOp &op) const /* override */;
680 
681  virtual std::ostream &printOutInstances(std::ostream &os) const;
682 
683  bool processParams ();
684  bool processInstanceParams ();
685 
686 
687 public:
688  void addInstance(Instance *instance)
689  {
690  instanceContainer.push_back(instance);
691  }
692 
693 private:
694  std::vector<Instance*> instanceContainer;
695 
696 private:
697 
698  int dtype; // device type : 1 = nmos, -1 = pmos
699  double model_l; // the length of the channel region
700  double model_w; // the width of the channel region
701  double tnom; // temperature at which parameters measured
702  double latDiff;
703  double jctSatCurDensity; // input - use tSatCurDens
704  double jctSatCur; // input - use tSatCur instead
708  double transconductance; // input - use tTransconductance
713  double vt0; // input - use tVto
714  double capBD; // input - use tCbs
715  double capBS; // input - use tCbd
716  double bulkCapFactor; // input - use tCj
717  double sideWallCapFactor; // input - use tCjsw
718  double bulkJctPotential; // input - use tBulkPot
722  double phi; // input - use tPhi
723  double gamma;
724  double lambda;
726  int gateType;
729  double surfaceMobility; // input - use tSurfMob
731  double fNcoef;
732  double fNexp;
733 
734  bool capBDGiven ;
735  bool capBSGiven ;
738 
739  // These variables were used as temporaries in mos1temp, but since
740  // the calculations in mos1temp are split between the model block
741  // constructor and the function updateTemperature, we need them to be
742  // model variables.
743 
744  double fact1;
745  double vtnom;
746  double egfet1;
747  double pbfact1;
748 };
749 
750 //-----------------------------------------------------------------------------
751 // Function : Instance:isConverged ()
752 // Purpose : Return whether a MOSFET device has done something that
753 // should be interpreted as invalidating other convergence
754 // tests
755 // In case of mos1, just do it if the limiter function
756 // pnjlim changed anything.
757 // This actually agrees with how the Check flag
758 // is used in Spice3F5 mos1load.c
759 // Special Notes :
760 // Scope : public
761 // Creator : Tom Russo, SNL, Component Information and Models
762 // Creation Date : 03/22/05
763 //-----------------------------------------------------------------------------
765 {
766  return (!limitedFlag);
767 }
768 
769 //-----------------------------------------------------------------------------
770 // Class : Master
771 // Purpose :
772 // Special Notes :
773 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
774 // Creation Date : 11/26/08
775 //-----------------------------------------------------------------------------
776 class Master : public DeviceMaster<Traits>
777 {
778 public:
780  const Configuration & configuration,
781  const FactoryBlock & factory_block,
782  const SolverState & ss1,
783  const DeviceOptions & do1)
784  : DeviceMaster<Traits>(configuration, factory_block, ss1, do1)
785  {}
786 
787  virtual bool updateState (double * solVec, double * staVec, double * stoVec);
788 
789  // new DAE stuff:
790  // new DAE load functions, residual:
791  virtual bool loadDAEVectors (double * solVec, double * fVec, double * qVec, double * bVec, double * storeLeadF, double * storeLeadQ, double * leadF, double * leadQ, double * junctionV);
792 
793  // new DAE load functions, Jacobian:
794  virtual bool loadDAEMatrices (Linear::Matrix & dFdx, Linear::Matrix & dQdx);
795 
796  friend class Instance;
797  friend class Traits;
798  friend class Model;
799 };
800 
801 void registerDevice();
802 
803 } // namespace MOSFET1
804 } // namespace Device
805 } // namespace Xyce
806 
807 #endif
static std::vector< int > jacMap_SC
static void loadModelParameters(ParametricData< Model > &model_parameters)
static std::vector< std::vector< int > > jacStamp_DC_SC
const std::vector< std::vector< int > > & jacobianStamp() const
void setupNoiseSources(Xyce::Analysis::NoiseData &noiseData)
virtual std::ostream & printOutInstances(std::ostream &os) const
bool updateTemperature(const double &temp_tmp)
Pure virtual class to augment a linear system.
static std::vector< std::vector< int > > jacMap2_SC
virtual void forEachInstance(DeviceInstanceOp &op) const
Apply a device instance "op" to all instances associated with this model.
Instance & operator=(const Instance &)
bool processInstanceParams()
processInstanceParams
static std::vector< std::vector< int > > jacStamp_SC
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.
virtual bool loadDAEMatrices(Linear::Matrix &dFdx, Linear::Matrix &dQdx)
Populates the device's Jacobian object with these pointers.
Master(const Configuration &configuration, const FactoryBlock &factory_block, const SolverState &ss1, const DeviceOptions &do1)
bool processParams()
processParams
void registerJacLIDs(const std::vector< std::vector< int > > &jacLIDVec)
static std::vector< std::vector< int > > jacMap2_DC_SC
DeviceMaster instantiates a device as described by the device traits T.
std::vector< Instance * > instanceContainer
The FactoryBlock contains parameters needed by the device, instance and model creation functions...
void getNoiseSources(Xyce::Analysis::NoiseData &noiseData)
static void loadInstanceParameters(ParametricData< Instance > &instance_parameters)
Definition: N_DEV_MOSFET1.C:67
Instance(const Configuration &configuration, const InstanceBlock &IB, Model &Miter, const FactoryBlock &factory_block)
void addInstance(Instance *instance)
static std::vector< int > jacMap
The Device class is an interface for device implementations.
Definition: N_DEV_Device.h:101
static const char * deviceTypeName()
Definition: N_DEV_MOSFET1.h:67
void registerLIDs(const std::vector< int > &intLIDVecRef, const std::vector< int > &extLIDVecRef)
Class Configuration contains device configuration data.
std::vector< Instance * > InstanceVector
static std::vector< std::vector< int > > jacStamp
static std::vector< int > jacMap_DC_SC
void registerStoreLIDs(const std::vector< int > &stoLIDVecRef)
static std::vector< std::vector< int > > jacMap2_DC
virtual bool updateState(double *solVec, double *staVec, double *stoVec)
Updates the devices state information.
double * q_SourcePrimedotEquVSourcePrimedotNodePtr
Model & operator=(const Model &)
static std::vector< int > jacMap_DC
static const char * name()
Definition: N_DEV_MOSFET1.h:66
static Device * factory(const Configuration &configuration, const FactoryBlock &factory_block)
void registerStateLIDs(const std::vector< int > &staLIDVecRef)
ModelBlock represents a .MODEL line from the netlist.
The DeviceTraits template describes the configuration of a device.
Manages parameter binding for class C.
Definition: N_DEV_Pars.h:214
InstanceBlock represent a device instance line from the netlist.
double * f_SourcePrimedotEquVSourcePrimedotNodePtr
static std::vector< std::vector< int > > jacMap2
static std::vector< std::vector< int > > jacStamp_DC
void loadNodeSymbols(Util::SymbolTable &symbol_table) const
Populates and returns the store name map.