Xyce  6.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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-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_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.68.2.1 $
40 //
41 // Revision Date : $Date: 2014/02/26 20:16:30 $
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 const int numNodes() {return 3;}
67  static const bool modelRequired() {return true;}
68  static const 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  std::map<int,std::string> & getIntNameMap ();
110  std::map<int,std::string> & getStoreNameMap ();
111 
112  const std::vector< std::vector<int> > & jacobianStamp() const;
113  void registerJacLIDs( const std::vector< std::vector<int> > & jacLIDVec );
114 
115  // load functions, residual:
116  bool loadDAEQVector ();
117  bool loadDAEFVector ();
118 
119  // load functions, Jacobian:
120  bool loadDAEdQdx ();
121  bool loadDAEdFdx ();
122 
123  void setupPointers ();
124 
125  bool updateIntermediateVars ();
126  bool updatePrimaryState ();
127 
128  bool processParams ();
129  bool updateTemperature(const double & temp_tmp);
130 
131  inline bool isConverged();
132 
133 public:
134  // Getters and setters
136  {
137  return model_;
138  }
139 
140 private:
141  static std::vector< std::vector<int> > jacStamp_DC_SC;
142  static std::vector< std::vector<int> > jacStamp_DC;
143  static std::vector< std::vector<int> > jacStamp_SC;
144  static std::vector< std::vector<int> > jacStamp;
145 
146  static std::vector<int> jacMap_DC_SC;
147  static std::vector<int> jacMap_DC;
148  static std::vector<int> jacMap_SC;
149  static std::vector<int> jacMap;
150 
151  static std::vector< std::vector<int> > jacMap2_DC_SC;
152  static std::vector< std::vector<int> > jacMap2_DC;
153  static std::vector< std::vector<int> > jacMap2_SC;
154  static std::vector< std::vector<int> > jacMap2;
155 
156 
157  Model & model_; //< Owning model
158 
159  bool limitedFlag; // device convergence.
160  bool off; // non-zero indicates device is off for dc analysis
161  int ic; // initial VDS, VGS vector
162  double area; // area factor
163  double ic_vds; // initial D-S voltage
164  double ic_vgs; // initial G-S voltage
165  double temp; // instance temperature
166  double drainCond; // drain conductance
167  double sourceCond; // source conductance
168  double tCGS; // temp. corr. gate-source capacitance
169  double tCGD; // temp. corr. gate-drain capacitance
170  double tIS; // temp. corr. saturation current
171  double tPB; // temp. corr. gate potential
172  double tMESb; // temp. corr. dopinng tail parameter
173  double tBeta; // temp. corr. Beta
174  double tvt0; // temp. corr. vt0
175  double tLambda; // temp. corr. Lambda
176  double tAlpha; // saturation voltage parameter
177  double tRD; // temp. corr. drain resistance
178  double tRS; // temp. corr. source resistance
179  double vt; // set in updateTemperature to CONSTKoverQ*temp
180 
181  int dNode; // number of drain node
182  int gNode; // number of gate node
183  int sNode; // number of source node
184  int dpNode; // internal drain node
185  int spNode; // internal source node
186  double Vgs; // voltage G-S
187  double Vgd; // voltage G-D
188  double gm; // transconductance
189  double gds; // dc conductance D-S
190  double ggs; // dc conductance G-S
191  double ggd; // dc conductance G-D
192  double cdrain; // channel current
193  double cd; // drain current
194  double cg; // total dc gate current
195  double cgd; // dc gate-drain current
196  double corDepCap; // joining point of fwd bias dep. cap.
197  double vcrit; // critical voltage
198  double f1; // coeff. of capacitance polynomial exponent
199  double f2;
200  double f3;
201  double Bfac; // doping profile parameter
202  double p; // power dissipated by the MESFET
203 
206 
207  // Solution variables and intermediate quantities
208  // drain,source,gate, drainprime and sourceprime voltages
209  double Vd;
210  double Vs;
211  double Vg;
212  double Vdp;
213  double Vsp;
214 
215  // voltage drops between pairs of nodes
216  double Vddp; // drain-drain'
217  double Vssp; // source-source'
218  double Vgsp; // gate-source'
219  double Vgdp; // gate-drain'
220  double Vdpsp; //drop across channel
221 
222  // vector local indices
223  int li_Drain;
227  int li_Gate;
228 
229  /////////////////////////////////////////////////////////////////
230  // Jacobian matrix indices:
231  // This is a 5x5 matrix block, of which 15 entries are nonzero:
232  //
233  // ----------------------------------------------------
234  // | #NZ | | |
235  // | entries | | V_d V_g V_s V_d' V_s' |
236  // ----------------------------------------------------
237  // | 2 | KCL_d | a b |
238  // | 3 | KCL_g | c e f |
239  // | 2 | KCL_s | g h |
240  // | 4 | KCL_d'| m n p q |
241  // | 4 | KCL_s'| r s u v |
242  // ----------------------------------------------------
243  // 15 total
244 
245  ////////////////////////////////////////////////////////////////////
246  // Offset variables corresponding to the above declared indices.
247 
248  // Jacobian Matrix Offset:
249 
250  // V_d Row:
253 
254  // V_g Row:
258 
259  // V_s Row:
262 
263  // V_d' Row:
268 
269  // V_s' Row:
274 
275 
276 #ifndef Xyce_NONPOINTER_MATRIX_LOAD
277  ////////////////////////////////////////////////////////////////////
278  // dFdx Matrix Ptr:
279  // V_d Row:
280  double * f_DrainEquDrainNodePtr; // a
282 
283  // V_g Row:
284  double * f_GateEquGateNodePtr; // c
287 
288  // V_s Row:
291 
292  // V_d' Row:
297 
298  // V_s' Row:
303 
304  ////////////////////////////////////////////////////////////////////
305  // dQdx Matrix Ptr:
306 
307  // V_d Row:
308  double * q_DrainEquDrainNodePtr; // a
310 
311  // V_g Row:
312  double * q_GateEquGateNodePtr; // c
315 
316  // V_s Row:
319 
320  // V_d' Row:
325 
326  // V_s' Row:
331 #endif
332 
333  ////////////////////////////////////////////////////////////////////
334  // 3f5 State Variables & related quantities:
335  // voltage drops
336  double vgs;
337  double vgd;
338  double vds;
339 
340  // "original" versions of various voltage drop variables:
341  double vgs_orig;
342  double vgd_orig;
343  double vds_orig;
344 
345  // "old" versions of various voltage drop variables:
346  double vgs_old;
347  double vgd_old;
348  double vds_old;
349 
351 
352  int mode; // device mode : 1 = normal, -1 = inverse
353 
354  //gate-source capacitor
355  double capgs; // value
356  double qgs; // charge
357  double cqgs; // trans. G-S current
358  double gcgs; // conductance, d(cqgs)/dVgs
359 
360  // gate-drain capacitor
361  double capgd; // value
362  double qgd; // charge
363  double cqgd; // trans. G-D current
364  double gcgd; // conductance, d(cqgd)/dVgd
365 
366  // current through source and drain resistors
367  double Isource;
368  double Idrain;
369 
370  // local indices
376 
381 };
382 
383 //------------------- Class Model ---------------------------------
384 //-----------------------------------------------------------------------------
385 // Class : Model
386 // Purpose :
387 // Special Notes :
388 // Creator : pmc
389 // Creation Date : 11/16/2003
390 //-----------------------------------------------------------------------------
391 class Model : public DeviceModel
392 {
393  typedef std::vector<Instance *> InstanceVector;
394 
395  friend class ParametricData<Model>;
396  friend class Instance;
397  friend class Traits;friend class Master;
398 
399 public:
400  Model(
401  const Configuration & configuration,
402  const ModelBlock & MB,
403  const FactoryBlock & factory_block);
404  ~Model();
405 
406 private:
407  Model();
408  Model(const Model &);
409  Model &operator=(const Model &);
410 
411 public:
412  virtual void forEachInstance(DeviceInstanceOp &op) const /* override */;
413 
414  virtual std::ostream &printOutInstances(std::ostream &os) const;
415  bool processParams ();
416  bool processInstanceParams ();
417 
418 
419 public:
420  void addInstance(Instance *instance)
421  {
422  instanceContainer.push_back(instance);
423  }
424 
426  {
427  return instanceContainer;
428  }
429 
431  {
432  return instanceContainer;
433  }
434 
435 private:
436  std::vector<Instance*> instanceContainer;
437 
438 private:
439 
440  //user-specified parameters
441  double AF; // flicker noise exponent, default=1
442  double B; // doping tail parameter, default=1
443  double ALPHA; // saturation voltage paramter, default=2
444  double BETA; // transconductance paramter (A/V^2), default=1.0E-4
445  double CGS; // zero-bias G-S junction capacitance (F), default=5pf
446  double CGD; // zero-bias G-D junction capacitance (F), default=1pf
447  double FC; // coeff. for forward-bias depletion cap., default=0.5
448  double IS; // gate junction saturation current (A), default=1.0E-14
449  double KF; // flicker noise coefficient, default=0
450  double LAMBDA; // channel-length modulation parameter (1/V), default=0
451  double PB; // gate junction potential (V), default=1
452  double RD; // drain ohmic resistance (ohms), default=0
453  double RS; // source ohmic resistance (ohms), default=0
454  double TNOM; // parameter measurement temperature (C), default=27
455  double VTO; // threshhold voltage (V), default=-2.0
456  double fNcoef; // default=0;
457  double fNexp; // default=1;
458 
459 
460  int dtype; // device type: 1 = NJF, -1 = PJF
461 };
462 
463 //-----------------------------------------------------------------------------
464 // Function : Instance:isConverged ()
465 // Purpose : Return whether a MOSFET device has done something that
466 // should be interpreted as invalidating other convergence
467 // tests
468 // In case of mesfet, just do it if the limiter function
469 // pnjlim changed anything.
470 // This actually agrees with how the Check flag
471 // is used in Spice3F5 mesfetload.c
472 // Special Notes :
473 // Scope : public
474 // Creator : Tom Russo, SNL, Component Information and Models
475 // Creation Date : 03/22/05
476 //-----------------------------------------------------------------------------
478 {
479  return (!limitedFlag);
480 }
481 
482 //-----------------------------------------------------------------------------
483 // Class : Master
484 // Purpose :
485 // Special Notes :
486 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
487 // Creation Date : 11/26/08
488 //-----------------------------------------------------------------------------
489 class Master : public DeviceMaster<Traits>
490 {
491  friend class Instance;
492  friend class Model;
493 
494 public:
496  const Configuration & configuration,
497  const FactoryBlock & factory_block,
498  const SolverState & ss1,
499  const DeviceOptions & do1)
500  : DeviceMaster<Traits>(configuration, factory_block, ss1, do1)
501  {}
502 
503  virtual bool updateState (double * solVec, double * staVec, double * stoVec);
504 
505  virtual bool loadDAEVectors (double * solVec, double * fVec, double * qVec, double * storeLeadF, double * storeLeadQ);
506  virtual bool loadDAEMatrices (N_LAS_Matrix & dFdx, N_LAS_Matrix & dQdx);
507 };
508 
509 void registerDevice();
510 
511 } // namespace MESFET
512 } // namespace Device
513 } // namespace Xyce
514 
518 
519 #endif