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 : Thu, 06 Mar 2014 15:58:02
39 //
40 // Revision Information:
41 // ---------------------
42 //
43 // Revision Number: $Revision: 1.48.2.3 $
44 //
45 // Revision Date : $Date: 2014/03/06 23:33:42 $
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 const int numNodes() {return 4;}
76  static const int numOptionalNodes() {return 5;}
77  static const bool modelRequired() {return true;}
78  static const 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(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 
481  {
482  return instanceContainer;
483  }
484 
486  {
487  return instanceContainer;
488  }
489 
490 private:
491  std::vector<Instance*> instanceContainer;
492 
493 private:
494 
495  // This one is for the annoying bogus "XyceADMSInstTemp" parameter
496  // that we need so we can set it from the device manager when there's no
497  // "TEMP" model parameter to use
498  double admsModTemp;
499  // Begin verilog Model Variables
500  // Model Parameters
501  double TNOM;
502  double RCX;
503  double RCI;
504  double VO;
505  double GAMM;
506  double HRCF;
507  double RBX;
508  double RBI;
509  double RE;
510  double RS;
511  double RBP;
512  double IS;
513  double NF;
514  double NR;
515  double FC;
516  double CBEO;
517  double CJE;
518  double PE;
519  double ME;
520  double AJE;
521  double CBCO;
522  double CJC;
523  double QCO;
524  double CJEP;
525  double PC;
526  double MC;
527  double AJC;
528  double CJCP;
529  double PS;
530  double MS;
531  double AJS;
532  double IBEI;
533  double WBE;
534  double NEI;
535  double IBEN;
536  double NEN;
537  double IBCI;
538  double NCI;
539  double IBCN;
540  double NCN;
541  double AVC1;
542  double AVC2;
543  double ISP;
544  double WSP;
545  double NFP;
546  double IBEIP;
547  double IBENP;
548  double IBCIP;
549  double NCIP;
550  double IBCNP;
551  double NCNP;
552  double VEF;
553  double VER;
554  double IKF;
555  double IKR;
556  double IKP;
557  double TF;
558  double QTF;
559  double XTF;
560  double VTF;
561  double ITF;
562  double TR;
563  double TD;
564  double KFN;
565  double AFN;
566  double BFN;
567  double XRE;
568  double XRBI;
569  double XRCI;
570  double XRS;
571  double XVO;
572  double EA;
573  double EAIE;
574  double EAIC;
575  double EAIS;
576  double EANE;
577  double EANC;
578  double EANS;
579  double XIS;
580  double XII;
581  double XIN;
582  double TNF;
583  double TAVC;
584  double RTH;
585  double CTH;
586  double VRT;
587  double ART;
588  double CCSO;
589  double QBM;
590  double NKF;
591  double XIKF;
592  double XRCX;
593  double XRBX;
594  double XRBP;
595  double ISRR;
596  double XISR;
597  double DEAR;
598  double EAP;
599  double VBBE;
600  double NBBE;
601  double IBBE;
602  double TVBBE1;
603  double TVBBE2;
604  double TNBBE;
605  double EBBE;
606  double DTEMP;
607  double VERS;
608  double VREV;
609  int dtype;
610  // Variables of global_model scope
611  // end verilog model variables=====
612 };
613 
614 void registerDevice();
615 
616 } // namespace ADMSvbic
617 } // namespace Device
618 } // namespace Xyce
619 #endif //Xyce_N_DEV_ADMSvbic_h