Xyce  6.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
N_DEV_ADMSvbic.h
Go to the documentation of this file.
1 
2 // -*-c++-*-
3 //-----------------------------------------------------------------------------
4 // Copyright Notice
5 //
6 // Copyright 2002 Sandia Corporation. Under the terms
7 // of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S.
8 // Government retains certain rights in this software.
9 //
10 // Xyce(TM) Parallel Electrical Simulator
11 // Copyright (C) 2002-2014 Sandia Corporation
12 //
13 // This program is free software: you can redistribute it and/or modify
14 // it under the terms of the GNU General Public License as published by
15 // the Free Software Foundation, either version 3 of the License, or
16 // (at your option) any later version.
17 //
18 // This program is distributed in the hope that it will be useful,
19 // but WITHOUT ANY WARRANTY; without even the implied warranty of
20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 // GNU General Public License for more details.
22 //
23 // You should have received a copy of the GNU General Public License
24 // along with this program. If not, see <http://www.gnu.org/licenses/>.
25 //-----------------------------------------------------------------------------
26 
27 //-----------------------------------------------------------------------------
28 // Filename : $RCSfile: N_DEV_ADMSvbic.h,v $
29 //
30 // Purpose :
31 //
32 // Special Notes : Generated from verilog file vbic_3T_et_cf_Xyce_typed.vla with ADMS
33 // interface for Xyce 6.1.0
34 // DO NOT EDIT THIS FILE DIRECTLY! It may be overwritten!
35 //
36 // Creator : admsXml-2.3.0
37 //
38 // Creation Date : Mon, 02 Jun 2014 11:31:29
39 //
40 // Revision Information:
41 // ---------------------
42 //
43 // Revision Number: $Revision: 1.53 $
44 //
45 // Revision Date : $Date: 2014/06/02 17:46:46 $
46 //
47 // Current Owner : $Author: tvrusso $
48 //-----------------------------------------------------------------------------
49 #ifndef Xyce_N_DEV_ADMSvbic_h
50 #define Xyce_N_DEV_ADMSvbic_h
51 
52 
53 #include <Sacado.hpp>
54 
55 #include <N_DEV_Configuration.h>
56 #include <N_DEV_Const.h>
57 #include <N_DEV_DeviceBlock.h>
58 #include <N_DEV_DeviceInstance.h>
59 #include <N_DEV_DeviceModel.h>
60 #include <N_DEV_BJT.h>
61 
62 
63 namespace Xyce {
64 namespace Device {
65 namespace ADMSvbic {
66 
67 class Model;
68 class Instance;
69 
70 struct Traits: public DeviceTraits<Model, Instance, BJT::Traits>
71 {
72  static const char *name() {return "VBIC 3T et cf v1.2";}
73  static const char *deviceTypeName() {return "q level 10";}
74 
75  static int numNodes() {return 4;}
76  static int numOptionalNodes() {return 5;}
77  static bool modelRequired() {return true;}
78  static bool isLinearDevice() {return false;}
79 
80  static Device *factory(const Configuration &configuration, const FactoryBlock &factory_block);
81  static void loadModelParameters(ParametricData<Model> &model_parameters);
82  static void loadInstanceParameters(ParametricData<Instance> &instance_parameters);
83 };
84 
85 //-----------------------------------------------------------------------------
86 // Class : Instance
87 
88 //
89 // Purpose : This class represents a single instance of the
90 // device. It mainly contains indices and pointers into
91 // the matrix equation (see the resistor instance class for
92 // more details).
93 //
94 // Special Notes :
95 // Creator :
96 // Creation Date :
97 //-----------------------------------------------------------------------------
98 class Instance : public DeviceInstance
99 {
100  friend class ParametricData<Instance>;
101  friend class Model;
102  friend class Traits;
103 
104  // This typedef is for our automatic differentiation:
105  typedef Sacado::Fad::SFad<double,15> AdmsFadType;
106 
107 public:
108  Instance(
109  const Configuration & configuration,
110  const InstanceBlock & instance_block,
111  Model & model,
112  const FactoryBlock & factory_block);
113 
114  ~Instance();
115 
116 private:
117  Instance(const Instance &);
118  Instance &operator=(const Instance &);
119 
120 public:
121  void registerLIDs( const std::vector<int> & intLIDVecRef,
122  const std::vector<int> & extLIDVecRef );
123  void registerStateLIDs( const std::vector<int> & staLIDVecRef );
124  void setupPointers();
125 
126  std::map<int,std::string> & getIntNameMap ();
127 
128  const std::vector< std::vector<int> > & jacobianStamp() const;
129  void registerJacLIDs( const std::vector< std::vector<int> > & jacLIDVec );
130 
131  bool processParams();
132  bool updateTemperature ( const double & temp = -999.0 );
133  bool updateIntermediateVars ();
134  bool updatePrimaryState ();
135  bool updateSecondaryState ();
136 
137  // load functions, residual:
138  bool loadDAEQVector ();
139  bool loadDAEFVector ();
140 
141  // load functions, Jacobian:
142  bool loadDAEdQdx ();
143  bool loadDAEdFdx ();
144 
145  void collapseNodes();
146 
147 private:
148  // Limited exponential --- NOT what verilog LRM says, but what qucs,
149  // ng-spice, and zspice do.
150 
151  template <typename T>
152  T limexp(const T &x)
153  {
154  if ((x) < 80.0)
155  return (exp(x));
156  else
157  return (exp(80.0)*(x-79.0));
158  }
159 
160 
161 public:
162  // iterator reference to the vbic model which owns this instance.
163  // Getters and setters
165  {
166  return model_;
167  }
168 
169 private:
170 
171  Model & model_; //< Owning Model
172  // Begin verilog Instance Variables
173  // Instance Parameters
174  int M;
175  // Variables of global_instance scope
176  // end verilog Instance Variables=====
177  // Nodal LID Variables
178  int li_c;
179  int li_b;
180  int li_e;
181  int li_dt;
182  int li_cx;
183  int li_ci;
184  int li_bx;
185  int li_bi;
186  int li_ei;
187  int li_bp;
188  // end Nodal LID Variables
189  // Branch LID Variables
190  // end Branch LID Variables
191  // Jacobian pointers
312  // end of Jacobian and pointers
313  // node numbers
314  static const int admsNodeID_c = 0;
315  static const int admsNodeID_b = 1;
316  static const int admsNodeID_e = 2;
317  static const int admsNodeID_dt = 3;
318  static const int admsNodeID_cx = 4;
319  static const int admsNodeID_ci = 5;
320  static const int admsNodeID_bx = 6;
321  static const int admsNodeID_bi = 7;
322  static const int admsNodeID_ei = 8;
323  static const int admsNodeID_bp = 9;
324  // end node numbers
325  // Additional IDs for branch equations
326  // end branch numbers
327  // Probe numbers
328  static const int admsProbeID_V_ci_ei = 0;
329  static const int admsProbeID_V_b_c = 1;
330  static const int admsProbeID_V_bp_cx = 2;
331  static const int admsProbeID_V_e_ei = 3;
332  static const int admsProbeID_V_b_bx = 4;
333  static const int admsProbeID_V_bx_bi = 5;
334  static const int admsProbeID_V_cx_ci = 6;
335  static const int admsProbeID_V_c_cx = 7;
336  static const int admsProbeID_V_b_e = 8;
337  static const int admsProbeID_V_dt_GND = 9;
338  static const int admsProbeID_V_bx_bp = 10;
339  static const int admsProbeID_V_bi_cx = 11;
340  static const int admsProbeID_V_bx_ei = 12;
341  static const int admsProbeID_V_bi_ci = 13;
342  static const int admsProbeID_V_bi_ei = 14;
343  // end probe numbers
344  // State LIDs
352  // end state LIDs
353  // bools for collapsing nodes
357  // Arrays to hold probes
358  std::vector < AdmsFadType > probeVars;
359  // Arrays to hold contributions
360  // dynamic contributions are differentiated w.r.t time
361  std::vector < AdmsFadType > staticContributions;
362  std::vector < AdmsFadType > dynamicContributions;
363 
364  // This array stores the differences between original and limited variables.
365  std::vector<double> probeDiffs;
366  // These store the Jdxp's for F and Q, respectively
367  std::vector<double> Jdxp_static;
368  std::vector<double> Jdxp_dynamic;
369 
370  // this is what we'll use when any model uses $temperature. We'll
371  // set it in updateTemperature, and initialize it to whatever
372  // is in devOptions when the instance is constructed.
374 
375  // vt at $temperature;
376  double adms_vt_nom;
377 
378 
379  // This one is for the annoying bogus "XyceADMSInstTemp" parameter
380  // that we need so we can set it from the device manager when there's no
381  // "TEMP" parameter to use
382  double admsInstTemp;
383 
384  // This is used to flag whether the cx, bx, and ei nodes are exposed
385  // on the instance line as external nodes.
387 
388  // thermal voltage at kelvin temperature temp)
389  inline double adms_vt(double temp) {return(CONSTKoverQ*temp);};
390 
391  std::vector< std::vector<int> > jacStamp;
392  std::vector<int> jacMap;
393  std::vector< std::vector<int> > jacMap2;
394 };
395 
396 
397 // Class AnalogFunctions
398 
400 {
401 public:
402 
403  // Analog Function limRTH
404  template<typename ScalarT> ScalarT limRTH(ScalarT orig, ScalarT old)
405  {
406 
407 
408  ScalarT limRTH;
409  ScalarT t0;
410  ScalarT t1;
411  ScalarT retval;
412  {
413  t0 = (orig-old);
414  t1 = fabs(t0);
415  retval = orig;
416  if ((t1>5.0))
417  {
418  if ((t0>0))
419  {
420  retval = (old+5.0);
421  }
422  else
423  {
424  retval = (old-5.0);
425  }
426  }
427  limRTH = retval;
428  }
429  return(limRTH);
430  }
431 
432 };
433 
434 
435 //-----------------------------------------------------------------------------
436 // Class : Model
437 
438 // Purpose :
439 // Special Notes :
440 // Creator :
441 // Creation Date :
442 //-----------------------------------------------------------------------------
443 class Model : public DeviceModel
444 {
445  typedef std::vector<Instance *> InstanceVector;
446 
447  friend class ParametricData<Model>;
448  friend class Instance;
449  friend class Traits;
450 
451  typedef Sacado::Fad::SFad<double,15> AdmsFadType;
452 
453 public:
454  Model(
455  const Configuration & configuration,
456  const ModelBlock & model_block,
457  const FactoryBlock & factory_block);
458 
459  ~Model();
460 
461 private:
462  Model(const Model &);
463  Model &operator=(const Model &);
464 
465 public:
466  virtual void forEachInstance(DeviceInstanceOp &op) const /* override */;
467  virtual std::ostream &printOutInstances(std::ostream &os) const;
468  bool processParams();
469  bool processInstanceParams();
470 
471 private:
473 
474 public:
475  void addInstance(Instance *instance)
476  {
477  instanceContainer.push_back(instance);
478  }
479 
480 private:
481  std::vector<Instance*> instanceContainer;
482 
483 private:
484 
485  // This one is for the annoying bogus "XyceADMSInstTemp" parameter
486  // that we need so we can set it from the device manager when there's no
487  // "TEMP" model parameter to use
488  double admsModTemp;
489  // Begin verilog Model Variables
490  // Model Parameters
491  double TNOM;
492  double RCX;
493  double RCI;
494  double VO;
495  double GAMM;
496  double HRCF;
497  double RBX;
498  double RBI;
499  double RE;
500  double RS;
501  double RBP;
502  double IS;
503  double NF;
504  double NR;
505  double FC;
506  double CBEO;
507  double CJE;
508  double PE;
509  double ME;
510  double AJE;
511  double CBCO;
512  double CJC;
513  double QCO;
514  double CJEP;
515  double PC;
516  double MC;
517  double AJC;
518  double CJCP;
519  double PS;
520  double MS;
521  double AJS;
522  double IBEI;
523  double WBE;
524  double NEI;
525  double IBEN;
526  double NEN;
527  double IBCI;
528  double NCI;
529  double IBCN;
530  double NCN;
531  double AVC1;
532  double AVC2;
533  double ISP;
534  double WSP;
535  double NFP;
536  double IBEIP;
537  double IBENP;
538  double IBCIP;
539  double NCIP;
540  double IBCNP;
541  double NCNP;
542  double VEF;
543  double VER;
544  double IKF;
545  double IKR;
546  double IKP;
547  double TF;
548  double QTF;
549  double XTF;
550  double VTF;
551  double ITF;
552  double TR;
553  double TD;
554  double KFN;
555  double AFN;
556  double BFN;
557  double XRE;
558  double XRBI;
559  double XRCI;
560  double XRS;
561  double XVO;
562  double EA;
563  double EAIE;
564  double EAIC;
565  double EAIS;
566  double EANE;
567  double EANC;
568  double EANS;
569  double XIS;
570  double XII;
571  double XIN;
572  double TNF;
573  double TAVC;
574  double RTH;
575  double CTH;
576  double VRT;
577  double ART;
578  double CCSO;
579  double QBM;
580  double NKF;
581  double XIKF;
582  double XRCX;
583  double XRBX;
584  double XRBP;
585  double ISRR;
586  double XISR;
587  double DEAR;
588  double EAP;
589  double VBBE;
590  double NBBE;
591  double IBBE;
592  double TVBBE1;
593  double TVBBE2;
594  double TNBBE;
595  double EBBE;
596  double DTEMP;
597  double VERS;
598  double VREV;
599  int dtype;
600  // Variables of global_model scope
601  // end verilog model variables=====
602 };
603 
604 void registerDevice();
605 
606 } // namespace ADMSvbic
607 } // namespace Device
608 } // namespace Xyce
609 #endif //Xyce_N_DEV_ADMSvbic_h