Xyce  6.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
N_DEV_MOSFET3.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_MOSFET3.h,v $
27 //
28 // Purpose : Level 3 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.118 $
41 //
42 // Revision Date : $Date: 2014/05/22 17:40:29 $
43 //
44 // Current Owner : $Author: erkeite $
45 //-----------------------------------------------------------------------------
46 
47 #ifndef Xyce_N_DEV_MOSFET3_h
48 #define Xyce_N_DEV_MOSFET3_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 #include <N_DEV_MOSFET1.h>
58 
59 namespace Xyce {
60 namespace Device {
61 namespace MOSFET3 {
62 
63 // ---------- Forward Declarations -------
64 class Model;
65 class Instance;
66 
67 struct Traits : public DeviceTraits<Model, Instance, MOSFET1::Traits>
68 {
69  static const char *name() {return "MOSFET level 3";}
70  static const char *deviceTypeName() {return "M level 3";}
71  static int numNodes() {return 4;}
72  static bool modelRequired() {return true;}
73  static bool isLinearDevice() {return false;}
74 
75  static Device *factory(const Configuration &configuration, const FactoryBlock &factory_block);
76  static void loadModelParameters(ParametricData<Model> &model_parameters);
77  static void loadInstanceParameters(ParametricData<Instance> &instance_parameters);
78 };
79 
80 //-----------------------------------------------------------------------------
81 // Class : Instance
82 // Purpose :
83 // Special Notes :
84 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
85 // Creation Date : 3/16/00
86 //-----------------------------------------------------------------------------
87 class Instance : public DeviceInstance
88 {
89  friend class ParametricData<Instance>;
90  friend class Model;
91  friend class Traits;friend class Master;
92 
93 public:
94 
95  Instance(
96  const Configuration & configuration,
97  const InstanceBlock & IB,
98  Model & Miter,
99  const FactoryBlock & factory_block);
100 
101  ~Instance();
102 
103 private:
104  Instance(const Instance &);
105  Instance &operator=(const Instance &);
106 
107 public:
108  void registerLIDs( const std::vector<int> & intLIDVecRef,
109  const std::vector<int> & extLIDVecRef );
110  void registerStateLIDs( const std::vector<int> & staLIDVecRef);
111  void registerStoreLIDs(const std::vector<int> & stoLIDVecRef);
112 
113  std::map<int,std::string> & getIntNameMap ();
114  std::map<int,std::string> & getStoreNameMap ();
115 
116  const std::vector< std::vector<int> > & jacobianStamp() const;
117  void registerJacLIDs( const std::vector< std::vector<int> > & jacLIDVec );
118 
119  bool processParams ();
120 
121  bool updateTemperature(const double & temp_tmp);
122  bool updateIntermediateVars ();
123  bool updatePrimaryState ();
124 
125  // load functions, residual:
126  bool loadDAEQVector ();
127  bool loadDAEFVector ();
128 
129  // load functions, Jacobian:
130  bool loadDAEdQdx ();
131  bool loadDAEdFdx ();
132 
133  void setupPointers();
134 
135  // Additional Public Declarations
136  inline bool isConverged();
137 
138 public:
139  // Getters and setters
141  {
142  return model_;
143  }
144 
145 private:
146  static std::vector< std::vector<int> > jacStamp_DC_SC;
147  static std::vector< std::vector<int> > jacStamp_DC;
148  static std::vector< std::vector<int> > jacStamp_SC;
149  static std::vector< std::vector<int> > jacStamp;
150 
151  static std::vector<int> jacMap_DC_SC;
152  static std::vector<int> jacMap_DC;
153  static std::vector<int> jacMap_SC;
154  static std::vector<int> jacMap;
155 
156  static std::vector< std::vector<int> > jacMap2_DC_SC;
157  static std::vector< std::vector<int> > jacMap2_DC;
158  static std::vector< std::vector<int> > jacMap2_SC;
159  static std::vector< std::vector<int> > jacMap2;
160 
161 
162  Model & model_; //< Owning model
163 
164 protected:
165 private:
166  // instance variables ripped -- bleeding and without anesthetic -- from
167  // 3f5, with obvious modifications to names (remove MOS3 prefix)
168  int states; // index into state table for this device
169  int dNode; // number of the gate node of the mosfet
170  int gNode; // number of the gate node of the mosfet
171  int sNode; // number of the source node of the mosfet
172  int bNode; // number of the bulk node of the mosfet
173  int dNodePrime; // number of the internal drain node of the mosfet
174  int sNodePrime; // number of the internal source node of the mosfet
175 
176 
177  bool OFF; // device initialized OFF (vbs=vgs=vds=0)
178 
179  double l; // the length of the channel region
180  double w; // the width of the channel region
181  double drainArea; // the area of the drain diffusion
182  double sourceArea; // the area of the source diffusion
183  double drainSquares; // the length of the drain in squares
184  double sourceSquares; // the length of the source in squares
187  double sourceConductance; //conductance of source(or 0):set in setup
188  double drainConductance; //conductance of drain(or 0):set in setup
189  double temp; // operating temperature of this instance
190  double numberParallel; // number simulated parallel mosfets
191 
192  double tTransconductance; // temperature corrected transconductance
193  double tSurfMob; // temperature corrected surface mobility
194  double tPhi; // temperature corrected Phi
195  double tVto; // temperature corrected Vto
196  double tSatCur; // temperature corrected saturation Cur.
197  double tSatCurDens; // temperature corrected saturation Cur. density
198  double tCbd; // temperature corrected B-D Capacitance
199  double tCbs; // temperature corrected B-S Capacitance
200  double tCj; // temperature corrected Bulk bottom Capacitance
201  double tCjsw; // temperature corrected Bulk side Capacitance
202  double tBulkPot; // temperature corrected Bulk potential
203  double tDepCap; // temperature adjusted transition point in
204  // the cureve matching Fc * Vj
205  double tVbi; // temperature adjusted Vbi
206 
207  double icVBS; // initial condition B-S voltage
208  double icVDS; // initial condition D-S voltage
209  double icVGS; // initial condition G-S voltage
210  double von;
211  double vdsat;
212  double sourceVcrit; // vcrit for pos. vds
213  double drainVcrit; // vcrit for neg. vds
214  double cd;
215  double cbs;
216  double cbd;
217  double gmbs;
218  double gm;
219  double gds;
220  double gbd;
221  double gbs;
222  double capbd;
223  double capbs;
224  double Cbd;
225  double Cbdsw;
226  double Cbs;
227  double Cbssw;
228  double f2d;
229  double f3d;
230  double f4d;
231  double f2s;
232  double f3s;
233  double f4s;
234  int mode; // device mode : 1 = normal, -1 = inverse
235  double mode_low;
236  double mode_high;
237 
238  bool limitedFlag; // for convergence testing.
239 
240  bool IC_GIVEN;
241 
242  //end of 3f5 outtakes
243 
244  ////////////////////////////////////////////////////////////////////
245  // these are intermediate variables added to the instance class instead
246  // of leaving them to be calculated repeatedly in the load function
247 
248  // some caluclated quantities
250  double DrainSatCur;
251  double SourceSatCur;
255  double OxideCap;
256 
257  // Solution variables and intermediate quantities
258  // drain,source,gate, bulk, drainprime and sourceprime voltages
259  double Vd;
260  double Vs;
261  double Vg;
262  double Vb;
263  double Vdp;
264  double Vsp;
265  // voltage drops between pairs of nodes
266  double Vddp; // drain-drain'
267  double Vssp; // source-source'
268  double Vbsp; // bulk-source'
269  double Vbdp; // bulk-drain'
270  double Vgsp; // gate-source'
271  double Vgdp; // gate-drain'
272  double Vgb; //gate-bulk
273  double Vdpsp; //drop across channel
274 
275  // the gate-drain voltage drop isn't actually a state variable, but it
276  // is calculated at the same time and in the same manner as the state
277  // vars. So here we go, sticking it in the instance class.
278  double vgd;
279 
280  // Some stuff from mos3temp that were local vars but used elsewhere
281  double vt; // set in updateTemperature to CONSTKoverQ*temp
282 
283 
284  // the variables capgs, capgd and capgb are the raw output of
285  // qmeyer. They get massaged into total capacitances in
286  // updateIntermediateVars, and get used in updatePrimaryState to get
287  // charges on the capacitors.
288 
289  double Capgs; // total gate-source capacitance
290  double Capgd; // total gate-drain capacitance
291  double Capgb; // total gate-bulk capacitance
292 
293  // current through source and drain resistors
294  double Isource;
295  double Idrain;
296 
297  double cdrain; // the channel current shouldn't be a local variable in */
298  // updateIntermediateVars!
299 
300  // these are calculated in loadRHS and used in the jacobian load
301  double Gm,Gmbs; // we do this so we don't really need the xnrm/xrev vars
302  double revsum; // described in comments at the end of
303  double nrmsum; // updateIntermediateVars (uIVB in remaining comments)
304  double cdreq;
305 
306  // end of intermediate variables that aren't state variables
307  ////////////////////////////
308  //
309  // vector indices
310  int li_Drain;
314  int li_Gate;
315  int li_Bulk;
316 
317  ////////////////////////////////////////////////////////////////////
318  // The following verbatim from Level=1, which has the same jacobian
319  // structure
320  ////////////////////////////////////////////////////////////////////
321  // Jacobian matrix indices:
322  // This is a 6x6 matrix block, of which 22 entries are nonzero:
323  //
324  // ---------------------------------------------------------
325  // | #NZ | | |
326  // | entries | | V_d V_g V_s V_b V_d' V_s' |
327  // ---------------------------------------------------------
328  // | 2 | KCL_d | a b |
329  // | 4 | KCL_g | c d e f |
330  // | 2 | KCL_s | g h |
331  // | 4 | KCL_b | i j k l |
332  // | 5 | KCL_d'| m n o p q |
333  // | 5 | KCL_s'| r s t u v |
334  // ---------------------------------------------------------
335  // 22 total
336 
337  ////////////////////////////////////////////////////////////////////
338  // Offset variables corresponding to the above declared indices.
339 
340  // Jacobian Matrix Offset:
341 
342  // V_d Row:
345 
346  // V_g Row:
351 
352  // V_s Row:
355 
356  // V_b Row:
361 
362  // V_d' Row:
368 
369  // V_s' Row:
375 
376  // Jacobian Matrix Pointers:
377 
378 #ifndef Xyce_NONPOINTER_MATRIX_LOAD
379  // F-vector pointers:
380  // V_d Row:
381  double * f_DrainEquDrainNodePtr; // a
383 
384  // V_g Row:
385  double * f_GateEquGateNodePtr; // c
386  double * f_GateEquBulkNodePtr; // d
389 
390  // V_s Row:
393 
394  // V_b Row:
395  double * f_BulkEquGateNodePtr; // i
396  double * f_BulkEquBulkNodePtr; // j
399 
400  // V_d' Row:
406 
407  // V_s' Row:
413 
414  // Q-vector pointers:
415  // V_d Row:
416  double * q_DrainEquDrainNodePtr; // a
418 
419  // V_g Row:
420  double * q_GateEquGateNodePtr; // c
421  double * q_GateEquBulkNodePtr; // d
424 
425  // V_s Row:
428 
429  // V_b Row:
430  double * q_BulkEquGateNodePtr; // i
431  double * q_BulkEquBulkNodePtr; // j
434 
435  // V_d' Row:
441 
442  // V_s' Row:
448 #endif
449 
450  ////////////////////////////////////////////////////////////////////
451  // 3f5 State Variables & related quantities:
452  // voltage drops
453  double vbd;
454  double vbs;
455  double vgs;
456  double vds;
457 
458  // "original" versions of various voltage drop variables:
459  double vgs_orig;
460  double vds_orig;
461  double vbs_orig;
462  double vbd_orig;
463  double vgd_orig;
464 
465  // "old" versions of various voltage drop variables:
466  double vgs_old;
467  double vds_old;
468  double vbs_old;
469  double vbd_old;
470  double vgd_old;
471 
472 
473  // meyer capacitances
474  //gate-source capacitor
475  double capgs; //value
476  double qgs; // charge
477  // gate-drain capacitor
478  double capgd; //value
479  double qgd; //charge
480  //gate-bulk capacitor
481  double capgb; //value
482  double qgb; //charge
483 
484  // diode capacitances
485  double qbd; // bulk-drain capacitor charge
486  double qbs; // bulk-source capacitor charge
487 
488  // indices into the state vector.
494 
495  // place in store vec for lead currents.
500 
504 
508 
511 
512  int blockHomotopyID; // For homotopy
513  double randomPerturb; // For homotopy
514 };
515 
516 
517 //-----------------------------------------------------------------------------
518 // Class : Model
519 // Purpose :
520 // Special Notes :
521 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
522 // Creation Date : 3/16/00
523 //-----------------------------------------------------------------------------
524 class Model : public DeviceModel
525 {
526  typedef std::vector<Instance *> InstanceVector;
527 
528  friend class ParametricData<Model>;
529  friend class Instance;
530  friend class Traits;friend class Master;
531 
532 public:
533  Model(
534  const Configuration & configuration,
535  const ModelBlock & MB,
536  const FactoryBlock & factory_block);
537  ~Model();
538 
539 private:
540  Model();
541  Model(const Model &);
542  Model &operator=(const Model &);
543 
544 public:
545  virtual void forEachInstance(DeviceInstanceOp &op) const /* override */;
546 
547  virtual std::ostream &printOutInstances(std::ostream &os) const;
548 
549  bool processParams ();
550  bool processInstanceParams ();
551 
552 
553 public:
554  void addInstance(Instance *instance)
555  {
556  instanceContainer.push_back(instance);
557  }
558 
559 private:
560  std::vector<Instance*> instanceContainer;
561 
562 private:
563 
564  int dtype; // device type : 1 = nmos, -1 = pmos
565  double model_l; // the length of the channel region
566  double model_w; // the width of the channel region
567  double tnom; // temperature at which parameters measured
568  double latDiff;
569  double jctSatCurDensity; // input - use tSatCurDens
570  double jctSatCur; // input - use tSatCur instead
574  double transconductance; // input - use tTransconductance
579  double vt0; // input - use tVto
580  double capBD; // input - use tCbs
581  double capBS; // input - use tCbd
582  double bulkCapFactor; // input - use tCj
583  double sideWallCapFactor; // input - use tCjsw
584  double bulkJctPotential; // input - use tBulkPot
588  double phi; // input - use tPhi
589  double gamma;
591  int gateType;
594  double surfaceMobility; // input - use tSurfMob
596  double eta;
598  double coeffDepLayWidth; // xd
599  double narrowFactor; // delta
600  double delta; // input delta
601  double fastSurfaceStateDensity; // nfs
602  double theta; // theta
603  double maxDriftVel; // vmax
604  double alpha; // alpha
605  double kappa; // kappa
606  double fNcoef;
607  double fNexp;
608 
609  bool capBDGiven ;
610  bool capBSGiven ;
613 
614  // These variables were used as temporaries in mos3temp, but since
615  // the calculations in mos3temp are split between the model block
616  // constructor and the function updateTemperature, we need them to be
617  // model variables.
618 
619  double fact1;
620  double vtnom;
621  double egfet1;
622  double pbfact1;
623 };
624 
625 //-----------------------------------------------------------------------------
626 // Function : Instance:isConverged ()
627 // Purpose : Return whether a MOSFET device has done something that
628 // should be interpreted as invalidating other convergence
629 // tests
630 // In case of mos3, just do it if the limiter function
631 // pnjlim changed anything.
632 // This actually agrees with how the Check flag
633 // is used in Spice3F5 mos3load.c
634 // Special Notes :
635 // Scope : public
636 // Creator : Tom Russo, SNL, Component Information and Models
637 // Creation Date : 03/22/05
638 //-----------------------------------------------------------------------------
640 {
641  return (!limitedFlag);
642 }
643 
644 //-----------------------------------------------------------------------------
645 // Class : Master
646 // Purpose :
647 // Special Notes :
648 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
649 // Creation Date : 11/26/08
650 //-----------------------------------------------------------------------------
651 class Master : public DeviceMaster<Traits>
652 {
653 public:
655  const Configuration & configuration,
656  const FactoryBlock & factory_block,
657  const SolverState & ss1,
658  const DeviceOptions & do1)
659  : DeviceMaster<Traits>(configuration, factory_block, ss1, do1)
660  {}
661 
662  virtual bool updateState (double * solVec, double * staVec, double * stoVec);
663 
664  // new DAE stuff:
665  // new DAE load functions, residual:
666  virtual bool loadDAEVectors (double * solVec, double * fVec, double * qVec, double * bVec, double * storeLeadF, double * storeLeadQ);
667 
668  // new DAE load functions, Jacobian:
669  virtual bool loadDAEMatrices (N_LAS_Matrix & dFdx, N_LAS_Matrix & dQdx);
670 
671  friend class Instance;
672  friend class Model;
673 };
674 
675 void registerDevice();
676 
677 } // namespace MOSFET3
678 } // namespace Device
679 } // namespace Xyce
680 
684 
685 #endif