Xyce  6.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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-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_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.141 $
41 //
42 // Revision Date : $Date: 2014/05/22 17:40:28 $
43 //
44 // Current Owner : $Author: erkeite $
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  std::map<int,std::string> & getIntNameMap ();
111  std::map<int,std::string> & getStoreNameMap ();
112 
113  const std::vector< std::vector<int> > & jacobianStamp() const;
114  void registerJacLIDs( const std::vector< std::vector<int> > & jacLIDVec );
115 
116  bool processParams ();
117 
118  bool updateTemperature(const double & temp_tmp);
119  bool updateIntermediateVars ();
120  bool updatePrimaryState ();
121 
122  bool loadDeviceMask ();
123 
124  // load functions, residual:
125  bool loadDAEQVector ();
126  bool loadDAEFVector ();
127 
128  // load functions, Jacobian:
129  bool loadDAEdQdx ();
130  bool loadDAEdFdx ();
131 
132  void setupPointers();
133 
134  // Additional Public Declarations
135 
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  // instance variables ripped -- bleeding and without anesthetic -- from
165  // 3f5, with obvious modifications to names (remove MOS1 prefix)
166  int states; // index into state table for this device
167  int dNode; // number of the gate node of the mosfet
168  int gNode; // number of the gate node of the mosfet
169  int sNode; // number of the source node of the mosfet
170  int bNode; // number of the bulk node of the mosfet
171  int dNodePrime; // number of the internal drain node of the mosfet
172  int sNodePrime; // number of the internal source node of the mosfet
173 
174 
175  bool OFF; // device initialized OFF (vbs=vgs=vds=0)
176 
177  double l; // the length of the channel region
178  double w; // the width of the channel region
179  double drainArea; // the area of the drain diffusion
180  double sourceArea; // the area of the source diffusion
181  double drainSquares; // the length of the drain in squares
182  double sourceSquares; // the length of the source in squares
185  double sourceConductance; //conductance of source(or 0):set in setup
186  double drainConductance; //conductance of drain(or 0):set in setup
187  double temp; // operating temperature of this instance
188  double numberParallel; // number simulated parallel mosfets
189 
190  double tTransconductance; // temperature corrected transconductance
191  double tSurfMob; // temperature corrected surface mobility
192  double tPhi; // temperature corrected Phi
193  double tVto; // temperature corrected Vto
194  double tSatCur; // temperature corrected saturation Cur.
195  double tSatCurDens; // temperature corrected saturation Cur. density
196  double tCbd; // temperature corrected B-D Capacitance
197  double tCbs; // temperature corrected B-S Capacitance
198  double tCj; // temperature corrected Bulk bottom Capacitance
199  double tCjsw; // temperature corrected Bulk side Capacitance
200  double tBulkPot; // temperature corrected Bulk potential
201  double tDepCap; // temperature adjusted transition point in
202  // the cureve matching Fc * Vj
203  double tVbi; // temperature adjusted Vbi
204 
205  double icVBS; // initial condition B-S voltage
206  double icVDS; // initial condition D-S voltage
207  double icVGS; // initial condition G-S voltage
208  double von;
209  double vdsat;
210  double sourceVcrit; // vcrit for pos. vds
211  double drainVcrit; // vcrit for neg. vds
212  double cd;
213  double cbs;
214  double cbd;
215  double gmbs;
216  double gm;
217  double gds;
218  double gbd;
219  double gbs;
220  double capbd;
221  double capbs;
222  double Cbd;
223  double Cbdsw;
224  double Cbs;
225  double Cbssw;
226  double f2d;
227  double f3d;
228  double f4d;
229  double f2s;
230  double f3s;
231  double f4s;
232  int mode; // device mode : 1 = normal, -1 = inverse
233  double mode_low;
234  double mode_high;
235 
236  bool limitedFlag; // for convergence testing.
237 
238  bool IC_GIVEN;
239 
240  //end of 3f5 outtakes
241 
242  ////////////////////////////////////////////////////////////////////
243  // these are intermediate variables added to the instance class instead
244  // of leaving them to be calculated repeatedly in the load function
245 
246  // some caluclated quantities
248  double DrainSatCur;
249  double SourceSatCur;
253  double OxideCap;
254 
255  // Solution variables and intermediate quantities
256  // drain,source,gate, bulk, drainprime and sourceprime voltages
257  double Vd;
258  double Vs;
259  double Vg;
260  double Vb;
261  double Vdp;
262  double Vsp;
263 
264  // KRS, 2/08/08: adding variables to represent the time derivatives of
265  // the above quantities (for MPDE compatibility). The "dot" means time
266  // derivative
267  double Vddot;
268  double Vsdot;
269  double Vgdot;
270  double Vbdot;
271  double Vdpdot;
272  double Vspdot;
273 
274 
275  // voltage drops between pairs of nodes
276  double Vddp; // drain-drain'
277  double Vssp; // source-source'
278  double Vbsp; // bulk-source'
279  double Vbdp; // bulk-drain'
280  double Vgsp; // gate-source'
281  double Vgdp; // gate-drain'
282  double Vgb; //gate-bulk
283  double Vdpsp; //drop across channel
284 
285  // the gate-drain voltage drop isn't actually a state variable, but it
286  // is calculated at the same time and in the same manner as the state
287  // vars. So here we go, sticking it in the instance class.
288  double vgd;
289 
290  // Some stuff from mos1temp that were local vars but used elsewhere
291  double vt; // set in updateTemperature to CONSTKoverQ*temp
292 
293 
294  // the variables capgs, capgd and capgb are the raw output of
295  // qmeyer. They get massaged into total capacitances in
296  // updateIntermediateVars, and get used in updatePrimaryState to get
297  // charges on the capacitors.
298 
299  double Capgs; // total gate-source capacitance
300  double Capgd; // total gate-drain capacitance
301  double Capgb; // total gate-bulk capacitance
302 
303  // current through source and drain resistors
304  double Isource;
305  double Idrain;
306 
307  double cdrain; // the channel current shouldn't be a local variable in */
308  // updateIntermediateVars!
309 
310  // these are calculated in loadRHS and used in the jacobian load
311  double Gm,Gmbs; // we do this so we don't really need the xnrm/xrev vars
312  double revsum; // described in comments at the end of
313  double nrmsum; // updateIntermediateVars (uIVB in remaining comments)
314  double cdreq;
315 
316  // end of intermediate variables that aren't state variables
317  ////////////////////////////
318  //
319  // vector indices
320  int li_Drain;
324  int li_Gate;
325  int li_Bulk;
326 
327  //KRS, 2/8/08: adding local indices for derivatives, too.
334 
335  ////////////////////////////////////////////////////////////////////
336  // The following verbatim from Level=1, which has the same jacobian
337  // structure
338  ////////////////////////////////////////////////////////////////////
339  // Jacobian matrix indices:
340  // This is a 6x6 matrix block, of which 22 entries are nonzero:
341  //
342  // ---------------------------------------------------------
343  // | #NZ | | |
344  // | entries | | V_d V_g V_s V_b V_d' V_s' |
345  // ---------------------------------------------------------
346  // | 2 | KCL_d | a b |
347  // | 4 | KCL_g | c d e f |
348  // | 2 | KCL_s | g h |
349  // | 4 | KCL_b | i j k l |
350  // | 5 | KCL_d'| m n o p q |
351  // | 5 | KCL_s'| r s t u v |
352  // ---------------------------------------------------------
353  // 22 total
354 
355  ////////////////////////////////////////////////////////////////////
356  // Offset variables corresponding to the above declared indices.
357 
358  //KRS, 3/6/08: Note that the above matrix stamp is NOT the matrix stamp
359  //for the new meyer stuff! The new Matrix stamp is 12x12 and is a little
360  //too large to put a diagram in here. I'll create some sort of memo/SAND
361  //report with the matrix structure...
362 
363  // Jacobian Matrix Offset:
364 
365  // V_d Row:
368 
369  // V_g Row:
374  // for new DAE/Meyer stuff:
379 
380  // V_s Row:
383 
384  // V_b Row:
389  // for new Meyer/DAE stuff
394 
395  // V_d' Row:
401  // for new Meyer/DAE stuff
405 
406  // V_s' Row:
412  // for new Meyer/DAE stuff
416 
417  //the remainder of these are all for new Meyer/DAE:
430 
431 #ifndef Xyce_NONPOINTER_MATRIX_LOAD
432  // F-Matrix Pointers:
433  // V_d Row:
434  double * f_DrainEquDrainNodePtr; // a
436 
437  // V_g Row:
438  double * f_GateEquGateNodePtr; // c
439  double * f_GateEquBulkNodePtr; // d
442  // for new DAE/Meyer stuff:
447 
448  // V_s Row:
451 
452  // V_b Row:
453  double * f_BulkEquGateNodePtr; // i
454  double * f_BulkEquBulkNodePtr; // j
457  // for new Meyer/DAE stuff
462 
463  // V_d' Row:
469  // for new Meyer/DAE stuff
473 
474  // V_s' Row:
480  // for new Meyer/DAE stuff
484 
485  //the remainder of these are all for new Meyer/DAE:
498 
499  // Q-Matrix Pointers:
500  // V_d Row:
501  double * q_DrainEquDrainNodePtr; // a
503 
504  // V_g Row:
505  double * q_GateEquGateNodePtr; // c
506  double * q_GateEquBulkNodePtr; // d
509  // for new DAE/Meyer stuff:
514 
515  // V_s Row:
518 
519  // V_b Row:
520  double * q_BulkEquGateNodePtr; // i
521  double * q_BulkEquBulkNodePtr; // j
524  // for new Meyer/DAE stuff
529 
530  // V_d' Row:
536  // for new Meyer/DAE stuff
540 
541  // V_s' Row:
547  // for new Meyer/DAE stuff
551 
552  //the remainder of these are all for new Meyer/DAE:
565 #endif
566 
567  ////////////////////////////////////////////////////////////////////
568  // 3f5 State Variables & related quantities:
569  // voltage drops
570  double vbd;
571  double vbs;
572  double vgs;
573  double vds;
574 
575  // "original" versions of various voltage drop variables:
576  double vgs_orig;
577  double vds_orig;
578  double vbs_orig;
579  double vbd_orig;
580  double vgd_orig;
581 
582  // "old" versions of various voltage drop variables:
583  double vgs_old;
584  double vds_old;
585  double vbs_old;
586  double vbd_old;
587  double vgd_old;
588 
589  // int newtonIter; // the Device class now has this, manager sets it.
590 
591  // meyer capacitances---KRS, 2/08/08: adding some variables to compute
592  // partial derivatives of these capacitances with respect to various
593  // voltage.
594  //gate-source capacitor
595  double capgs; //value
596  double dcapgsdvgs; //partial deriv. of capgs with respect to vgs
597  double dcapgsdvgb; //partial deriv. of capgs with respect to vgb
598  double dcapgsdvgd; //partial deriv. of capgs with respect to vgd
599  double qgs; // charge
600  // gate-drain capacitor
601  double capgd; //value
602  double dcapgddvgs; //partial deriv. of capgd with respect to vgs
603  double dcapgddvgb; //partial deriv. of capgd with respect to vgb
604  double dcapgddvgd; //partial deriv. of capgd with respect to vgd
605  double qgd; //charge
606  //gate-bulk capacitor
607  double capgb; //value
608  double dcapgbdvgs; //partial deriv. of capgb with respect to vgs
609  double dcapgbdvgb; //partial deriv. of capgb with respect to vgb
610  double dcapgbdvgd; //partial deriv. of capgb with respect to vgd
611  double qgb; //charge
612 
613  // diode capacitances
614  double qbd; // bulk-drain capacitor charge
615  double cqbd;// bulk-drain capacitor current
616 
617  double qbs; // bulk-source capacitor charge
618 
619  // indices into the state/store vector(s).
625 
626  // place in store vec for lead currents.
631 
635 
639 
642 
643  int blockHomotopyID; // For homotopy
644  double randomPerturb; // For homotopy
645 };
646 
647 
648 //-----------------------------------------------------------------------------
649 // Class : Model
650 // Purpose :
651 // Special Notes :
652 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
653 // Creation Date : 3/16/00
654 //-----------------------------------------------------------------------------
655 class Model : public DeviceModel
656 {
657  typedef std::vector<Instance *> InstanceVector;
658 
659  friend class ParametricData<Model>;
660  friend class Instance;
661  friend class Traits;friend class Master;
662 
663 public:
664  Model(
665  const Configuration & configuration,
666  const ModelBlock & MB,
667  const FactoryBlock & factory_block);
668  ~Model();
669 
670 private:
671  Model();
672  Model(const Model &);
673  Model &operator=(const Model &);
674 
675 public:
676  virtual void forEachInstance(DeviceInstanceOp &op) const /* override */;
677 
678  virtual std::ostream &printOutInstances(std::ostream &os) const;
679 
680  bool processParams ();
681  bool processInstanceParams ();
682 
683 
684 public:
685  void addInstance(Instance *instance)
686  {
687  instanceContainer.push_back(instance);
688  }
689 
690 private:
691  std::vector<Instance*> instanceContainer;
692 
693 private:
694 
695  int dtype; // device type : 1 = nmos, -1 = pmos
696  double model_l; // the length of the channel region
697  double model_w; // the width of the channel region
698  double tnom; // temperature at which parameters measured
699  double latDiff;
700  double jctSatCurDensity; // input - use tSatCurDens
701  double jctSatCur; // input - use tSatCur instead
705  double transconductance; // input - use tTransconductance
710  double vt0; // input - use tVto
711  double capBD; // input - use tCbs
712  double capBS; // input - use tCbd
713  double bulkCapFactor; // input - use tCj
714  double sideWallCapFactor; // input - use tCjsw
715  double bulkJctPotential; // input - use tBulkPot
719  double phi; // input - use tPhi
720  double gamma;
721  double lambda;
723  int gateType;
726  double surfaceMobility; // input - use tSurfMob
728  double fNcoef;
729  double fNexp;
730 
731  bool capBDGiven ;
732  bool capBSGiven ;
735 
736  // These variables were used as temporaries in mos1temp, but since
737  // the calculations in mos1temp are split between the model block
738  // constructor and the function updateTemperature, we need them to be
739  // model variables.
740 
741  double fact1;
742  double vtnom;
743  double egfet1;
744  double pbfact1;
745 };
746 
747 //-----------------------------------------------------------------------------
748 // Function : Instance:isConverged ()
749 // Purpose : Return whether a MOSFET device has done something that
750 // should be interpreted as invalidating other convergence
751 // tests
752 // In case of mos1, just do it if the limiter function
753 // pnjlim changed anything.
754 // This actually agrees with how the Check flag
755 // is used in Spice3F5 mos1load.c
756 // Special Notes :
757 // Scope : public
758 // Creator : Tom Russo, SNL, Component Information and Models
759 // Creation Date : 03/22/05
760 //-----------------------------------------------------------------------------
762 {
763  return (!limitedFlag);
764 }
765 
766 //-----------------------------------------------------------------------------
767 // Class : Master
768 // Purpose :
769 // Special Notes :
770 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
771 // Creation Date : 11/26/08
772 //-----------------------------------------------------------------------------
773 class Master : public DeviceMaster<Traits>
774 {
775 public:
777  const Configuration & configuration,
778  const FactoryBlock & factory_block,
779  const SolverState & ss1,
780  const DeviceOptions & do1)
781  : DeviceMaster<Traits>(configuration, factory_block, ss1, do1)
782  {}
783 
784  virtual bool updateState (double * solVec, double * staVec, double * stoVec);
785 
786  // new DAE stuff:
787  // new DAE load functions, residual:
788  virtual bool loadDAEVectors (double * solVec, double * fVec, double * qVec, double * bVec, double * storeLeadF, double * storeLeadQ);
789 
790  // new DAE load functions, Jacobian:
791  virtual bool loadDAEMatrices (N_LAS_Matrix & dFdx, N_LAS_Matrix & dQdx);
792 
793  friend class Instance;
794  friend class Traits;
795  friend class Model;
796 };
797 
798 void registerDevice();
799 
800 } // namespace MOSFET1
801 } // namespace Device
802 } // namespace Xyce
803 
807 
808 #endif