Xyce  6.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
N_DEV_BJT.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_BJT.h,v $
27 //
28 // Purpose :
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.157.2.1 $
40 //
41 // Revision Date : $Date: 2014/02/26 20:16:30 $
42 //
43 // Current Owner : $Author: tvrusso $
44 //-----------------------------------------------------------------------------
45 
46 
47 #ifndef Xyce_N_DEV_BJT_H
48 #define Xyce_N_DEV_BJT_H
49 
50 
51 // ---------- Standard Includes ----------
52 
53 // ---------- Xyce Includes ----------
54 #include <N_DEV_Configuration.h>
55 #include <N_DEV_DeviceMaster.h>
56 #include <N_DEV_DeviceInstance.h>
57 #include <N_DEV_DeviceModel.h>
58 #include <N_DEV_DeviceBlock.h>
59 #include <N_DEV_Param.h>
60 #include <N_UTL_BreakPoint.h>
61 
62 
63 // ---------- Forward Declarations -------
64 namespace Xyce {
65 namespace Device {
66 namespace BJT {
67 
68 class Model;
69 class Instance;
70 
71 struct Traits : public DeviceTraits<Model, Instance>
72 {
73  static const char *name() {return "Bipolar Junction Transistor";}
74  static const char *deviceTypeName() {return "Q level 1";}
75  static const int numNodes() {return 3;}
76  static const int numOptionalNodes() {return 4;}
77  static const int numFillNodes() {return 1;}
78  static const bool modelRequired() {return true;}
79  static const bool isLinearDevice() {return false;}
80 
81  static Device *factory(const Configuration &configuration, const FactoryBlock &factory_block);
82  static void loadModelParameters(ParametricData<Model> &model_parameters);
83  static void loadInstanceParameters(ParametricData<Instance> &instance_parameters);
84 };
85 
86 //-----------------------------------------------------------------------------
87 // Class : Instance
88 // Purpose : This class refers to a single instance of the BJT
89 // device. It contains indices into the matrix equation.
90 // See the comments for the ResistorInstance class for
91 // more details.
92 //
93 // The bjt will have 4 external nodes: collector, base,
94 // emitter, and substrate, and 3 internal nodes:
95 // collectorPrime, basePrime, and emitterPrime.
96 // Special Notes :
97 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
98 // Creation Date : 3/16/00
99 //-----------------------------------------------------------------------------
100 
101 class Instance : public DeviceInstance
102 {
103  friend class ParametricData<Instance>;
104  friend class Model;
105  friend class Traits;friend class Master;
106 
107  // functions
108 public:
109 
110  Instance(
111  const Configuration & configuration,
112  const InstanceBlock & IB,
113  Model & it_MB,
114  const FactoryBlock & factory_block);
115 
116  ~Instance();
117 
118 private:
119  Instance(const Instance &);
120  Instance &operator=(const Instance &);
121 
122 public:
123  void registerLIDs( const std::vector<int> & intLIDVecRef,
124  const std::vector<int> & extLIDVecRef );
125  void registerStateLIDs( const std::vector<int> & stateLIDVecRef );
126  void registerStoreLIDs( const std::vector<int> & stoLIDVecRef);
127 
128  std::map<int,std::string> & getIntNameMap ();
129  std::map<int,std::string> & getStoreNameMap();
130 
131  const std::vector< std::vector<int> > & jacobianStamp() const;
132  void registerJacLIDs( const std::vector< std::vector<int> > & jacLIDVec );
133 
134  bool processParams ();
135  bool updateTemperature (const double & temp = -999.0 );
136  bool lambertWCurrent (double &Id, double &Gd, double Vd, double Vte, double Isat);
137 
138  bool updateIntermediateVars ();
139  bool updatePrimaryState ();
140  bool updateSecondaryState ();
141 
142  bool loadDeviceMask ();
143 
144 #ifdef Xyce_DEBUG_EXCESS_PHASE
145  bool plotfileFlag () {return true;}
146 #else
147  bool plotfileFlag () {return false;}
148 #endif
149 
152  (double & iEX, double & gEX, double & iC_local);
153 
154  // load functions, residual:
155  bool loadDAEQVector ();
156  bool loadDAEFVector ();
157 
158  void auxDAECalculations ();
159 
160  // load functions, Jacobian:
161  bool loadDAEdQdx ();
162  bool loadDAEdFdx ();
163 
164  // Debugging Excess Phase function:
165  bool outputPlotFiles ();
166 
167  void setupPointers();
168 
169 protected:
170 private:
171 
172  //attributes
173 public:
174  //iterator reference to the BJT model which owns this instance.
175  // Getters and setters
177  {
178  return model_;
179  }
180 
181 private:
182 
183  Model & model_; //< Owning model
184 
185  //external instance params
186  double AREA; // The normalized emitter area (AREA)
187  double icVBE; // the inital base-emitter voltage (ICVBE)
188  double icVCE; // the inital collector-emitter voltage (ICVCE)
189  double TEMP; // instance temperature (TEMP)
190  bool OFF; // initial mode of operation (OFF)
192  bool IC_GIVEN;
194  bool offFlag;
195 
196  //generated instance params
197  double vt; //thermal junc. volt.
198  double tSatCur; //saturation current (temp. adj.)
199  double tBetaF; //forward beta (temp. adj.)
200  double tBetaR; //reverse beta (temp. adj.)
201  double tBELeakCur; //BE leakage current (temp. adj.)
202  double tBCLeakCur; //BC leakage current (temp. adj.)
203  double tBECap; //BE capacitance (temp. adj.)
204  double tBCCap; //BC capacitance (temp. adj.)
205  double tBEPot; //BE potential (temp. adj.)
206  double tBCPot; //BC potential (temp. adj.)
207  double tDepCap; //join pt in diode curve (temp. adj.)
208  double tF1; //polynomial coeff. (temp. adj.)
209  double tF4; //polynomial coeff. (temp. adj.)
210  double tF5; //polynomial coeff. (temp. adj.)
211  double tVCrit; //critical voltage (temp. adj.)
212 
213  // additional temperature-adjusted parameters
216  double tRollOffExp;
217  double tInvRollOffF;
218  double tInvRollOffR;
221  double tBaseResist;
224 
225  //generated intermediate variables
226  double vEEp; // e-e' voltage
227  double vBBp; // b-b' voltage
228  double vCCp; // c-c' voltage
229 
230  double vBE; // b'-e' voltage
231  double vBC; // b'-c' voltage
232  double vBX; // b-c' voltage
233  double vCS; // c'-s voltage
234 
235  double vBE_old; // b'-e' voltage, from previous newton step.
236  double vBC_old; // b'-c' voltage, from previous newton step.
237 
238  double vBE_orig; // b'-e' voltage, before pinning.
239  double vBC_orig; // b'-c' voltage, before pinning.
240 
241  double qB; // Base charge factor
242  double invqB; // inverse of qB
243  double dqBdvEp; // d(qB)/d(vE')
244  double dqBdvBp; // d(qB)/d(vB')
245  double dqBdvCp; // d(qB)/d(vC')
246 
247  double iBE; // b-e current (not including capacitors)
248  double iBC; // b-c current (not including capacitors)
249  double iBEleak;
250  double iBCleak;
251  double iCE; // c-e current
252 
253  double iB; // total current to base
254  double iC; // total current to collector
255  double iE; // total current to emitter
256 
257  // high current versions of iBE, gBE.
258  double iBEhighCurr;
259  double gBEhighCurr;
260 
261  double gBE;
262  double gBC;
263  double gBEleak;
264  double gBCleak;
265 
266  double gEpr; // conductance for e-e' resistance
267  double gCpr; // conductance for c-c' resistance
268 
269  double gX; // conductance for b-b' resistance
270 
271  double geqCB; // high current forward transit effect (conductance)
272  double capeqCB; // high current forward transit effect (capacitance)
273 
274  // Partial derivatives that originally were local to load function
275  double diBrdvB;
276  double diBrdvEp;
277  double diBrdvCp;
278  double diBrdvBp;
279  double diCEdvEp;
280  double diCEdvCp;
281  double diCEdvBp;
282  double diBEdvEp;
283  double diBEdvCp;
284  double diBEdvBp;
285 
286  double gCapBEdiff;
287  double gCapBEdep;
288  double gCapBCdiff;
289  double gCapBCdep;
290  double gCapBX;
291  double gCapCS;
292  double gBEtot;
293  double gBCtot;
294  //double gCpr;
295  //double gEpr;
296 
297 
298  //state variables
299  double qBEdiff; // charge in the b-e diffusion capacitor
300  double iBEdiff; // current through the b-e diffusion capacitor
301  double capBEdiff; // capacitance for b-e diffusion capacitor
302  double qBEdep; // charge in the b-e depletion capacitor
303  double iBEdep; // current through the b-e diffusion capacitor
304  double capBEdep; // capacitance for b-e depletion capacitor
305  double qCS; // charge in the c-s capacitor
306  double iCS; // current through the c-s capacitor
307  double capCS; // capacitance for c-s capacitor
308  double qBCdiff; // charge in the b-c diffusion capacitor
309  double iBCdiff; // current through the b-c diffusion capacitor
310  double capBCdiff; // capacitance for b-c diffusion capacitor
311  double qBCdep; // charge in the b-c depletion capacitor
312  double iBCdep; // current through the b-c depletion capacitor
313  double capBCdep; // capacitance for b-c depletion capacitor
314  double qBX; // charge in the b-cP capacitor
315  double iBX; // current through the b-cP capacitor
316  double capBX; // capacitance for b-cP capacitor
317 
318  //local indexing of solution and state variables
319  int li_Coll;
320  int li_CollP;
321  int li_Base;
322  int li_BaseP;
323  int li_Emit;
324  int li_EmitP;
325  int li_Subst;
326 
327  //new variables for full new DAE integration of excess phase term
328  int li_Ifx;
329  int li_dIfx;
330 
337 
338  // for the "old" excess phase calculation.
340 
341  // stored data for limiting and lead currents.
349 
350  //conductance values
351  double gcpr;
352  double gepr;
353  double gx;
354  double gm;
355  double go;
356  double gmu;
357  double gpi;
358  double gccs;
359  double geqbx;
360  double geqbc;
361 
362  // excess phase variables
363  double nextCexbc;
364  double currCexbc;
365  double lastCexbc;
366  double phaseScalar;
367  double dt0,dt1;
368 
369  // Offset variables corresponding to the above declared indices.
394 
395  //new offsets for full new DAE integration of excess phase term
398 
399  // ERK. These 3 are only needed for dcop.
403 
406 
412 
413 #ifndef Xyce_NONPOINTER_MATRIX_LOAD
414  // f-matrix pointers:
439 
440  //new offsets for full new DAE integration of excess phase term
443 
444  // ERK. These 3 are only needed for dcop.
448 
451 
457 
458 
459  // q-matrix pointers:
484 
485  //new offsets for full new DAE integration of excess phase term
488 
489  // ERK. These 3 are only needed for dcop.
493 
496 
502 #endif
503 
504 
505  static std::vector< std::vector<int> > jacStamp_RB_RC_RE_;
506  static std::vector< std::vector<int> > jacStamp_RB_RC_;
507  static std::vector< std::vector<int> > jacStamp_RB_RE_;
508  static std::vector< std::vector<int> > jacStamp_RC_RE_;
509  static std::vector< std::vector<int> > jacStamp_RB_;
510  static std::vector< std::vector<int> > jacStamp_RC_;
511  static std::vector< std::vector<int> > jacStamp_RE_;
512  static std::vector< std::vector<int> > jacStamp_;
513 
514  static std::vector<int> jacMap_RB_RC_RE_;
515  static std::vector<int> jacMap_RB_RC_;
516  static std::vector<int> jacMap_RB_RE_;
517  static std::vector<int> jacMap_RC_RE_;
518  static std::vector<int> jacMap_RB_;
519  static std::vector<int> jacMap_RC_;
520  static std::vector<int> jacMap_RE_;
521  static std::vector<int> jacMap_;
522 
523  static std::vector< std::vector<int> > jacMap2_RB_RC_RE_;
524  static std::vector< std::vector<int> > jacMap2_RB_RC_;
525  static std::vector< std::vector<int> > jacMap2_RB_RE_;
526  static std::vector< std::vector<int> > jacMap2_RC_RE_;
527  static std::vector< std::vector<int> > jacMap2_RB_;
528  static std::vector< std::vector<int> > jacMap2_RC_;
529  static std::vector< std::vector<int> > jacMap2_RE_;
530  static std::vector< std::vector<int> > jacMap2_;
531 
533 };
534 
535 //-----------------------------------------------------------------------------
536 // Class : Model
537 // Purpose :
538 // Special Notes :
539 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
540 // Creation Date : 3/16/00
541 //-----------------------------------------------------------------------------
542 class Model : public DeviceModel
543 {
544  typedef std::vector<Instance *> InstanceVector;
545 
546  friend class ParametricData<Model>;
547  friend class Instance;
548  friend class Traits;friend class Master;
549 
550 public:
551  Model(
552  const Configuration & configuration,
553  const ModelBlock & MB,
554  const FactoryBlock & factory_block);
555 
556  ~Model();
557 
558 private:
559  Model();
560  Model(const Model &);
561  Model &operator=(const Model &);
562 
563 public:
565 
566  virtual void forEachInstance(DeviceInstanceOp &op) const /* override */;
567 
568  virtual std::ostream &printOutInstances(std::ostream &os) const;
569 
570  bool processParams ();
571  bool processInstanceParams ();
572 
573 
574 public:
575  void addInstance(Instance *instance)
576  {
577  instanceContainer.push_back(instance);
578  }
579 
581  {
582  return instanceContainer;
583  }
584 
586  {
587  return instanceContainer;
588  }
589 
590 private:
591  std::vector<Instance*> instanceContainer;
592 
593 private:
594 
595  //external model params
596  int TYPE; //+1 = NPN, -1 = PNP
597  double TNOM; //nominal temperature
598  double satCur; //Saturation Current (IS)
599 
600  double betaF; //forward beta (BF)
601  bool BFgiven; // given flag for forward beta (spice/Pspice)
602  bool BFMgiven; // given flag for forward beta (hspice)
603  double emissionCoeffF; //forward current emmission coeff (NF)
604  double earlyVoltF; //forward early voltage (VAF)
605  bool VAgiven; // given flag for fwd early voltage (Hspice/Pspice)
606  bool VAFgiven; // given flag for fwd early voltage (Spice)
607  bool VBFgiven; // given flag for fwd early voltage (Hspice)
608 
609  double rollOffF; //forward high current roll-off (IKF)
610  bool IKFgiven; // given flag for high current roll-off (spice)
611  bool IKgiven; // given flag for high current roll-off (pspice/hspice)
612  bool JBFgiven; // given flag for high current roll-off (hspice)
613 
614  double leakBECurrent; //BE leakage saturation current (ISE)
615  double leakBEEmissionCoeff;//BE leakage emission coeff. (NE)
616  bool NEgiven; // given flag for leakage emission coef.(NE) (spice/pspice)
617  bool NLEgiven; // given flag for leakage emission coef.(NLE) (hspice)
618 
619  double betaR; // reverse beta (BR)
620  bool BRgiven; // given flag for reverse beta, BR (spice/pspice)
621  bool BRMgiven; // given flag for reverse beta, BR (hspice)
622 
623  double emissionCoeffR; // reverse current emmission coeff (NR)
624  double earlyVoltR; // reverse early voltage (VAR/VB/VRB/BV)
625  bool VARgiven; // given flag for reverse early voltage(VAR) (spice)
626  bool VBgiven; // given flag for reverse early voltage(VB) (pspice/hspice)
627  bool VRBgiven; // given flag for reverse early voltage(VRB) (hspice)
628  bool BVgiven; // given flag for reverse early voltage(BV) (hspice)
629 
630 
631  double rollOffR; //reverse high current roll-off (IKR)
632  bool IKRgiven; // given flag for reverse high current roll-off (IKR) (spice)
633  bool JBRgiven; // given flag for reverse high current roll-off (JBR) (Hspice)
634  double leakBCCurrent; //BC leakage saturation current (ISC)
635  double leakBCEmissionCoeff;//BC leakage emission coeff. (NC)
636 
637  double baseResist; //zero bias base resistance (RB)
638  double baseCurrHalfResist; //current for 1/2 base resistance (IRB)
639  bool IRBgiven; // given flag for 1/2 base resist. (IRB, spice)
640  bool JRBgiven; // given flag for 1/2 base resist. (JRB, spice)
641  bool IOBgiven; // given flag for 1/2 base resist. (IOB, spice)
642 
643  double minBaseResist; //min base resistance for high current (RBM)
644  double emitterResist; //emitter resistance (RE)
645  double collectorResist; //collector resistance (RC)
646 
647  double depCapBE; //BE zero bias depletion capacitance (CJE)
648  double potBE; //BE built-in potential (VJE)
649  bool VJEgiven; // given flag for BE built-in potential (VJE,spice)
650  bool PEgiven; // given flag for BE built-in potential (PE,pspice, hspice)
651 
652  double juncExpBE; //BE junction exponential factor (MJE)
653  bool MJEgiven; // given flag for BE exponential factor (MJE,spice)
654  bool MEgiven; // given flag for BE exponential factor (ME,pspice, hspice)
655 
656  double transTimeF; //ideal forward transit time (TF)
657  double transTimeBiasCoeffF;//bias dependent coefficient for TF (XTF)
658  double transTimeFVBC; //VBC dependence for TF (VTF)
659  double transTimeHighCurrF; //high current parameter for TF (ITF)
660  bool ITFgiven; // given flag for ITF (spice)
661  bool JTFgiven; // given flag for ITF (hspice)
662  double excessPhase; //excess phase at freq=1.0/(TF*2PI) Hz (PTF)
663 
664  double depCapBC; //BC zero bias depletion capacitance (CJC)
665  double potBC; //BC built-in potential (VJC)
666  bool VJCgiven; // given flag for BC built-in potential (VJE,spice)
667  bool PCgiven; // given flag for BC built-in potential (PE,pspice, hspice)
668 
669  double juncExpBC; //BC junction exponential factor (MJC)
670  bool MJCgiven; // given flag for BC exponential factor (MJC,spice)
671  bool MCgiven; // given flag for BC exponential factor (MC,pspice, hspice)
672 
673  double baseFracBCCap; //fraction of BC cap. to int. base node (XCJC)
674  bool XCJCgiven; // given flag for spice/pspice.
675  bool CDISgiven; // given flag for hspice
676 
677  double transTimeR; //ideal reverse transit time (TR)
678 
679  double CJS; //zero-bias coll-subst capacitance (CJS)
680  bool CJSgiven; //zero-bias coll-subst capacitance (CJS) given flag (spice)
681  bool CCSgiven; //zero-bias coll-subst capacitance (CCS) given flag (Pspice/Hspice)
682  bool CSUBgiven; //zero-bias coll-subst capacitance (CSUB) given flag (Hspice)
683 
684  double potSubst; //substrate junction built-in potential (VJS)
685  bool VJSgiven; // given flag for spice format (VJS)
686  bool PSgiven; // given flag for spice format (PS)
687  bool PSUBgiven; // given flag for spice format (PSUB)
688 
689  double expSubst; //subst. junction exponential factor (MJS)
690  bool MJSgiven; // given flag for spice format (MJS)
691  bool MSgiven; // given flag for spice format (MS)
692  bool ESUBgiven; // given flag for spice format (ESUB)
693 
694  double betaExp; //beta temperature exponent (XTB)
695  bool XTBgiven; // given for spice/pspice
696  bool TBgiven; // given for hspice
697  bool TCBgiven; // given for hspice
698 
699  double energyGap; //energy gap for temp. effect on IS (EG)
700  double tempExpIS; //temp. exponent for IS (XTI)
701  bool XTIgiven; // given for spice/hspice
702  bool PTgiven; // given for pspice
703 
704  double depCapCoeff; //coeff. for fwd bias depletion cap. (FC)
705  double fNCoeff; //flicker-noise coeff. (KF)
706  double fNExp; //flicker-noise exponent (AF)
707 
708  double rollOffExp; //Pspice high-current rolloff parameter (NK)
709  bool NKgiven; // spice/pspice
710  bool NKFgiven; // hspice
711 
712  double c2;
713  double c4;
714 
715  bool leakBECurrentGiven; // specified as ISE (spice)
716  bool JLEgiven; // hspice version of leakBECurrent
717  bool leakBCCurrentGiven; // specified as ISC (spice)
718  bool JLCgiven; // hspice version of leakBCCurrent
719 
720  bool c2Given;
721  bool c4Given;
723 
724  //generated model params
725  double invEarlyVoltF; //inverse of fwd early voltage
726  double invEarlyVoltR; //inverse of rvs early voltage
727  double invRollOffF; //inverse of fwd high curr. roll-off
728  double invRollOffR; //inverse of rvs high curr. roll-off
729  double collectorConduct; //collector conductance
730  double emitterConduct; //emitter conductance
731  double transTimeVBCFac; //VBC transit time factor
732  double excessPhaseFac; //excess phase factor
733 
734  double f2;
735  double f3;
736  double f6;
737  double f7;
738 };
739 
740 
741 //-----------------------------------------------------------------------------
742 // Class : Master
743 // Purpose :
744 // Special Notes :
745 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
746 // Creation Date : 11/26/08
747 //-----------------------------------------------------------------------------
748 class Master : public DeviceMaster<Traits>
749 {
750 public:
752  const Configuration & configuration,
753  const FactoryBlock & factory_block,
754  const SolverState & ss1,
755  const DeviceOptions & do1)
756  : DeviceMaster<Traits>(configuration, factory_block, ss1, do1)
757  {}
758 
759  virtual bool updateState (double * solVec, double * staVec, double * stoVec);
760  virtual bool updateSecondaryState (double * staDeriv, double * stoVec);
761 
762  // load functions, residual:
763  virtual bool loadDAEVectors (double * solVec, double * fVec, double * qVec, double * storeLeadF, double * storeLeadQ);
764 
765  // load functions, Jacobian:
766  virtual bool loadDAEMatrices (N_LAS_Matrix & dFdx, N_LAS_Matrix & dQdx);
767 
768  friend class Instance;
769  friend class Traits;
770  friend class Model;
771 };
772 
773 void registerDevice();
774 
775 } // namespace BJT
776 } // namespace Device
777 } // namespace Xyce
778 
782 
783 #endif