Xyce  6.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
N_DEV_MOSFET2.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_MOSFET2.h,v $
27 //
28 // Purpose : Level 2 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.49 $
41 //
42 // Revision Date : $Date: 2014/05/22 17:40:29 $
43 //
44 // Current Owner : $Author: erkeite $
45 //-----------------------------------------------------------------------------
46 
47 #ifndef Xyce_N_DEV_MOSFET2_h
48 #define Xyce_N_DEV_MOSFET2_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 MOSFET2 {
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 2";}
70  static const char *deviceTypeName() {return "M level 2";}
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  // iterator reference to the model which owns this instance.
140  // Getters and setters
142  {
143  return model_;
144  }
145 
146 private:
147  static std::vector< std::vector<int> > jacStamp_DC_SC;
148  static std::vector< std::vector<int> > jacStamp_DC;
149  static std::vector< std::vector<int> > jacStamp_SC;
150  static std::vector< std::vector<int> > jacStamp;
151 
152  static std::vector<int> jacMap_DC_SC;
153  static std::vector<int> jacMap_DC;
154  static std::vector<int> jacMap_SC;
155  static std::vector<int> jacMap;
156 
157  static std::vector< std::vector<int> > jacMap2_DC_SC;
158  static std::vector< std::vector<int> > jacMap2_DC;
159  static std::vector< std::vector<int> > jacMap2_SC;
160  static std::vector< std::vector<int> > jacMap2;
161 
162 
163  Model & model_; //< Owning model
164 
165  // instance variables ripped -- bleeding and without anesthetic -- from
166  // 3f5, with obvious modifications to names (remove MOS1 prefix)
167  int states; // index into state table for this device
168  int dNode; // number of the gate node of the mosfet
169  int gNode; // number of the gate node of the mosfet
170  int sNode; // number of the source node of the mosfet
171  int bNode; // number of the bulk node of the mosfet
172  int dNodePrime; // number of the internal drain node of the mosfet
173  int sNodePrime; // number of the internal source node of the mosfet
174 
175 
176  bool OFF; // device initialized OFF (vbs=vgs=vds=0)
177 
178  double l; // the length of the channel region
179  double w; // the width of the channel region
180  double drainArea; // the area of the drain diffusion
181  double sourceArea; // the area of the source diffusion
182  double drainSquares; // the length of the drain in squares
183  double sourceSquares; // the length of the source in squares
186  double sourceConductance; //conductance of source(or 0):set in setup
187  double drainConductance; //conductance of drain(or 0):set in setup
188  double temp; // operating temperature of this instance
189  double numberParallel; // number simulated parallel mosfets
190 
191  double tTransconductance; // temperature corrected transconductance
192  double tSurfMob; // temperature corrected surface mobility
193  double tPhi; // temperature corrected Phi
194  double tVto; // temperature corrected Vto
195  double tSatCur; // temperature corrected saturation Cur.
196  double tSatCurDens; // temperature corrected saturation Cur. density
197  double tCbd; // temperature corrected B-D Capacitance
198  double tCbs; // temperature corrected B-S Capacitance
199  double tCj; // temperature corrected Bulk bottom Capacitance
200  double tCjsw; // temperature corrected Bulk side Capacitance
201  double tBulkPot; // temperature corrected Bulk potential
202  double tDepCap; // temperature adjusted transition point in
203  // the cureve matching Fc * Vj
204  double tVbi; // temperature adjusted Vbi
205 
206  double icVBS; // initial condition B-S voltage
207  double icVDS; // initial condition D-S voltage
208  double icVGS; // initial condition G-S voltage
209  double von;
210  double vdsat;
211  double sourceVcrit; // vcrit for pos. vds
212  double drainVcrit; // vcrit for neg. vds
213  double cd;
214  double cbs;
215  double cbd;
216  double gmbs;
217  double gm;
218  double gds;
219  double gbd;
220  double gbs;
221  double capbd;
222  double capbs;
223  double Cbd;
224  double Cbdsw;
225  double Cbs;
226  double Cbssw;
227  double f2d;
228  double f3d;
229  double f4d;
230  double f2s;
231  double f3s;
232  double f4s;
233  int mode; // device mode : 1 = normal, -1 = inverse
234  double mode_low;
235  double mode_high;
236 
237  bool limitedFlag; // for convergence testing.
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  // voltage drops between pairs of nodes
264  double Vddp; // drain-drain'
265  double Vssp; // source-source'
266  double Vbsp; // bulk-source'
267  double Vbdp; // bulk-drain'
268  double Vgsp; // gate-source'
269  double Vgdp; // gate-drain'
270  double Vgb; //gate-bulk
271  double Vdpsp; //drop across channel
272 
273  // the gate-drain voltage drop isn't actually a state variable, but it
274  // is calculated at the same time and in the same manner as the state
275  // vars. So here we go, sticking it in the instance class.
276  double vgd;
277 
278  // Some stuff from mos1temp that were local vars but used elsewhere
279  double vt; // set in updateTemperature to CONSTKoverQ*temp
280 
281 
282  // the variables capgs, capgd and capgb are the raw output of
283  // qmeyer. They get massaged into total capacitances in
284  // updateIntermediateVars, and get used in updatePrimaryState to get
285  // charges on the capacitors.
286 
287  double Capgs; // total gate-source capacitance
288  double Capgd; // total gate-drain capacitance
289  double Capgb; // total gate-bulk capacitance
290 
291  // current through source and drain resistors
292  double Isource;
293  double Idrain;
294 
295  double cdrain; // the channel current shouldn't be a local variable in */
296  // updateIntermediateVars!
297 
298  // these are calculated in loadRHS and used in the jacobian load
299  double Gm,Gmbs; // we do this so we don't really need the xnrm/xrev vars
300  double revsum; // described in comments at the end of
301  double nrmsum; // updateIntermediateVars (uIVB in remaining comments)
302  double cdreq;
303 
304  // end of intermediate variables that aren't state variables
305  ////////////////////////////
306  //
307  // vector indices
308  int li_Drain;
312  int li_Gate;
313  int li_Bulk;
314 
315  ////////////////////////////////////////////////////////////////////
316  // The following verbatim from Level=2, which has the same jacobian
317  // structure
318  ////////////////////////////////////////////////////////////////////
319  // Jacobian matrix indices:
320  // This is a 6x6 matrix block, of which 22 entries are nonzero:
321  //
322  // ---------------------------------------------------------
323  // | #NZ | | |
324  // | entries | | V_d V_g V_s V_b V_d' V_s' |
325  // ---------------------------------------------------------
326  // | 2 | KCL_d | a b |
327  // | 4 | KCL_g | c d e f |
328  // | 2 | KCL_s | g h |
329  // | 4 | KCL_b | i j k l |
330  // | 5 | KCL_d'| m n o p q |
331  // | 5 | KCL_s'| r s t u v |
332  // ---------------------------------------------------------
333  // 22 total
334 
335  ////////////////////////////////////////////////////////////////////
336  // Offset variables corresponding to the above declared indices.
337 
338  // Jacobian Matrix Offset:
339 
340  // V_d Row:
343 
344  // V_g Row:
349 
350  // V_s Row:
353 
354  // V_b Row:
359 
360  // V_d' Row:
366 
367  // V_s' Row:
373 
374  // Jacobian Matrix Pointers:
375 
376 #ifndef Xyce_NONPOINTER_MATRIX_LOAD
377  // F-vector pointers:
378  // V_d Row:
379  double * f_DrainEquDrainNodePtr; // a
381 
382  // V_g Row:
383  double * f_GateEquGateNodePtr; // c
384  double * f_GateEquBulkNodePtr; // d
387 
388  // V_s Row:
391 
392  // V_b Row:
393  double * f_BulkEquGateNodePtr; // i
394  double * f_BulkEquBulkNodePtr; // j
397 
398  // V_d' Row:
404 
405  // V_s' Row:
411 
412  // Q-vector pointers:
413  // V_d Row:
414  double * q_DrainEquDrainNodePtr; // a
416 
417  // V_g Row:
418  double * q_GateEquGateNodePtr; // c
419  double * q_GateEquBulkNodePtr; // d
422 
423  // V_s Row:
426 
427  // V_b Row:
428  double * q_BulkEquGateNodePtr; // i
429  double * q_BulkEquBulkNodePtr; // j
432 
433  // V_d' Row:
439 
440  // V_s' Row:
446 #endif
447  ////////////////////////////////////////////////////////////////////
448  // 3f5 State Variables & related quantities:
449  // voltage drops
450  double vbd;
451  double vbs;
452  double vgs;
453  double vds;
454 
455  // "original" versions of various voltage drop variables:
456  double vgs_orig;
457  double vds_orig;
458  double vbs_orig;
459  double vbd_orig;
460  double vgd_orig;
461 
462  // "old" versions of various voltage drop variables:
463  double vgs_old;
464  double vds_old;
465  double vbs_old;
466  double vbd_old;
467  double vgd_old;
468 
469  // int newtonIter; // the Device class now has this, manager sets it.
470 
471  // meyer capacitances
472  //gate-source capacitor
473  double capgs; //value
474  double qgs; // charge
475  // gate-drain capacitor
476  double capgd; //value
477  double qgd; //charge
478  //gate-bulk capacitor
479  double capgb; //value
480  double qgb; //charge
481 
482  // diode capacitances
483  double qbd; // bulk-drain capacitor charge
484  double qbs; // bulk-source capacitor charge
485 
486  // indices into the state vector.
492 
493  // place in store vec for lead currents.
498 
502 
506 
509 
510  int blockHomotopyID; // For homotopy
511  double randomPerturb; // For homotopy
512 };
513 
514 
515 //-----------------------------------------------------------------------------
516 // Class : Model
517 // Purpose :
518 // Special Notes :
519 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
520 // Creation Date : 3/16/00
521 //-----------------------------------------------------------------------------
522 class Model : public DeviceModel
523 {
524  typedef std::vector<Instance *> InstanceVector;
525 
526  friend class ParametricData<Model>;
527  friend class Instance;
528  friend class Traits;friend class Master;
529 
530 public:
531  Model(
532  const Configuration & configuration,
533  const ModelBlock & MB,
534  const FactoryBlock & factory_block);
535  ~Model();
536 
537 private:
538  Model();
539  Model(const Model &);
540  Model &operator=(const Model &);
541 
542 public:
543  virtual void forEachInstance(DeviceInstanceOp &op) const /* override */;
544 
545  virtual std::ostream &printOutInstances(std::ostream &os) const;
546 
547  bool processParams ();
548  bool processInstanceParams ();
549 
550 
551 public:
552  void addInstance(Instance *instance)
553  {
554  instanceContainer.push_back(instance);
555  }
556 
557 private:
558  std::vector<Instance*> instanceContainer;
559 
560 private:
561 
562  int dtype; // device type : 1 = nmos, -1 = pmos
563  double model_l; // the length of the channel region
564  double model_w; // the width of the channel region
565  double tnom; // temperature at which parameters measured
566  double latDiff;
567  double jctSatCurDensity; // input - use tSatCurDens
568  double jctSatCur; // input - use tSatCur instead
572  double transconductance; // input - use tTransconductance
577  double vt0; // input - use tVto
578  double capBD; // input - use tCbs
579  double capBS; // input - use tCbd
580  double bulkCapFactor; // input - use tCj
581  double sideWallCapFactor; // input - use tCjsw
582  double bulkJctPotential; // input - use tBulkPot
586  double phi; // input - use tPhi
587  double gamma;
588  double lambda;
590  int gateType;
593  double surfaceMobility; // input - use tSurfMob
595  double fNcoef;
596  double fNexp;
597 
598  bool capBDGiven ;
599  bool capBSGiven ;
602 
603  // These variables were used as temporaries in mos1temp, but since
604  // the calculations in mos1temp are split between the model block
605  // constructor and the function updateTemperature, we need them to be
606  // model variables.
607 
608  double fact1;
609  double vtnom;
610  double egfet1;
611  double pbfact1;
612 
613  // level-2 vars
614  double xd;
617  double critField;
618  double critFieldExp;
619  double maxDriftVel;
621  double narrowFactor;
622 };
623 
624 //-----------------------------------------------------------------------------
625 // Function : Instance:isConverged ()
626 // Purpose : Return whether a MOSFET device has done something that
627 // should be interpreted as invalidating other convergence
628 // tests
629 // In case of mos1, just do it if the limiter function
630 // pnjlim changed anything.
631 // This actually agrees with how the Check flag
632 // is used in Spice3F5 mos1load.c
633 // Special Notes :
634 // Scope : public
635 // Creator : Tom Russo, SNL, Component Information and Models
636 // Creation Date : 03/22/05
637 //-----------------------------------------------------------------------------
639 {
640  return (!limitedFlag);
641 }
642 
643 //-----------------------------------------------------------------------------
644 // Class : Master
645 // Purpose :
646 // Special Notes :
647 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
648 // Creation Date : 11/26/08
649 //-----------------------------------------------------------------------------
650 class Master : public DeviceMaster<Traits>
651 {
652  friend class Instance;
653  friend class Model;
654 
655 public:
657  const Configuration & configuration,
658  const FactoryBlock & factory_block,
659  const SolverState & ss1,
660  const DeviceOptions & do1)
661  : DeviceMaster<Traits>(configuration, factory_block, ss1, do1)
662  {}
663 
664  virtual bool updateState (double * solVec, double * staVec, double * stoVec);
665 
666  // new DAE stuff:
667  // new DAE load functions, residual:
668  virtual bool loadDAEVectors (double * solVec, double * fVec, double * qVec, double * bVec, double * storeLeadF, double * storeLeadQ);
669 
670  // new DAE load functions, Jacobian:
671  virtual bool loadDAEMatrices (N_LAS_Matrix & dFdx, N_LAS_Matrix & dQdx);
672 };
673 
674 void registerDevice();
675 
676 } // namespace MOSFET2
677 } // namespace Device
678 } // namespace Xyce
679 
683 
684 #endif
685