My Project  0.0.16
QUCS Mapping
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HBT_X.core.cpp
Go to the documentation of this file.
1 /*
2  * HBT_X.core.cpp - device implementations for HBT_X module
3  *
4  * This is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2, or (at your option)
7  * any later version.
8  *
9  */
10 
11 #if HAVE_CONFIG_H
12 #include <config.h>
13 #endif
14 
15 #include "HBT_X.analogfunction.h"
16 #include "component.h"
17 #include "device.h"
18 #include "HBT_X.core.h"
19 
20 #ifndef CIR_HBT_X
21 #define CIR_HBT_X -1
22 #endif
23 
24 // external nodes
25 #define c 0
26 #define b 1
27 #define e 2
28 #define t 3
29 // internal nodes
30 #define ei 4
31 #define bi 5
32 #define bii 6
33 #define ci 7
34 #define ex 8
35 #define exx 9
36 #define cx 10
37 #define ni 11
38 #define nii 12
39 #define niix 13
40 #define niii 14
41 #define niiix 15
42 #define niv 16
43 #define nivx 17
44 #define ti 18
45 
46 // useful macro definitions
47 #define NP(node) real (getV (node))
48 #define BP(pnode,nnode) (NP(pnode) - NP(nnode))
49 #define _load_static_residual2(pnode,nnode,current)\
50  _rhs[pnode] -= current;\
51  _rhs[nnode] += current;
52 #define _load_static_augmented_residual2(pnode,nnode,current)\
53  _rhs[pnode] -= current;\
54  _rhs[nnode] += current;
55 #define _load_static_residual1(node,current)\
56  _rhs[node] -= current;
57 #define _load_static_augmented_residual1(node,current)\
58  _rhs[node] -= current;
59 #define _load_static_jacobian4(pnode,nnode,vpnode,vnnode,conductance)\
60  _jstat[pnode][vpnode] += conductance;\
61  _jstat[nnode][vnnode] += conductance;\
62  _jstat[pnode][vnnode] -= conductance;\
63  _jstat[nnode][vpnode] -= conductance;\
64  if (doHB) {\
65  _ghs[pnode] += conductance * BP(vpnode,vnnode);\
66  _ghs[nnode] -= conductance * BP(vpnode,vnnode);\
67  } else {\
68  _rhs[pnode] += conductance * BP(vpnode,vnnode);\
69  _rhs[nnode] -= conductance * BP(vpnode,vnnode);\
70  }
71 #define _load_static_jacobian2p(node,vpnode,vnnode,conductance)\
72  _jstat[node][vpnode] += conductance;\
73  _jstat[node][vnnode] -= conductance;\
74  if (doHB) {\
75  _ghs[node] += conductance * BP(vpnode,vnnode);\
76  } else {\
77  _rhs[node] += conductance * BP(vpnode,vnnode);\
78  }
79 #define _load_static_jacobian2s(pnode,nnode,node,conductance)\
80  _jstat[pnode][node] += conductance;\
81  _jstat[nnode][node] -= conductance;\
82  if (doHB) {\
83  _ghs[pnode] += conductance * NP(node);\
84  _ghs[nnode] -= conductance * NP(node);\
85  } else {\
86  _rhs[pnode] += conductance * NP(node);\
87  _rhs[nnode] -= conductance * NP(node);\
88  }
89 #define _load_static_jacobian1(node,vnode,conductance)\
90  _jstat[node][vnode] += conductance;\
91  if (doHB) {\
92  _ghs[node] += conductance * NP(vnode);\
93  } else {\
94  _rhs[node] += conductance * NP(vnode);\
95  }
96 #define _load_dynamic_residual2(pnode,nnode,charge)\
97  if (doTR) _charges[pnode][nnode] += charge;\
98  if (doHB) {\
99  _qhs[pnode] -= charge;\
100  _qhs[nnode] += charge;\
101  }
102 #define _load_dynamic_residual1(node,charge)\
103  if (doTR) _charges[node][node] += charge;\
104  if (doHB) {\
105  _qhs[node] -= charge;\
106  }
107 #define _load_dynamic_jacobian4(pnode,nnode,vpnode,vnnode,capacitance)\
108  if (doAC) {\
109  _jdyna[pnode][vpnode] += capacitance;\
110  _jdyna[nnode][vnnode] += capacitance;\
111  _jdyna[pnode][vnnode] -= capacitance;\
112  _jdyna[nnode][vpnode] -= capacitance;\
113  }\
114  if (doTR) {\
115  _caps[pnode][nnode][vpnode][vnnode] += capacitance;\
116  }\
117  if (doHB) {\
118  _chs[pnode] += capacitance * BP(vpnode,vnnode);\
119  _chs[nnode] -= capacitance * BP(vpnode,vnnode);\
120  }
121 #define _load_dynamic_jacobian2s(pnode,nnode,vnode,capacitance)\
122  if (doAC) {\
123  _jdyna[pnode][vnode] += capacitance;\
124  _jdyna[nnode][vnode] -= capacitance;\
125  }\
126  if (doTR) {\
127  _caps[pnode][nnode][vnode][vnode] += capacitance;\
128  }\
129  if (doHB) {\
130  _chs[pnode] += capacitance * NP(vnode);\
131  _chs[nnode] -= capacitance * NP(vnode);\
132  }
133 #define _load_dynamic_jacobian2p(node,vpnode,vnnode,capacitance)\
134  if (doAC) {\
135  _jdyna[node][vpnode] += capacitance;\
136  _jdyna[node][vnnode] -= capacitance;\
137  }\
138  if (doTR) {\
139  _caps[node][node][vpnode][vnnode] += capacitance;\
140  }\
141  if (doHB) {\
142  _chs[node] += capacitance * BP(vpnode,vnnode);\
143  }
144 #define _load_dynamic_jacobian1(node,vnode,capacitance)\
145  if (doAC) {\
146  _jdyna[node][vnode] += capacitance;\
147  }\
148  if (doTR) {\
149  _caps[node][node][vnode][vnode] += capacitance;\
150  }\
151  if (doHB) {\
152  _chs[node] += capacitance * NP(vnode);\
153  }
154 
155 #define _save_whitenoise1(n1,pwr,type)\
156  _white_pwr[n1][n1] += pwr;
157 #define _save_whitenoise2(n1,n2,pwr,type)\
158  _white_pwr[n1][n2] += pwr;
159 #define _save_flickernoise1(n1,pwr,exp,type)\
160  _flicker_pwr[n1][n1] += pwr;\
161  _flicker_exp[n1][n1] += exp;
162 #define _save_flickernoise2(n1,n2,pwr,exp,type)\
163  _flicker_pwr[n1][n2] += pwr;\
164  _flicker_exp[n1][n2] += exp;
165 #define _load_whitenoise2(n1,n2,pwr)\
166  cy (n1,n2) -= pwr/kB/T0; cy (n2,n1) -= pwr/kB/T0;\
167  cy (n1,n1) += pwr/kB/T0; cy (n2,n2) += pwr/kB/T0;
168 #define _load_whitenoise1(n1,pwr)\
169  cy (n1,n1) += pwr/kB/T0;
170 #define _load_flickernoise2(n1,n2,pwr,exp)\
171  cy (n1,n2) -= pwr*pow(_freq,-exp)/kB/T0;\
172  cy (n2,n1) -= pwr*pow(_freq,-exp)/kB/T0;\
173  cy (n1,n1) += pwr*pow(_freq,-exp)/kB/T0;\
174  cy (n2,n2) += pwr*pow(_freq,-exp)/kB/T0;
175 #define _load_flickernoise1(n1,pwr,exp)\
176  cy (n1,n1) += pwr*pow(_freq,-exp)/kB/T0;
177 
178 // derivative helper macros
179 #define m00_hypot(v00,x,y) v00 = xhypot(x,y);
180 #define m10_hypot(v10,v00,x,y) v10 = (x)/(v00);
181 #define m11_hypot(v11,v00,x,y) v11 = (y)/(v00);
182 #define m00_max(v00,x,y) v00 = ((x)>(y))?(x):(y);
183 #define m10_max(v10,v00,x,y) v10 = ((x)>(y))?1.0:0.0;
184 #define m11_max(v11,v00,x,y) v11 = ((x)>(y))?0.0:1.0;
185 #define m00_min(v00,x,y) v00 = ((x)<(y))?(x):(y);
186 #define m10_min(v10,v00,x,y) v10 = ((x)<(y))?1.0:0.0;
187 #define m11_min(v11,v00,x,y) v11 = ((x)<(y))?0.0:1.0;
188 #define m00_pow(v00,x,y) v00 = pow(x,y);
189 #define m10_pow(v10,v00,x,y) v10 = (x==0.0)?0.0:(v00)*(y)/(x);
190 #define m11_pow(v11,v00,x,y) v11 = (x==0.0)?0.0:(log(x)*(v00));
191 
192 #define m00_div(v00,v10,x,y) double v10=1/(y); double v00=(x)*v10;
193 #define m10_div(v10,v00,vv,x,y)
194 #define m11_div(v11,v00,vv,x,y) double v11 = -v00*vv;
195 
196 #define m00_mult(v00,v10,v11,x,y) double v10=(x); double v11=(y); double v00=v10*v11;
197 #define m00_add(v00,x,y) double v00=(x)+(y);
198 
199 #define m00_cos(v00,x) v00 = cos(x);
200 #define m10_cos(v10,v00,x) v10 = (-sin(x));
201 #define m00_sin(v00,x) v00 = sin(x);
202 #define m10_sin(v10,v00,x) v10 = (cos(x));
203 #define m00_tan(v00,x) v00 = tan(x);
204 #define m10_tan(v10,v00,x) v10 = (1.0/cos(x)/cos(x));
205 #define m00_cosh(v00,x) v00 = cosh(x);
206 #define m10_cosh(v10,v00,x) v10 = (sinh(x));
207 #define m00_sinh(v00,x) v00 = sinh(x);
208 #define m10_sinh(v10,v00,x) v10 = (cosh(x));
209 #define m00_tanh(v00,x) v00 = tanh(x);
210 #define m10_tanh(v10,v00,x) v10 = (1.0/cosh(x)/cosh(x));
211 #define m00_acos(v00,x) v00 = acos(x);
212 #define m10_acos(v10,v00,x) v10 = (-1.0/sqrt(1-x*x));
213 #define m00_asin(v00,x) v00 = asin(x);
214 #define m10_asin(v10,v00,x) v10 = (+1.0/sqrt(1-x*x));
215 #define m00_atan(v00,x) v00 = atan(x);
216 #define m10_atan(v10,v00,x) v10 = (+1.0/(1+x*x));
217 #define m00_atanh(v00,x) v00 = atanh(x);
218 #define m10_atanh(v10,v00,x) v10 = (+1.0/(1-x*x));
219 #define m00_logE(v00,x) v00 = log(x);
220 #define m10_logE(v10,v00,x) v10 = (1.0/x);
221 #define m00_log10(v00,x) v00 = log10(x);
222 #define m10_log10(v10,v00,x) v10 = (1.0/x/M_LN10);
223 #define m00_sqrt(v00,x) v00 = sqrt(x);
224 #define m10_sqrt(v10,v00,x) v10 = (0.5/v00);
225 #define m00_fabs(v00,x) v00 = fabs(x);
226 #define m10_fabs(v10,v00,x) v10 = (((x)>=0)?(+1.0):(-1.0));
227 
228 #define m00_exp(v00,x) v00 = exp(x);
229 #define m10_exp(v10,v00,x) v10 = v00;
230 
231 #define m00_abs(v00) ((v00)<(0)?(-(v00)):(v00))
232 #define m00_floor(v00,x) v00 = floor(x);
233 #define m00_limexp(v00,x) v00 = ((x)<80.0?exp(x):exp(80.0)*(x-79.0));
234 #define m10_limexp(v10,v00,x) v10 = ((x)<80.0?(v00):exp(80.0));
235 
236 #define m20_logE(v00) (-1.0/v00/v00)
237 #define m20_exp(v00) exp(v00)
238 #define m20_limexp(v00) ((v00)<80.0?exp(v00):0.0)
239 #define m20_sqrt(v00) (-0.25/(v00)/sqrt(v00))
240 #define m20_fabs(v00) 0.0
241 #define m20_pow(x,y) ((y)*((y)-1.0)*pow(x,y)/(x)/(x))
242 #define m00_vt(x) (kBoverQ*(x))
243 #define m10_vt(x) (kBoverQ)
244 
245 // simulator specific definitions
246 #define _modelname "HBT_X"
247 #define _instancename getName()
248 #define _circuit_temp (getPropertyDouble("Temp")+273.15)
249 #define _param_given(p) (isPropertyGiven(p)?1:0)
250 
251 
252 // $vt and $vt() functions
253 #define _vt_nom (kBoverQ*_circuit_temp)
254 
255 using namespace device;
256 
257 /* Device constructor. */
258 HBT_X::HBT_X() : circuit (19)
259 {
260  type = CIR_HBT_X;
261 }
262 
263 /* Initialization of model. */
264 void HBT_X::initModel (void)
265 {
266  // create internal nodes
267  setInternalNode (ei, "ei");
268  setInternalNode (bi, "bi");
269  setInternalNode (bii, "bii");
270  setInternalNode (ci, "ci");
271  setInternalNode (ex, "ex");
272  setInternalNode (exx, "exx");
273  setInternalNode (cx, "cx");
274  setInternalNode (ni, "ni");
275  setInternalNode (nii, "nii");
276  setInternalNode (niix, "niix");
277  setInternalNode (niii, "niii");
278  setInternalNode (niiix, "niiix");
279  setInternalNode (niv, "niv");
280  setInternalNode (nivx, "nivx");
281  setInternalNode (ti, "ti");
282 
283  // get device model parameters
284  loadVariables ();
285  // evaluate global model equations
286  initializeModel ();
287  // evaluate initial step equations
288  initialStep ();
289  // evaluate global instance equations
290  initializeInstance ();
291 }
292 
293 /* Initialization of DC analysis. */
294 void HBT_X::initDC (void)
295 {
296  allocMatrixMNA ();
297  initModel ();
298  pol = 1;
299  restartDC ();
300  doAC = 1;
301  doTR = 0;
302  doHB = 0;
303 }
304 
305 /* Run when DC is restarted (fallback algorithms). */
306 void HBT_X::restartDC (void)
307 {
308 }
309 
310 /* Initialize Verilog-AMS code. */
311 void HBT_X::initVerilog (void)
312 {
313  // initialization of noise variables
314  _white_pwr[nii][nii] = 0.0;
315  _white_pwr[cx][bii] = 0.0;
316  _white_pwr[exx][bii] = 0.0;
317  _white_pwr[ex][bii] = 0.0;
318  _white_pwr[c][ci] = 0.0;
319  _white_pwr[e][ei] = 0.0;
320  _white_pwr[b][bi] = 0.0;
321  _white_pwr[bii][bi] = 0.0;
322  _white_pwr[ni][ni] = 0.0;
323  _white_pwr[bii][ei] = 0.0;
324  _flicker_pwr[niv][niv] = 0.0;
325  _flicker_exp[niv][niv] = 0.0;
326  _flicker_pwr[niii][niii] = 0.0;
327  _flicker_exp[niii][niii] = 0.0;
328 
329  int i1, i2, i3, i4;
330 
331  // zero charges
332  for (i1 = 0; i1 < 19; i1++) {
333  for (i2 = 0; i2 < 19; i2++) {
334  _charges[i1][i2] = 0.0;
335  } }
336 
337  // zero capacitances
338  for (i1 = 0; i1 < 19; i1++) {
339  for (i2 = 0; i2 < 19; i2++) {
340  for (i3 = 0; i3 < 19; i3++) {
341  for (i4 = 0; i4 < 19; i4++) {
342  _caps[i1][i2][i3][i4] = 0.0;
343  } } } }
344 
345  // zero right hand side, static and dynamic jacobian
346  for (i1 = 0; i1 < 19; i1++) {
347  _rhs[i1] = 0.0;
348  _qhs[i1] = 0.0;
349  _chs[i1] = 0.0;
350  _ghs[i1] = 0.0;
351  for (i2 = 0; i2 < 19; i2++) {
352  _jstat[i1][i2] = 0.0;
353  _jdyna[i1][i2] = 0.0;
354  }
355  }
356 }
357 
358 /* Load device model input parameters. */
359 void HBT_X::loadVariables (void)
360 {
361  Mode = getPropertyInteger ("Mode");
362  Noise = getPropertyInteger ("Noise");
363  Debug = getPropertyInteger ("Debug");
364  DebugPlus = getPropertyInteger ("DebugPlus");
365  Temp = getPropertyDouble ("Temp");
366  Rth = getPropertyDouble ("Rth");
367  Cth = getPropertyDouble ("Cth");
368  N = getPropertyInteger ("N");
369  L = getPropertyDouble ("L");
370  W = getPropertyDouble ("W");
371  Jsf = getPropertyDouble ("Jsf");
372  nf = getPropertyDouble ("nf");
373  Vg = getPropertyDouble ("Vg");
374  Jse = getPropertyDouble ("Jse");
375  ne = getPropertyDouble ("ne");
376  Rbxx = getPropertyDouble ("Rbxx");
377  Vgb = getPropertyDouble ("Vgb");
378  Jsee = getPropertyDouble ("Jsee");
379  nee = getPropertyDouble ("nee");
380  Rbbxx = getPropertyDouble ("Rbbxx");
381  Vgbb = getPropertyDouble ("Vgbb");
382  Jsr = getPropertyDouble ("Jsr");
383  nr = getPropertyDouble ("nr");
384  Vgr = getPropertyDouble ("Vgr");
385  XCjc = getPropertyDouble ("XCjc");
386  Jsc = getPropertyDouble ("Jsc");
387  nc = getPropertyDouble ("nc");
388  Rcxx = getPropertyDouble ("Rcxx");
389  Vgc = getPropertyDouble ("Vgc");
390  Bf = getPropertyDouble ("Bf");
391  kBeta = getPropertyDouble ("kBeta");
392  Br = getPropertyDouble ("Br");
393  VAF = getPropertyDouble ("VAF");
394  VAR = getPropertyDouble ("VAR");
395  IKF = getPropertyDouble ("IKF");
396  IKR = getPropertyDouble ("IKR");
397  Mc = getPropertyDouble ("Mc");
398  BVceo = getPropertyDouble ("BVceo");
399  kc = getPropertyDouble ("kc");
400  BVebo = getPropertyDouble ("BVebo");
401  Tr = getPropertyDouble ("Tr");
402  Trx = getPropertyDouble ("Trx");
403  Tf = getPropertyDouble ("Tf");
404  Tft = getPropertyDouble ("Tft");
405  Thcs = getPropertyDouble ("Thcs");
406  Ahc = getPropertyDouble ("Ahc");
407  Cje = getPropertyDouble ("Cje");
408  mje = getPropertyDouble ("mje");
409  Vje = getPropertyDouble ("Vje");
410  Cjc = getPropertyDouble ("Cjc");
411  mjc = getPropertyDouble ("mjc");
412  Vjc = getPropertyDouble ("Vjc");
413  kjc = getPropertyDouble ("kjc");
414  Cmin = getPropertyDouble ("Cmin");
415  J0 = getPropertyDouble ("J0");
416  XJ0 = getPropertyDouble ("XJ0");
417  Rci0 = getPropertyDouble ("Rci0");
418  Jk = getPropertyDouble ("Jk");
419  RJk = getPropertyDouble ("RJk");
420  Vces = getPropertyDouble ("Vces");
421  Rc = getPropertyDouble ("Rc");
422  Re = getPropertyDouble ("Re");
423  Rb = getPropertyDouble ("Rb");
424  Rb2 = getPropertyDouble ("Rb2");
425  Lc = getPropertyDouble ("Lc");
426  Le = getPropertyDouble ("Le");
427  Lb = getPropertyDouble ("Lb");
428  Cq = getPropertyDouble ("Cq");
429  Cpb = getPropertyDouble ("Cpb");
430  Cpc = getPropertyDouble ("Cpc");
431  Kfb = getPropertyDouble ("Kfb");
432  Afb = getPropertyDouble ("Afb");
433  Ffeb = getPropertyDouble ("Ffeb");
434  Kb = getPropertyDouble ("Kb");
435  Ab = getPropertyDouble ("Ab");
436  Fb = getPropertyDouble ("Fb");
437  Kfe = getPropertyDouble ("Kfe");
438  Afe = getPropertyDouble ("Afe");
439  Ffee = getPropertyDouble ("Ffee");
440  Tnom = getPropertyDouble ("Tnom");
441 }
442 
443 /* #define's for translated code */
444 #undef _DDT
445 #define _DDT(q) q
446 #define _DYNAMIC
447 #define _DERIVATE
448 #define _DDX
449 #define _DERIVATEFORDDX
450 
451 /* Evaluate Verilog-AMS equations in model initialization. */
452 void HBT_X::initializeModel (void)
453 {
454 }
455 
456 /* Evaluate Verilog-AMS equations in instance initialization. */
457 void HBT_X::initializeInstance (void)
458 {
459 }
460 
461 /* Evaluate Verilog-AMS equations in initial step. */
462 void HBT_X::initialStep (void)
463 {
464 }
465 
466 /* Evaluate Verilog-AMS equations in final step. */
467 void HBT_X::finalStep (void)
468 {
469 }
470 
471 /* Evaluate Verilog-AMS equations in analog block. */
472 void HBT_X::calcVerilog (void)
473 {
474 
475 /* ----------------- evaluate verilog analog equations -------------------- */
476 double Inivx;
477 #if defined(_DERIVATE)
478 double Inivx_Vbii_ei;
479 double Inivx_Tempti_GND;
480 double Inivx_Vbii_ci;
481 #endif
482 double Iniiix;
483 #if defined(_DERIVATE)
484 double Iniiix_Vbii_ei;
485 double Iniiix_Tempti_GND;
486 double Iniiix_Vbii_ci;
487 #endif
488 double Iniix;
489 #if defined(_DERIVATE)
490 double Iniix_Vbii_ei;
491 double Iniix_Tempti_GND;
492 double Iniix_Vbii_ci;
493 #endif
494 #if defined(_DYNAMIC)
495 double qbe;
496 #if defined(_DERIVATE)
497 double qbe_Vbii_ei;
498 double qbe_Tempti_GND;
499 double qbe_Vbii_ci;
500 double qbe_Vci_ei;
501 #endif
502 #endif
503 #if defined(_DYNAMIC)
504 double qbtf;
505 #if defined(_DERIVATE)
506 double qbtf_Tempti_GND;
507 double qbtf_Vbii_ei;
508 double qbtf_Vbii_ci;
509 #endif
510 #endif
511 #if defined(_DYNAMIC)
512 double xtff;
513 #if defined(_DERIVATE)
514 double xtff_Vbii_ei;
515 double xtff_Tempti_GND;
516 double xtff_Vbii_ci;
517 double xtff_Vci_ei;
518 #endif
519 #endif
520 #if defined(_DYNAMIC)
521 double Wh;
522 #if defined(_DERIVATE)
523 double Wh_Vci_ei;
524 double Wh_Vbii_ei;
525 double Wh_Tempti_GND;
526 double Wh_Vbii_ci;
527 #endif
528 #endif
529 #if defined(_DYNAMIC)
530 double Ih;
531 #if defined(_DERIVATE)
532 double Ih_Vci_ei;
533 double Ih_Vbii_ei;
534 double Ih_Tempti_GND;
535 double Ih_Vbii_ci;
536 #endif
537 #endif
538 #if defined(_DYNAMIC)
539 double AHC;
540 #endif
541 #if defined(_DYNAMIC)
542 double RCIO;
543 #endif
544 #if defined(_DYNAMIC)
545 double InvVpt;
546 #endif
547 #if defined(_DYNAMIC)
548 double Vlim;
549 #endif
550 #if defined(_DYNAMIC)
551 double qb2;
552 #if defined(_DERIVATE)
553 double qb2_Vbii_ei;
554 double qb2_Tempti_GND;
555 double qb2_Vbii_ci;
556 #endif
557 #endif
558 #if defined(_DYNAMIC)
559 double qbtra;
560 #if defined(_DERIVATE)
561 double qbtra_Vbi_ci;
562 double qbtra_Tempti_GND;
563 #endif
564 #endif
565 #if defined(_DYNAMIC)
566 double qbtr;
567 #if defined(_DERIVATE)
568 double qbtr_Vbii_ci;
569 double qbtr_Tempti_GND;
570 double qbtr_Vbii_ei;
571 #endif
572 #endif
573 #if defined(_DYNAMIC)
574 double qb1;
575 #if defined(_DERIVATE)
576 double qb1_Vbi_ci;
577 #endif
578 #endif
579 #if defined(_DYNAMIC)
580 double xix;
581 #if defined(_DERIVATE)
582 double xix_Vbii_ei;
583 double xix_Tempti_GND;
584 double xix_Vbii_ci;
585 #endif
586 #endif
587 #if defined(_DYNAMIC)
588 double qb2med;
589 #if defined(_DERIVATE)
590 double qb2med_Vbii_ei;
591 double qb2med_Tempti_GND;
592 double qb2med_Vbii_ci;
593 #endif
594 #endif
595 #if defined(_DYNAMIC)
596 double I00;
597 #endif
598 double Ipdiss;
599 #if defined(_DERIVATE)
600 double Ipdiss_Vbii_ei;
601 double Ipdiss_Tempti_GND;
602 double Ipdiss_Vbii_ci;
603 double Ipdiss_Vci_ei;
604 double Ipdiss_Vbi_ci;
605 #endif
606 double Icdx;
607 #if defined(_DERIVATE)
608 double Icdx_Vcx_ci;
609 double Icdx_Tempti_GND;
610 #endif
611 double Ibdxx;
612 #if defined(_DERIVATE)
613 double Ibdxx_Vexx_ei;
614 double Ibdxx_Tempti_GND;
615 #endif
616 double Ibdx;
617 #if defined(_DERIVATE)
618 double Ibdx_Vex_ei;
619 double Ibdx_Tempti_GND;
620 #endif
621 double Ib1;
622 #if defined(_DERIVATE)
623 double Ib1_Vbii_ei;
624 double Ib1_Tempti_GND;
625 double Ib1_Vbii_ci;
626 #endif
627 double Ib0;
628 #if defined(_DERIVATE)
629 double Ib0_Vbii_ei;
630 double Ib0_Tempti_GND;
631 double Ib0_Vbii_ci;
632 #endif
633 double EdBeta;
634 #if defined(_DERIVATE)
635 double EdBeta_Tempti_GND;
636 double EdBeta_Vbii_ci;
637 #endif
638 double mm;
639 #if defined(_DERIVATE)
640 double mm_Vbii_ci;
641 #endif
642 double Vbclin;
643 double epsi;
644 double Ibx;
645 #if defined(_DERIVATE)
646 double Ibx_Vbi_ci;
647 double Ibx_Tempti_GND;
648 #endif
649 double Ib2;
650 #if defined(_DERIVATE)
651 double Ib2_Vbii_ci;
652 double Ib2_Tempti_GND;
653 #endif
654 double Ic1;
655 #if defined(_DERIVATE)
656 double Ic1_Vbii_ei;
657 double Ic1_Tempti_GND;
658 double Ic1_Vbii_ci;
659 #endif
660 double Ic1r;
661 #if defined(_DERIVATE)
662 double Ic1r_Vbii_ci;
663 double Ic1r_Tempti_GND;
664 double Ic1r_Vbii_ei;
665 #endif
666 double Ic0;
667 #if defined(_DERIVATE)
668 double Ic0_Vbii_ei;
669 double Ic0_Tempti_GND;
670 double Ic0_Vbii_ci;
671 #endif
672 double qb;
673 #if defined(_DERIVATE)
674 double qb_Vbii_ei;
675 double qb_Vbii_ci;
676 double qb_Tempti_GND;
677 #endif
678 double q2;
679 #if defined(_DERIVATE)
680 double q2_Vbii_ei;
681 double q2_Tempti_GND;
682 double q2_Vbii_ci;
683 #endif
684 double q1;
685 #if defined(_DERIVATE)
686 double q1_Vbii_ei;
687 double q1_Vbii_ci;
688 #endif
689 double Ic1ra;
690 #if defined(_DERIVATE)
691 double Ic1ra_Vbii_ci;
692 double Ic1ra_Tempti_GND;
693 #endif
694 double Ic0a;
695 #if defined(_DERIVATE)
696 double Ic0a_Vbii_ei;
697 double Ic0a_Tempti_GND;
698 #endif
699 double TWO_Q;
700 double FOUR_K;
701 double Area;
702 double Tex;
703 #if defined(_DERIVATE)
704 double Tex_Tempti_GND;
705 #endif
706 double TjK;
707 #if defined(_DERIVATE)
708 double TjK_Tempti_GND;
709 #endif
710 double Tj;
711 #if defined(_DERIVATE)
712 double Tj_Tempti_GND;
713 #endif
714 double Texi;
715 #if defined(_DERIVATE)
716 double Texi_Tempti_GND;
717 #endif
718 double vcei;
719 #if defined(_DERIVATE)
720 double vcei_Vci_ei;
721 #endif
722 double vxxe;
723 #if defined(_DERIVATE)
724 double vxxe_Vexx_ei;
725 #endif
726 double vxc;
727 #if defined(_DERIVATE)
728 double vxc_Vcx_ci;
729 #endif
730 double vxe;
731 #if defined(_DERIVATE)
732 double vxe_Vex_ei;
733 #endif
734 double vbei;
735 #if defined(_DERIVATE)
736 double vbei_Vbii_ei;
737 #endif
738 double vbci;
739 #if defined(_DERIVATE)
740 double vbci_Vbii_ci;
741 #endif
742 double vbcx;
743 #if defined(_DERIVATE)
744 double vbcx_Vbi_ci;
745 #endif
746 #if defined(_DERIVATE)
747 vbcx_Vbi_ci=1.0;
748 #endif
749 vbcx=BP(bi,ci);
750 #if defined(_DERIVATE)
751 vbci_Vbii_ci=1.0;
752 #endif
753 vbci=BP(bii,ci);
754 #if defined(_DERIVATE)
755 vbei_Vbii_ei=1.0;
756 #endif
757 vbei=BP(bii,ei);
758 #if defined(_DERIVATE)
759 vxe_Vex_ei=1.0;
760 #endif
761 vxe=BP(ex,ei);
762 #if defined(_DERIVATE)
763 vxc_Vcx_ci=1.0;
764 #endif
765 vxc=BP(cx,ci);
766 #if defined(_DERIVATE)
767 vxxe_Vexx_ei=1.0;
768 #endif
769 vxxe=BP(exx,ei);
770 #if defined(_DERIVATE)
771 vcei_Vci_ei=1.0;
772 #endif
773 vcei=BP(ci,ei);
774 #if defined(_DERIVATE)
775 Texi_Tempti_GND=1.0;
776 #endif
777 Texi=NP(ti);
778 #if defined(_DERIVATE)
779 Tj_Tempti_GND=Texi_Tempti_GND;
780 #endif
781 Tj=(Texi+Temp);
782 #if defined(_DERIVATE)
783 TjK_Tempti_GND=Tj_Tempti_GND;
784 #endif
785 TjK=(Tj+273.15);
786 #if defined(_DERIVATE)
787 Tex_Tempti_GND=Tj_Tempti_GND;
788 #endif
789 Tex=(Tj-Tnom);
790 Area=(((L*W)*1.0e12)*N);
791 FOUR_K=(4*1.3806226e-23);
792 TWO_Q=(2*1.6021918e-19);
793 #if defined(_DERIVATE)
794 Ic0a_Vbii_ei=HBT_X_d_diode(vbei,Jsf,Vg,nf,Area,Tj,Tnom,vbei_Vbii_ei,0.0,0.0,0.0,0.0,0.0,0.0);
795 Ic0a_Tempti_GND=HBT_X_d_diode(vbei,Jsf,Vg,nf,Area,Tj,Tnom,0.0,0.0,0.0,0.0,0.0,Tj_Tempti_GND,0.0);
796 #endif
797 Ic0a=HBT_X_diode(vbei,Jsf,Vg,nf,Area,Tj,Tnom);
798 #if defined(_DERIVATE)
799 Ic1ra_Vbii_ci=HBT_X_d_diode(vbci,(XCjc*Jsr),Vgr,nr,Area,Tj,Tnom,vbci_Vbii_ci,0.0,0.0,0.0,0.0,0.0,0.0);
800 Ic1ra_Tempti_GND=HBT_X_d_diode(vbci,(XCjc*Jsr),Vgr,nr,Area,Tj,Tnom,0.0,0.0,0.0,0.0,0.0,Tj_Tempti_GND,0.0);
801 #endif
802 Ic1ra=HBT_X_diode(vbci,(XCjc*Jsr),Vgr,nr,Area,Tj,Tnom);
803 if
804 (((VAF>0.0)&&(VAR>0.0)))
805 {
806 #if defined(_DERIVATE)
807 q1_Vbii_ei=(((HBT_X_d_charge(vbei,1.0,Vje,mje,1.0,vbei_Vbii_ei,0.0,0.0,0.0,0.0)-HBT_X_d_charge(0.0,1.0,Vje,mje,1.0,0.0,0.0,0.0,0.0,0.0))/VAR)+((HBT_X_d_charge(vbci,1.0,Vjc,mjc,1.0,0.0,0.0,0.0,0.0,0.0)-HBT_X_d_charge(0.0,1.0,Vjc,mjc,1.0,0.0,0.0,0.0,0.0,0.0))/VAF));
808 q1_Vbii_ci=(((HBT_X_d_charge(vbei,1.0,Vje,mje,1.0,0.0,0.0,0.0,0.0,0.0)-HBT_X_d_charge(0.0,1.0,Vje,mje,1.0,0.0,0.0,0.0,0.0,0.0))/VAR)+((HBT_X_d_charge(vbci,1.0,Vjc,mjc,1.0,vbci_Vbii_ci,0.0,0.0,0.0,0.0)-HBT_X_d_charge(0.0,1.0,Vjc,mjc,1.0,0.0,0.0,0.0,0.0,0.0))/VAF));
809 #endif
810 q1=((1.0+((HBT_X_charge(vbei,1.0,Vje,mje,1.0)-HBT_X_charge(0.0,1.0,Vje,mje,1.0))/VAR))+((HBT_X_charge(vbci,1.0,Vjc,mjc,1.0)-HBT_X_charge(0.0,1.0,Vjc,mjc,1.0))/VAF));
811 }
812 else
813 {
814 if
815 (((VAF>0.0)&&(VAR==0.0)))
816 {
817 #if defined(_DERIVATE)
818 q1_Vbii_ei=0.0;
819 q1_Vbii_ci=((HBT_X_d_charge(vbci,1.0,Vjc,mjc,1.0,vbci_Vbii_ci,0.0,0.0,0.0,0.0)-HBT_X_d_charge(0.0,1.0,Vjc,mjc,1.0,0.0,0.0,0.0,0.0,0.0))/VAF);
820 #endif
821 q1=(1.0+((HBT_X_charge(vbci,1.0,Vjc,mjc,1.0)-HBT_X_charge(0.0,1.0,Vjc,mjc,1.0))/VAF));
822 }
823 else
824 {
825 if
826 (((VAF==0.0)&&(VAR>0.0)))
827 {
828 #if defined(_DERIVATE)
829 q1_Vbii_ei=((HBT_X_d_charge(vbei,1.0,Vje,mje,1.0,vbei_Vbii_ei,0.0,0.0,0.0,0.0)-HBT_X_d_charge(0.0,1.0,Vje,mje,1.0,0.0,0.0,0.0,0.0,0.0))/VAR);
830 q1_Vbii_ci=0.0;
831 #endif
832 q1=(1.0+((HBT_X_charge(vbei,1.0,Vje,mje,1.0)-HBT_X_charge(0.0,1.0,Vje,mje,1.0))/VAR));
833 }
834 else
835 {
836 #if defined(_DERIVATE)
837 q1_Vbii_ei=0.0;
838 q1_Vbii_ci=0.0;
839 #endif
840 q1=1.0;
841 }
842 }
843 }
844 if
845 (((IKF>0.0)&&(IKR>0.0)))
846 {
847 #if defined(_DERIVATE)
848 q2_Vbii_ei=(Ic0a_Vbii_ei/(Area*IKF));
849 q2_Tempti_GND=((Ic0a_Tempti_GND/(Area*IKF))+(Ic1ra_Tempti_GND/(Area*IKR)));
850 q2_Vbii_ci=(Ic1ra_Vbii_ci/(Area*IKR));
851 #endif
852 q2=((Ic0a/(Area*IKF))+(Ic1ra/(Area*IKR)));
853 }
854 else
855 {
856 if
857 (((IKF>0.0)&&(IKR==0.0)))
858 {
859 #if defined(_DERIVATE)
860 q2_Vbii_ei=(Ic0a_Vbii_ei/(Area*IKF));
861 q2_Tempti_GND=(Ic0a_Tempti_GND/(Area*IKF));
862 q2_Vbii_ci=0.0;
863 #endif
864 q2=(Ic0a/(Area*IKF));
865 }
866 else
867 {
868 if
869 (((IKF==0.0)&&(IKR>0.0)))
870 {
871 #if defined(_DERIVATE)
872 q2_Vbii_ei=0.0;
873 q2_Tempti_GND=(Ic1ra_Tempti_GND/(Area*IKR));
874 q2_Vbii_ci=(Ic1ra_Vbii_ci/(Area*IKR));
875 #endif
876 q2=(Ic1ra/(Area*IKR));
877 }
878 else
879 {
880 #if defined(_DERIVATE)
881 q2_Vbii_ei=0.0;
882 q2_Tempti_GND=0.0;
883 q2_Vbii_ci=0.0;
884 #endif
885 q2=0.0;
886 }
887 }
888 }
889 {
890 double m00_sqrt(d00_sqrt0,((q1*q1)+(4.0*q2)))
891 #if defined(_DERIVATE)
892 double m10_sqrt(d10_sqrt0,d00_sqrt0,((q1*q1)+(4.0*q2)))
893 #endif
894 #if defined(_DERIVATE)
895 qb_Vbii_ei=((q1_Vbii_ei+(((q1_Vbii_ei*q1)+(q1*q1_Vbii_ei))+(4.0*q2_Vbii_ei))*d10_sqrt0)/2.0);
896 qb_Vbii_ci=((q1_Vbii_ci+(((q1_Vbii_ci*q1)+(q1*q1_Vbii_ci))+(4.0*q2_Vbii_ci))*d10_sqrt0)/2.0);
897 qb_Tempti_GND=((4.0*q2_Tempti_GND)*d10_sqrt0/2.0);
898 #endif
899 qb=((q1+d00_sqrt0)/2.0);
900 }
901 #if defined(_DERIVATE)
902 Ic0_Vbii_ei=((Ic0a_Vbii_ei*qb-Ic0a*qb_Vbii_ei)/qb/qb);
903 Ic0_Tempti_GND=((Ic0a_Tempti_GND*qb-Ic0a*qb_Tempti_GND)/qb/qb);
904 Ic0_Vbii_ci=(-Ic0a*qb_Vbii_ci/qb/qb);
905 #endif
906 Ic0=(Ic0a/qb);
907 #if defined(_DERIVATE)
908 Ic1r_Vbii_ci=((Ic1ra_Vbii_ci*qb-Ic1ra*qb_Vbii_ci)/qb/qb);
909 Ic1r_Tempti_GND=((Ic1ra_Tempti_GND*qb-Ic1ra*qb_Tempti_GND)/qb/qb);
910 Ic1r_Vbii_ei=(-Ic1ra*qb_Vbii_ei/qb/qb);
911 #endif
912 Ic1r=(Ic1ra/qb);
913 #if defined(_DERIVATE)
914 Ic1_Vbii_ei=(Ic0_Vbii_ei-Ic1r_Vbii_ei);
915 Ic1_Tempti_GND=(Ic0_Tempti_GND-Ic1r_Tempti_GND);
916 Ic1_Vbii_ci=(Ic0_Vbii_ci-Ic1r_Vbii_ci);
917 #endif
918 Ic1=(Ic0-Ic1r);
919 #if defined(_DERIVATE)
920 Ib2_Vbii_ci=(HBT_X_d_diode(vbci,(XCjc*Jsr),Vgr,nr,Area,Tj,Tnom,vbci_Vbii_ci,0.0,0.0,0.0,0.0,0.0,0.0)/Br);
921 Ib2_Tempti_GND=(HBT_X_d_diode(vbci,(XCjc*Jsr),Vgr,nr,Area,Tj,Tnom,0.0,0.0,0.0,0.0,0.0,Tj_Tempti_GND,0.0)/Br);
922 #endif
923 Ib2=(HBT_X_diode(vbci,(XCjc*Jsr),Vgr,nr,Area,Tj,Tnom)/Br);
924 #if defined(_DERIVATE)
925 Ibx_Vbi_ci=(HBT_X_d_diode(vbcx,((1.0-XCjc)*Jsr),Vgr,nr,Area,Tj,Tnom,vbcx_Vbi_ci,0.0,0.0,0.0,0.0,0.0,0.0)/Br);
926 Ibx_Tempti_GND=(HBT_X_d_diode(vbcx,((1.0-XCjc)*Jsr),Vgr,nr,Area,Tj,Tnom,0.0,0.0,0.0,0.0,0.0,Tj_Tempti_GND,0.0)/Br);
927 #endif
928 Ibx=(HBT_X_diode(vbcx,((1.0-XCjc)*Jsr),Vgr,nr,Area,Tj,Tnom)/Br);
929 epsi=1.0e-6;
930 {
931 double m00_pow(d00_pow0,(1.0-epsi),(1/Mc))
932 Vbclin=(BVceo*d00_pow0);
933 }
934 #if defined(_DERIVATE)
935 mm_Vbii_ci=HBT_X_d_MM(vbci,BVceo,Mc,Vbclin,Bf,kc,vbci_Vbii_ci,0.0,0.0,0.0,0.0,0.0);
936 #endif
937 mm=HBT_X_MM(vbci,BVceo,Mc,Vbclin,Bf,kc);
938 if
939 ((mm>1.0))
940 {
941 if
942 ((kBeta>0.0))
943 {
944 if
945 (((Bf-(kBeta*Tex))>1e-6))
946 {
947 #if defined(_DERIVATE)
948 EdBeta_Tempti_GND=((-1*(-(kBeta*Tex_Tempti_GND))/(Bf-(kBeta*Tex))/(Bf-(kBeta*Tex)))/((kc*(mm-1))+1));
949 EdBeta_Vbii_ci=(((-(kc*mm_Vbii_ci))*((kc*(mm-1))+1)-((1/(Bf-(kBeta*Tex)))-(kc*(mm-1)))*(kc*mm_Vbii_ci))/((kc*(mm-1))+1)/((kc*(mm-1))+1));
950 #endif
951 EdBeta=(((1/(Bf-(kBeta*Tex)))-(kc*(mm-1)))/((kc*(mm-1))+1));
952 }
953 else
954 {
955 #if defined(_DERIVATE)
956 EdBeta_Tempti_GND=0.0;
957 EdBeta_Vbii_ci=(((-(kc*mm_Vbii_ci))*((kc*(mm-1))+1)-(1e6-(kc*(mm-1)))*(kc*mm_Vbii_ci))/((kc*(mm-1))+1)/((kc*(mm-1))+1));
958 #endif
959 EdBeta=((1e6-(kc*(mm-1)))/((kc*(mm-1))+1));
960 }
961 }
962 else
963 {
964 #if defined(_DERIVATE)
965 EdBeta_Tempti_GND=0.0;
966 EdBeta_Vbii_ci=(((-(kc*mm_Vbii_ci))*((kc*(mm-1))+1)-((1/Bf)-(kc*(mm-1)))*(kc*mm_Vbii_ci))/((kc*(mm-1))+1)/((kc*(mm-1))+1));
967 #endif
968 EdBeta=(((1/Bf)-(kc*(mm-1)))/((kc*(mm-1))+1));
969 }
970 }
971 else
972 {
973 if
974 ((kBeta>0.0))
975 {
976 if
977 (((Bf-(kBeta*Tex))>1e-6))
978 {
979 #if defined(_DERIVATE)
980 EdBeta_Tempti_GND=(-1*(-(kBeta*Tex_Tempti_GND))/(Bf-(kBeta*Tex))/(Bf-(kBeta*Tex)));
981 EdBeta_Vbii_ci=0.0;
982 #endif
983 EdBeta=(1/(Bf-(kBeta*Tex)));
984 }
985 else
986 {
987 #if defined(_DERIVATE)
988 EdBeta_Tempti_GND=0.0;
989 EdBeta_Vbii_ci=0.0;
990 #endif
991 EdBeta=1e6;
992 }
993 }
994 else
995 {
996 #if defined(_DERIVATE)
997 EdBeta_Tempti_GND=0.0;
998 EdBeta_Vbii_ci=0.0;
999 #endif
1000 EdBeta=(1/Bf);
1001 }
1002 }
1003 #if defined(_DERIVATE)
1004 Ib0_Vbii_ei=Ic0a_Vbii_ei*EdBeta;
1005 Ib0_Tempti_GND=((Ic0a_Tempti_GND*EdBeta)+(Ic0a*EdBeta_Tempti_GND));
1006 Ib0_Vbii_ci=(Ic0a*EdBeta_Vbii_ci);
1007 #endif
1008 Ib0=(Ic0a*EdBeta);
1009 if
1010 ((BVebo>0))
1011 {
1012 #if defined(_DERIVATE)
1013 Ib1_Vbii_ei=(Ib0_Vbii_ei-HBT_X_d_diode(((-BVebo)-vbei),Jsf,0.0,1.0,Area,0.0,0.0,(-vbei_Vbii_ei),0.0,0.0,0.0,0.0,0.0,0.0));
1014 Ib1_Tempti_GND=(Ib0_Tempti_GND-HBT_X_d_diode(((-BVebo)-vbei),Jsf,0.0,1.0,Area,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0));
1015 Ib1_Vbii_ci=(Ib0_Vbii_ci-HBT_X_d_diode(((-BVebo)-vbei),Jsf,0.0,1.0,Area,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0));
1016 #endif
1017 Ib1=(Ib0-HBT_X_diode(((-BVebo)-vbei),Jsf,0.0,1.0,Area,0.0,0.0));
1018 }
1019 else
1020 {
1021 #if defined(_DERIVATE)
1022 Ib1_Vbii_ei=Ib0_Vbii_ei;
1023 Ib1_Tempti_GND=Ib0_Tempti_GND;
1024 Ib1_Vbii_ci=Ib0_Vbii_ci;
1025 #endif
1026 Ib1=Ib0;
1027 }
1028 if
1029 (((Jse>0.0)&&(ne>0)))
1030 {
1031 #if defined(_DERIVATE)
1032 Ibdx_Vex_ei=HBT_X_d_diode(vxe,Jse,Vgb,ne,Area,Tj,Tnom,vxe_Vex_ei,0.0,0.0,0.0,0.0,0.0,0.0);
1033 Ibdx_Tempti_GND=HBT_X_d_diode(vxe,Jse,Vgb,ne,Area,Tj,Tnom,0.0,0.0,0.0,0.0,0.0,Tj_Tempti_GND,0.0);
1034 #endif
1035 Ibdx=HBT_X_diode(vxe,Jse,Vgb,ne,Area,Tj,Tnom);
1036 }
1037 else
1038 {
1039 #if defined(_DERIVATE)
1040 Ibdx_Vex_ei=vxe_Vex_ei*1e-12;
1041 Ibdx_Tempti_GND=0.0;
1042 #endif
1043 Ibdx=(vxe*1e-12);
1044 }
1045 if
1046 (((Jsee>0.0)&&(nee>0)))
1047 {
1048 #if defined(_DERIVATE)
1049 Ibdxx_Vexx_ei=HBT_X_d_diode(vxxe,Jsee,Vgbb,nee,Area,Tj,Tnom,vxxe_Vexx_ei,0.0,0.0,0.0,0.0,0.0,0.0);
1050 Ibdxx_Tempti_GND=HBT_X_d_diode(vxxe,Jsee,Vgbb,nee,Area,Tj,Tnom,0.0,0.0,0.0,0.0,0.0,Tj_Tempti_GND,0.0);
1051 #endif
1052 Ibdxx=HBT_X_diode(vxxe,Jsee,Vgbb,nee,Area,Tj,Tnom);
1053 }
1054 else
1055 {
1056 #if defined(_DERIVATE)
1057 Ibdxx_Vexx_ei=vxxe_Vexx_ei*1e-12;
1058 Ibdxx_Tempti_GND=0.0;
1059 #endif
1060 Ibdxx=(vxxe*1e-12);
1061 }
1062 if
1063 (((Jsc>0.0)&&(nc>0)))
1064 {
1065 #if defined(_DERIVATE)
1066 Icdx_Vcx_ci=HBT_X_d_diode(vxc,Jsc,Vgc,nc,Area,Tj,Tnom,vxc_Vcx_ci,0.0,0.0,0.0,0.0,0.0,0.0);
1067 Icdx_Tempti_GND=HBT_X_d_diode(vxc,Jsc,Vgc,nc,Area,Tj,Tnom,0.0,0.0,0.0,0.0,0.0,Tj_Tempti_GND,0.0);
1068 #endif
1069 Icdx=HBT_X_diode(vxc,Jsc,Vgc,nc,Area,Tj,Tnom);
1070 }
1071 else
1072 {
1073 #if defined(_DERIVATE)
1074 Icdx_Vcx_ci=vxc_Vcx_ci*1e-12;
1075 Icdx_Tempti_GND=0.0;
1076 #endif
1077 Icdx=(vxc*1e-12);
1078 }
1079 #if defined(_DERIVATE)
1080 Ipdiss_Vbii_ei=(Ic1_Vbii_ei*vcei+((Ib1_Vbii_ei*vbei)+(Ib1*vbei_Vbii_ei)));
1081 Ipdiss_Tempti_GND=(((Ic1_Tempti_GND*vcei+Ib1_Tempti_GND*vbei)+Ib2_Tempti_GND*vbci)+Ibx_Tempti_GND*vbcx);
1082 Ipdiss_Vbii_ci=((Ic1_Vbii_ci*vcei+Ib1_Vbii_ci*vbei)+((Ib2_Vbii_ci*vbci)+(Ib2*vbci_Vbii_ci)));
1083 Ipdiss_Vci_ei=(Ic1*vcei_Vci_ei);
1084 Ipdiss_Vbi_ci=((Ibx_Vbi_ci*vbcx)+(Ibx*vbcx_Vbi_ci));
1085 #endif
1086 Ipdiss=((((Ic1*vcei)+(Ib1*vbei))+(Ib2*vbci))+(Ibx*vbcx));
1087 if
1088 ((Ipdiss<0.0))
1089 {
1090 #if defined(_DERIVATE)
1091 Ipdiss_Vbii_ei=0.0;
1092 Ipdiss_Tempti_GND=0.0;
1093 Ipdiss_Vbii_ci=0.0;
1094 Ipdiss_Vci_ei=0.0;
1095 Ipdiss_Vbi_ci=0.0;
1096 #endif
1097 Ipdiss=0;
1098 }
1099 #if defined(_DYNAMIC)
1100 I00=(J0*Area);
1101 #endif
1102 #ifdef _DYNAMIC
1103 if
1104 (((XCjc<1.0)&&(XCjc>0.0)))
1105 {
1106 #ifdef _DYNAMIC
1107 if
1108 (((J0<=0.0)||(Ic0<0.0)))
1109 {
1110 #if defined(_DYNAMIC)
1111 #if defined(_DERIVATE)
1112 qb2med_Vbii_ei=0.0;
1113 qb2med_Tempti_GND=0.0;
1114 qb2med_Vbii_ci=((XCjc*HBT_X_d_charge(vbci,(Cjc-Cmin),Vjc,mjc,Area,vbci_Vbii_ci,0.0,0.0,0.0,0.0))+(((XCjc*Area)*Cmin)*vbci_Vbii_ci));
1115 #endif
1116 qb2med=((XCjc*HBT_X_charge(vbci,(Cjc-Cmin),Vjc,mjc,Area))+(((XCjc*Area)*Cmin)*vbci));
1117 #endif
1118 }
1119 else
1120 {
1121 #if defined(_DYNAMIC)
1122 #if defined(_DERIVATE)
1123 xix_Vbii_ei=(Ic0_Vbii_ei/I00);
1124 xix_Tempti_GND=(Ic0_Tempti_GND/I00);
1125 xix_Vbii_ci=(Ic0_Vbii_ci/I00);
1126 #endif
1127 xix=(Ic0/I00);
1128 #endif
1129 #if defined(_DYNAMIC)
1130 {
1131 double m00_tanh(d00_tanh0,xix)
1132 #if defined(_DERIVATE)
1133 double m10_tanh(d10_tanh0,d00_tanh0,xix)
1134 #endif
1135 #if defined(_DERIVATE)
1136 qb2med_Vbii_ei=(((XCjc*(-xix_Vbii_ei*d10_tanh0))*(HBT_X_charge(vbci,(Cjc-Cmin),Vjc,mjc,Area)+((((1.0-XJ0)*Area)*Cmin)*vbci)))+((XCjc*(1.0-d00_tanh0))*HBT_X_d_charge(vbci,(Cjc-Cmin),Vjc,mjc,Area,0.0,0.0,0.0,0.0,0.0)));
1137 qb2med_Tempti_GND=(((XCjc*(-xix_Tempti_GND*d10_tanh0))*(HBT_X_charge(vbci,(Cjc-Cmin),Vjc,mjc,Area)+((((1.0-XJ0)*Area)*Cmin)*vbci)))+((XCjc*(1.0-d00_tanh0))*HBT_X_d_charge(vbci,(Cjc-Cmin),Vjc,mjc,Area,0.0,0.0,0.0,0.0,0.0)));
1138 qb2med_Vbii_ci=((((XCjc*(-xix_Vbii_ci*d10_tanh0))*(HBT_X_charge(vbci,(Cjc-Cmin),Vjc,mjc,Area)+((((1.0-XJ0)*Area)*Cmin)*vbci)))+((XCjc*(1.0-d00_tanh0))*(HBT_X_d_charge(vbci,(Cjc-Cmin),Vjc,mjc,Area,vbci_Vbii_ci,0.0,0.0,0.0,0.0)+((((1.0-XJ0)*Area)*Cmin)*vbci_Vbii_ci))))+((((XJ0*XCjc)*Area)*Cmin)*vbci_Vbii_ci));
1139 #endif
1140 qb2med=(((XCjc*(1.0-d00_tanh0))*(HBT_X_charge(vbci,(Cjc-Cmin),Vjc,mjc,Area)+((((1.0-XJ0)*Area)*Cmin)*vbci)))+((((XJ0*XCjc)*Area)*Cmin)*vbci));
1141 }
1142 #endif
1143 }
1144 #endif /* if (...) */
1145 }
1146 else
1147 {
1148 #ifdef _DYNAMIC
1149 if
1150 (((J0<0.0)||(Ic0<0.0)))
1151 {
1152 #if defined(_DYNAMIC)
1153 #if defined(_DERIVATE)
1154 qb2med_Vbii_ei=0.0;
1155 qb2med_Tempti_GND=0.0;
1156 qb2med_Vbii_ci=(HBT_X_d_charge(vbci,(Cjc-Cmin),Vjc,mjc,Area,vbci_Vbii_ci,0.0,0.0,0.0,0.0)+((Area*Cmin)*vbci_Vbii_ci));
1157 #endif
1158 qb2med=(HBT_X_charge(vbci,(Cjc-Cmin),Vjc,mjc,Area)+((Area*Cmin)*vbci));
1159 #endif
1160 }
1161 else
1162 {
1163 #if defined(_DYNAMIC)
1164 #if defined(_DERIVATE)
1165 xix_Vbii_ei=(Ic0_Vbii_ei/I00);
1166 xix_Tempti_GND=(Ic0_Tempti_GND/I00);
1167 xix_Vbii_ci=(Ic0_Vbii_ci/I00);
1168 #endif
1169 xix=(Ic0/I00);
1170 #endif
1171 #if defined(_DYNAMIC)
1172 {
1173 double m00_tanh(d00_tanh0,xix)
1174 #if defined(_DERIVATE)
1175 double m10_tanh(d10_tanh0,d00_tanh0,xix)
1176 #endif
1177 #if defined(_DERIVATE)
1178 qb2med_Vbii_ei=(((-xix_Vbii_ei*d10_tanh0)*(HBT_X_charge(vbci,(Cjc-Cmin),Vjc,mjc,Area)+((((1.0-XJ0)*Area)*Cmin)*vbci)))+((1.0-d00_tanh0)*HBT_X_d_charge(vbci,(Cjc-Cmin),Vjc,mjc,Area,0.0,0.0,0.0,0.0,0.0)));
1179 qb2med_Tempti_GND=(((-xix_Tempti_GND*d10_tanh0)*(HBT_X_charge(vbci,(Cjc-Cmin),Vjc,mjc,Area)+((((1.0-XJ0)*Area)*Cmin)*vbci)))+((1.0-d00_tanh0)*HBT_X_d_charge(vbci,(Cjc-Cmin),Vjc,mjc,Area,0.0,0.0,0.0,0.0,0.0)));
1180 qb2med_Vbii_ci=((((-xix_Vbii_ci*d10_tanh0)*(HBT_X_charge(vbci,(Cjc-Cmin),Vjc,mjc,Area)+((((1.0-XJ0)*Area)*Cmin)*vbci)))+((1.0-d00_tanh0)*(HBT_X_d_charge(vbci,(Cjc-Cmin),Vjc,mjc,Area,vbci_Vbii_ci,0.0,0.0,0.0,0.0)+((((1.0-XJ0)*Area)*Cmin)*vbci_Vbii_ci))))+(((XJ0*Area)*Cmin)*vbci_Vbii_ci));
1181 #endif
1182 qb2med=(((1.0-d00_tanh0)*(HBT_X_charge(vbci,(Cjc-Cmin),Vjc,mjc,Area)+((((1.0-XJ0)*Area)*Cmin)*vbci)))+(((XJ0*Area)*Cmin)*vbci));
1183 }
1184 #endif
1185 }
1186 #endif /* if (...) */
1187 }
1188 #endif /* if (...) */
1189 #ifdef _DYNAMIC
1190 if
1191 (((XCjc<1.0)&&(XCjc>0.0)))
1192 {
1193 #if defined(_DYNAMIC)
1194 #if defined(_DERIVATE)
1195 qb1_Vbi_ci=(((1.0-XCjc)*HBT_X_d_charge(vbcx,(Cjc-Cmin),Vjc,mjc,Area,vbcx_Vbi_ci,0.0,0.0,0.0,0.0))+((((1.0-XCjc)*Area)*Cmin)*vbcx_Vbi_ci));
1196 #endif
1197 qb1=(((1.0-XCjc)*HBT_X_charge(vbcx,(Cjc-Cmin),Vjc,mjc,Area))+((((1.0-XCjc)*Area)*Cmin)*vbcx));
1198 #endif
1199 }
1200 else
1201 {
1202 #if defined(_DYNAMIC)
1203 #if defined(_DERIVATE)
1204 qb1_Vbi_ci=0.0;
1205 #endif
1206 qb1=0.0;
1207 #endif
1208 }
1209 #endif /* if (...) */
1210 #if defined(_DYNAMIC)
1211 #if defined(_DERIVATE)
1212 qbtr_Vbii_ci=(Tr*Ic1r_Vbii_ci);
1213 qbtr_Tempti_GND=(Tr*Ic1r_Tempti_GND);
1214 qbtr_Vbii_ei=(Tr*Ic1r_Vbii_ei);
1215 #endif
1216 qbtr=(Tr*Ic1r);
1217 #endif
1218 #if defined(_DYNAMIC)
1219 #if defined(_DERIVATE)
1220 qbtra_Vbi_ci=(Trx*Ibx_Vbi_ci);
1221 qbtra_Tempti_GND=(Trx*Ibx_Tempti_GND);
1222 #endif
1223 qbtra=(Trx*Ibx);
1224 #endif
1225 #if defined(_DYNAMIC)
1226 #if defined(_DERIVATE)
1227 qb2_Vbii_ei=(qb2med_Vbii_ei+qbtr_Vbii_ei);
1228 qb2_Tempti_GND=(qb2med_Tempti_GND+qbtr_Tempti_GND);
1229 qb2_Vbii_ci=(qb2med_Vbii_ci+qbtr_Vbii_ci);
1230 #endif
1231 qb2=(qb2med+qbtr);
1232 #endif
1233 #ifdef _DYNAMIC
1234 if
1235 (((Jk>0.0)&&(Rci0>0.0)))
1236 {
1237 #ifdef _DYNAMIC
1238 if
1239 ((RJk>0.0))
1240 {
1241 #if defined(_DYNAMIC)
1242 Vlim=((Jk*Rci0)/(1.0-(Rci0/RJk)));
1243 #endif
1244 #if defined(_DYNAMIC)
1245 InvVpt=((1.0-(Rci0/RJk))/(Jk*RJk));
1246 #endif
1247 }
1248 else
1249 {
1250 #if defined(_DYNAMIC)
1251 Vlim=((Jk*Rci0)/1.016);
1252 #endif
1253 #if defined(_DYNAMIC)
1254 InvVpt=0.0;
1255 #endif
1256 }
1257 #endif /* if (...) */
1258 }
1259 #endif /* if (...) */
1260 #ifdef _DYNAMIC
1261 if
1262 (((((Thcs>0.0)&&(Ahc>0.0))&&(Jk>0.0))&&(Ic0>0.0)))
1263 {
1264 #if defined(_DYNAMIC)
1265 RCIO=(Rci0/Area);
1266 #endif
1267 #if defined(_DYNAMIC)
1268 AHC=(Area*Ahc);
1269 #endif
1270 #ifdef _DYNAMIC
1271 if
1272 (((Rci0<RJk)||(RJk<=0.0)))
1273 {
1274 #if defined(_DYNAMIC)
1275 #if defined(_DERIVATE)
1276 Ih_Vci_ei=(-(HBT_X_d_ICK(vcei,RCIO,Vlim,InvVpt,Vces,vcei_Vci_ei,0.0,0.0,0.0,0.0)/Ic0));
1277 Ih_Vbii_ei=(-((HBT_X_d_ICK(vcei,RCIO,Vlim,InvVpt,Vces,0.0,0.0,0.0,0.0,0.0)*Ic0-HBT_X_ICK(vcei,RCIO,Vlim,InvVpt,Vces)*Ic0_Vbii_ei)/Ic0/Ic0));
1278 Ih_Tempti_GND=(-((HBT_X_d_ICK(vcei,RCIO,Vlim,InvVpt,Vces,0.0,0.0,0.0,0.0,0.0)*Ic0-HBT_X_ICK(vcei,RCIO,Vlim,InvVpt,Vces)*Ic0_Tempti_GND)/Ic0/Ic0));
1279 Ih_Vbii_ci=(-((HBT_X_d_ICK(vcei,RCIO,Vlim,InvVpt,Vces,0.0,0.0,0.0,0.0,0.0)*Ic0-HBT_X_ICK(vcei,RCIO,Vlim,InvVpt,Vces)*Ic0_Vbii_ci)/Ic0/Ic0));
1280 #endif
1281 Ih=(1.0-(HBT_X_ICK(vcei,RCIO,Vlim,InvVpt,Vces)/Ic0));
1282 #endif
1283 }
1284 else
1285 {
1286 #if defined(_DYNAMIC)
1287 #if defined(_DERIVATE)
1288 Ih_Vci_ei=(-(HBT_X_d_Vceff(vcei,Vces,vcei_Vci_ei,0.0)/(RCIO*Ic0)));
1289 Ih_Vbii_ei=(-((HBT_X_d_Vceff(vcei,Vces,0.0,0.0)*(RCIO*Ic0)-HBT_X_Vceff(vcei,Vces)*(RCIO*Ic0_Vbii_ei))/(RCIO*Ic0)/(RCIO*Ic0)));
1290 Ih_Tempti_GND=(-((HBT_X_d_Vceff(vcei,Vces,0.0,0.0)*(RCIO*Ic0)-HBT_X_Vceff(vcei,Vces)*(RCIO*Ic0_Tempti_GND))/(RCIO*Ic0)/(RCIO*Ic0)));
1291 Ih_Vbii_ci=(-((HBT_X_d_Vceff(vcei,Vces,0.0,0.0)*(RCIO*Ic0)-HBT_X_Vceff(vcei,Vces)*(RCIO*Ic0_Vbii_ci))/(RCIO*Ic0)/(RCIO*Ic0)));
1292 #endif
1293 Ih=(1.0-(HBT_X_Vceff(vcei,Vces)/(RCIO*Ic0)));
1294 #endif
1295 }
1296 #endif /* if (...) */
1297 #if defined(_DYNAMIC)
1298 {
1299 double m00_sqrt(d00_sqrt0,((Ih*Ih)+AHC))
1300 double m00_sqrt(d00_sqrt1,(1.0+AHC))
1301 #if defined(_DERIVATE)
1302 double m10_sqrt(d10_sqrt0,d00_sqrt0,((Ih*Ih)+AHC))
1303 #endif
1304 #if defined(_DERIVATE)
1305 Wh_Vci_ei=((Ih_Vci_ei+((Ih_Vci_ei*Ih)+(Ih*Ih_Vci_ei))*d10_sqrt0)/(1.0+d00_sqrt1));
1306 Wh_Vbii_ei=((Ih_Vbii_ei+((Ih_Vbii_ei*Ih)+(Ih*Ih_Vbii_ei))*d10_sqrt0)/(1.0+d00_sqrt1));
1307 Wh_Tempti_GND=((Ih_Tempti_GND+((Ih_Tempti_GND*Ih)+(Ih*Ih_Tempti_GND))*d10_sqrt0)/(1.0+d00_sqrt1));
1308 Wh_Vbii_ci=((Ih_Vbii_ci+((Ih_Vbii_ci*Ih)+(Ih*Ih_Vbii_ci))*d10_sqrt0)/(1.0+d00_sqrt1));
1309 #endif
1310 Wh=((Ih+d00_sqrt0)/(1.0+d00_sqrt1));
1311 }
1312 #endif
1313 #if defined(_DYNAMIC)
1314 #if defined(_DERIVATE)
1315 xtff_Vbii_ei=(((Thcs*Ic0_Vbii_ei)*(Wh*Wh))+((Thcs*Ic0)*((Wh_Vbii_ei*Wh)+(Wh*Wh_Vbii_ei))));
1316 xtff_Tempti_GND=(((Thcs*Ic0_Tempti_GND)*(Wh*Wh))+((Thcs*Ic0)*((Wh_Tempti_GND*Wh)+(Wh*Wh_Tempti_GND))));
1317 xtff_Vbii_ci=(((Thcs*Ic0_Vbii_ci)*(Wh*Wh))+((Thcs*Ic0)*((Wh_Vbii_ci*Wh)+(Wh*Wh_Vbii_ci))));
1318 xtff_Vci_ei=((Thcs*Ic0)*((Wh_Vci_ei*Wh)+(Wh*Wh_Vci_ei)));
1319 #endif
1320 xtff=((Thcs*Ic0)*(Wh*Wh));
1321 #endif
1322 }
1323 else
1324 {
1325 #if defined(_DYNAMIC)
1326 #if defined(_DERIVATE)
1327 xtff_Vbii_ei=0.0;
1328 xtff_Tempti_GND=0.0;
1329 xtff_Vbii_ci=0.0;
1330 xtff_Vci_ei=0.0;
1331 #endif
1332 xtff=0;
1333 #endif
1334 }
1335 #endif /* if (...) */
1336 #if defined(_DYNAMIC)
1337 #if defined(_DERIVATE)
1338 qbtf_Tempti_GND=(((Tft*Tex_Tempti_GND)*Ic0)+((Tf+(Tft*Tex))*Ic0_Tempti_GND));
1339 qbtf_Vbii_ei=((Tf+(Tft*Tex))*Ic0_Vbii_ei);
1340 qbtf_Vbii_ci=((Tf+(Tft*Tex))*Ic0_Vbii_ci);
1341 #endif
1342 qbtf=((Tf+(Tft*Tex))*Ic0);
1343 #endif
1344 #if defined(_DYNAMIC)
1345 #if defined(_DERIVATE)
1346 qbe_Vbii_ei=((xtff_Vbii_ei+qbtf_Vbii_ei)+HBT_X_d_charge(vbei,Cje,Vje,mje,Area,vbei_Vbii_ei,0.0,0.0,0.0,0.0));
1347 qbe_Tempti_GND=((xtff_Tempti_GND+qbtf_Tempti_GND)+HBT_X_d_charge(vbei,Cje,Vje,mje,Area,0.0,0.0,0.0,0.0,0.0));
1348 qbe_Vbii_ci=((xtff_Vbii_ci+qbtf_Vbii_ci)+HBT_X_d_charge(vbei,Cje,Vje,mje,Area,0.0,0.0,0.0,0.0,0.0));
1349 qbe_Vci_ei=(xtff_Vci_ei+HBT_X_d_charge(vbei,Cje,Vje,mje,Area,0.0,0.0,0.0,0.0,0.0));
1350 #endif
1351 qbe=((xtff+qbtf)+HBT_X_charge(vbei,Cje,Vje,mje,Area));
1352 #endif
1354 #if defined(_DERIVATE)
1355 _load_static_jacobian2s(bi,ci,ti,Ibx_Tempti_GND);
1356 _load_static_jacobian4(bi,ci,bi,ci,Ibx_Vbi_ci);
1357 #endif
1358 #if defined(_DYNAMIC)
1359 _load_dynamic_residual2(bi,ci,_DDT((qb1+qbtra)));
1360 #if defined(_DERIVATE)
1361 _load_dynamic_jacobian2s(bi,ci,ti,qbtra_Tempti_GND);
1362 _load_dynamic_jacobian4(bi,ci,bi,ci,(qb1_Vbi_ci+qbtra_Vbi_ci));
1363 #endif
1364 #endif
1366 #if defined(_DERIVATE)
1367 _load_static_jacobian2s(bii,ci,ti,Ib2_Tempti_GND);
1368 _load_static_jacobian4(bii,ci,bii,ci,Ib2_Vbii_ci);
1369 #endif
1370 #if defined(_DYNAMIC)
1372 #if defined(_DERIVATE)
1373 _load_dynamic_jacobian4(bii,ci,bii,ci,qb2_Vbii_ci);
1374 _load_dynamic_jacobian2s(bii,ci,ti,qb2_Tempti_GND);
1375 _load_dynamic_jacobian4(bii,ci,bii,ei,qb2_Vbii_ei);
1376 #endif
1377 #endif
1379 #if defined(_DERIVATE)
1380 _load_static_jacobian4(bii,ei,bii,ci,Ib1_Vbii_ci);
1381 _load_static_jacobian2s(bii,ei,ti,Ib1_Tempti_GND);
1382 _load_static_jacobian4(bii,ei,bii,ei,Ib1_Vbii_ei);
1383 #endif
1384 #if defined(_DYNAMIC)
1386 #if defined(_DERIVATE)
1387 _load_dynamic_jacobian4(bii,ei,ci,ei,qbe_Vci_ei);
1388 _load_dynamic_jacobian4(bii,ei,bii,ci,qbe_Vbii_ci);
1389 _load_dynamic_jacobian2s(bii,ei,ti,qbe_Tempti_GND);
1390 _load_dynamic_jacobian4(bii,ei,bii,ei,qbe_Vbii_ei);
1391 #endif
1392 #endif
1394 #if defined(_DERIVATE)
1395 _load_static_jacobian4(ci,ei,bii,ci,Ic1_Vbii_ci);
1396 _load_static_jacobian2s(ci,ei,ti,Ic1_Tempti_GND);
1397 _load_static_jacobian4(ci,ei,bii,ei,Ic1_Vbii_ei);
1398 #endif
1400 #if defined(_DERIVATE)
1401 _load_static_jacobian2s(ex,ei,ti,Ibdx_Tempti_GND);
1402 _load_static_jacobian4(ex,ei,ex,ei,Ibdx_Vex_ei);
1403 #endif
1405 #if defined(_DERIVATE)
1406 _load_static_jacobian2s(exx,ei,ti,Ibdxx_Tempti_GND);
1407 _load_static_jacobian4(exx,ei,exx,ei,Ibdxx_Vexx_ei);
1408 #endif
1410 #if defined(_DERIVATE)
1411 _load_static_jacobian2s(cx,ci,ti,Icdx_Tempti_GND);
1412 _load_static_jacobian4(cx,ci,cx,ci,Icdx_Vcx_ci);
1413 #endif
1414 _save_whitenoise2(bii,ei,(TWO_Q*Ib1),"Ib");
1416 #if defined(_DERIVATE)
1418 #endif
1419 _save_whitenoise1(ni,(TWO_Q*Ic0),"Ic");
1421 #if defined(_DERIVATE)
1423 #endif
1425 #if defined(_DERIVATE)
1427 #endif
1428 _load_static_residual2(bii,bi,(BP(bii,bi)/(Rb2/N)));
1429 #if defined(_DERIVATE)
1430 _load_static_jacobian4(bii,bi,bii,bi,(1/(Rb2/N)));
1431 #endif
1432 _save_whitenoise2(bii,bi,((FOUR_K*TjK)/(Rb2/N)),"thermal");
1433 _load_static_residual2(b,bi,(BP(b,bi)/(Rb/N)));
1434 #if defined(_DERIVATE)
1435 _load_static_jacobian4(b,bi,b,bi,(1/(Rb/N)));
1436 #endif
1437 _save_whitenoise2(b,bi,((FOUR_K*TjK)/(Rb/N)),"thermal");
1438 _load_static_residual2(e,ei,(BP(e,ei)/(Re/N)));
1439 #if defined(_DERIVATE)
1440 _load_static_jacobian4(e,ei,e,ei,(1/(Re/N)));
1441 #endif
1442 _save_whitenoise2(e,ei,((FOUR_K*TjK)/(Re/N)),"thermal");
1443 _load_static_residual2(c,ci,(BP(c,ci)/(Rc/N)));
1444 #if defined(_DERIVATE)
1445 _load_static_jacobian4(c,ci,c,ci,(1/(Rc/N)));
1446 #endif
1447 _save_whitenoise2(c,ci,((FOUR_K*TjK)/(Rc/N)),"thermal");
1448 if
1449 (((Jse>0.0)&&(ne>0)))
1450 {
1451 _load_static_residual2(ex,bii,(BP(ex,bii)/(Rbxx/N)));
1452 #if defined(_DERIVATE)
1453 _load_static_jacobian4(ex,bii,ex,bii,(1/(Rbxx/N)));
1454 #endif
1455 _save_whitenoise2(ex,bii,((FOUR_K*TjK)/(Rbxx/N)),"thermal");
1456 }
1457 else
1458 {
1460 #if defined(_DERIVATE)
1462 #endif
1463 }
1464 if
1465 (((Jsee>0.0)&&(nee>0)))
1466 {
1467 _load_static_residual2(exx,bii,(BP(exx,bii)/(Rbbxx/N)));
1468 #if defined(_DERIVATE)
1469 _load_static_jacobian4(exx,bii,exx,bii,(1/(Rbbxx/N)));
1470 #endif
1471 _save_whitenoise2(exx,bii,((FOUR_K*TjK)/(Rbbxx/N)),"thermal");
1472 }
1473 else
1474 {
1476 #if defined(_DERIVATE)
1478 #endif
1479 }
1480 if
1481 (((Jsc>0.0)&&(nc>0)))
1482 {
1483 _load_static_residual2(cx,bii,(BP(cx,bii)/(Rcxx/N)));
1484 #if defined(_DERIVATE)
1485 _load_static_jacobian4(cx,bii,cx,bii,(1/(Rcxx/N)));
1486 #endif
1487 _save_whitenoise2(cx,bii,((FOUR_K*TjK)/(Rcxx/N)),"thermal");
1488 }
1489 else
1490 {
1492 #if defined(_DERIVATE)
1494 #endif
1495 }
1496 #if defined(_DYNAMIC)
1497 _load_dynamic_residual1(b,_DDT((Cpb*NP(b))));
1498 #if defined(_DERIVATE)
1499 _load_dynamic_jacobian1(b,b,(Cpb));
1500 #endif
1501 #endif
1502 #if defined(_DYNAMIC)
1503 _load_dynamic_residual1(c,_DDT((Cpc*NP(c))));
1504 #if defined(_DERIVATE)
1505 _load_dynamic_jacobian1(c,c,(Cpc));
1506 #endif
1507 #endif
1508 #if defined(_DYNAMIC)
1509 _load_dynamic_residual2(b,c,_DDT((Cq*BP(b,c))));
1510 #if defined(_DERIVATE)
1511 _load_dynamic_jacobian4(b,c,b,c,(Cq));
1512 #endif
1513 #endif
1514 _load_static_residual1(ti,(-Ipdiss));
1515 #if defined(_DERIVATE)
1516 _load_static_jacobian2p(ti,bi,ci,(-Ipdiss_Vbi_ci));
1517 _load_static_jacobian2p(ti,ci,ei,(-Ipdiss_Vci_ei));
1518 _load_static_jacobian2p(ti,bii,ci,(-Ipdiss_Vbii_ci));
1519 _load_static_jacobian1(ti,ti,(-Ipdiss_Tempti_GND));
1520 _load_static_jacobian2p(ti,bii,ei,(-Ipdiss_Vbii_ei));
1521 #endif
1522 if
1523 (Rth)
1524 {
1525 _load_static_residual2(t,ti,(BP(t,ti)/Rth));
1526 #if defined(_DERIVATE)
1527 _load_static_jacobian4(t,ti,t,ti,(1/Rth));
1528 #endif
1529 #if defined(_DYNAMIC)
1531 #if defined(_DERIVATE)
1533 #endif
1534 #endif
1535 }
1536 else
1537 {
1538 _load_static_residual2(t,ti,(BP(t,ti)*1e3));
1539 #if defined(_DERIVATE)
1540 _load_static_jacobian4(t,ti,t,ti,(1e3));
1541 #endif
1542 }
1543 if
1544 ((Ib0<=0))
1545 {
1546 #if defined(_DERIVATE)
1547 Iniix_Vbii_ei=0.0;
1548 Iniix_Tempti_GND=0.0;
1549 Iniix_Vbii_ci=0.0;
1550 #endif
1551 Iniix=0;
1552 #if defined(_DERIVATE)
1553 Iniiix_Vbii_ei=0.0;
1554 Iniiix_Tempti_GND=0.0;
1555 Iniiix_Vbii_ci=0.0;
1556 #endif
1557 Iniiix=0;
1558 }
1559 if
1560 (((Ib0+Ic1)<=0))
1561 {
1562 #if defined(_DERIVATE)
1563 Inivx_Vbii_ei=0.0;
1564 Inivx_Tempti_GND=0.0;
1565 Inivx_Vbii_ci=0.0;
1566 #endif
1567 Inivx=0;
1568 }
1569 else
1570 {
1571 if
1572 ((Ab==2))
1573 {
1574 #if defined(_DERIVATE)
1575 Iniix_Vbii_ei=Ib0_Vbii_ei;
1576 Iniix_Tempti_GND=Ib0_Tempti_GND;
1577 Iniix_Vbii_ci=Ib0_Vbii_ci;
1578 #endif
1579 Iniix=Ib0;
1580 }
1581 else
1582 {
1583 {
1584 double m00_pow(d00_pow0,Ib0,(Ab*0.5))
1585 #if defined(_DERIVATE)
1586 double m10_pow(d10_pow0,d00_pow0,Ib0,(Ab*0.5))
1587 #endif
1588 #if defined(_DERIVATE)
1589 Iniix_Vbii_ei=(d10_pow0*Ib0_Vbii_ei);
1590 Iniix_Tempti_GND=(d10_pow0*Ib0_Tempti_GND);
1591 Iniix_Vbii_ci=(d10_pow0*Ib0_Vbii_ci);
1592 #endif
1593 Iniix=d00_pow0;
1594 }
1595 }
1596 if
1597 ((Afb==2))
1598 {
1599 #if defined(_DERIVATE)
1600 Iniiix_Vbii_ei=Ib0_Vbii_ei;
1601 Iniiix_Tempti_GND=Ib0_Tempti_GND;
1602 Iniiix_Vbii_ci=Ib0_Vbii_ci;
1603 #endif
1604 Iniiix=Ib0;
1605 }
1606 else
1607 {
1608 {
1609 double m00_pow(d00_pow0,Ib0,(Afb*0.5))
1610 #if defined(_DERIVATE)
1611 double m10_pow(d10_pow0,d00_pow0,Ib0,(Afb*0.5))
1612 #endif
1613 #if defined(_DERIVATE)
1614 Iniiix_Vbii_ei=(d10_pow0*Ib0_Vbii_ei);
1615 Iniiix_Tempti_GND=(d10_pow0*Ib0_Tempti_GND);
1616 Iniiix_Vbii_ci=(d10_pow0*Ib0_Vbii_ci);
1617 #endif
1618 Iniiix=d00_pow0;
1619 }
1620 }
1621 if
1622 ((Afe==2))
1623 {
1624 #if defined(_DERIVATE)
1625 Inivx_Vbii_ei=(Ib0_Vbii_ei+Ic1_Vbii_ei);
1626 Inivx_Tempti_GND=(Ib0_Tempti_GND+Ic1_Tempti_GND);
1627 Inivx_Vbii_ci=(Ib0_Vbii_ci+Ic1_Vbii_ci);
1628 #endif
1629 Inivx=(Ib0+Ic1);
1630 }
1631 else
1632 {
1633 {
1634 double m00_pow(d00_pow0,(Ib0+Ic1),(Afe*0.5))
1635 #if defined(_DERIVATE)
1636 double m10_pow(d10_pow0,d00_pow0,(Ib0+Ic1),(Afe*0.5))
1637 #endif
1638 #if defined(_DERIVATE)
1639 Inivx_Vbii_ei=(d10_pow0*(Ib0_Vbii_ei+Ic1_Vbii_ei));
1640 Inivx_Tempti_GND=(d10_pow0*(Ib0_Tempti_GND+Ic1_Tempti_GND));
1641 Inivx_Vbii_ci=(d10_pow0*(Ib0_Vbii_ci+Ic1_Vbii_ci));
1642 #endif
1643 Inivx=d00_pow0;
1644 }
1645 }
1646 }
1648 #if defined(_DERIVATE)
1650 #endif
1651 #if defined(_DYNAMIC)
1652 _load_dynamic_residual1(nii,_DDT((NP(nii)/((2.0*3.1415)*Fb))));
1653 #if defined(_DERIVATE)
1654 _load_dynamic_jacobian1(nii,nii,(1/((2.0*3.1415)*Fb)));
1655 #endif
1656 #endif
1657 _save_whitenoise1(nii,(Area*Kb),NULL);
1659 #if defined(_DERIVATE)
1661 #endif
1663 #if defined(_DERIVATE)
1664 _load_static_jacobian2p(niix,bii,ci,Iniix_Vbii_ci);
1665 _load_static_jacobian1(niix,ti,Iniix_Tempti_GND);
1666 _load_static_jacobian2p(niix,bii,ei,Iniix_Vbii_ei);
1667 #endif
1669 #if defined(_DERIVATE)
1671 #endif
1672 _save_flickernoise1(niii,(Area*Kfb),Ffeb,"Flicker noise base-emitter junction (a)");
1674 #if defined(_DERIVATE)
1676 #endif
1678 #if defined(_DERIVATE)
1679 _load_static_jacobian2p(niiix,bii,ci,Iniiix_Vbii_ci);
1680 _load_static_jacobian1(niiix,ti,Iniiix_Tempti_GND);
1681 _load_static_jacobian2p(niiix,bii,ei,Iniiix_Vbii_ei);
1682 #endif
1684 #if defined(_DERIVATE)
1687 #endif
1689 #if defined(_DERIVATE)
1692 #endif
1694 #if defined(_DERIVATE)
1696 #endif
1697 _save_flickernoise1(niv,(Area*Kfe),Ffee,"Hooge noise of emitter resistance");
1699 #if defined(_DERIVATE)
1701 #endif
1703 #if defined(_DERIVATE)
1704 _load_static_jacobian2p(nivx,bii,ci,Inivx_Vbii_ci);
1705 _load_static_jacobian1(nivx,ti,Inivx_Tempti_GND);
1706 _load_static_jacobian2p(nivx,bii,ei,Inivx_Vbii_ei);
1707 #endif
1708 _load_static_residual2(e,ei,((NP(niv)*NP(nivx))/(Re/N)));
1709 #if defined(_DERIVATE)
1710 _load_static_jacobian2s(e,ei,nivx,((NP(niv))/(Re/N)));
1711 _load_static_jacobian2s(e,ei,niv,((NP(nivx))/(Re/N)));
1712 #endif
1713 
1714 /* ------------------ end of verilog analog equations --------------------- */
1715 
1716 /* ------------------ evaluate verilog noise equations -------------------- */
1717 
1718 /* ------------------- end of verilog noise equations --------------------- */
1719 }
1720 
1721 /* Perform DC iteration. */
1722 void HBT_X::calcDC (void)
1723 {
1724  // evaluate Verilog code
1725  initVerilog ();
1726  calcVerilog ();
1727 
1728  // fill right hand side and static jacobian
1729  for (int i1 = 0; i1 < 19; i1++) {
1730  setI (i1, _rhs[i1]);
1731  for (int i2 = 0; i2 < 19; i2++) {
1732  setY (i1, i2, _jstat[i1][i2]);
1733  }
1734  }
1735 }
1736 
1737 /* Save operating points. */
1739 {
1740  // save global instance operating points
1741 }
1742 
1743 /* Load operating points. */
1745 {
1746 }
1747 
1748 /* Calculate operating points. */
1750 {
1751 }
1752 
1753 /* Initialization of AC analysis. */
1754 void HBT_X::initAC (void)
1755 {
1756  allocMatrixMNA ();
1757 }
1758 
1759 /* Perform AC calculations. */
1760 void HBT_X::calcAC (nr_double_t frequency)
1761 {
1762  setMatrixY (calcMatrixY (frequency));
1763 }
1764 
1765 /* Compute Y-matrix for AC analysis. */
1766 matrix HBT_X::calcMatrixY (nr_double_t frequency)
1767 {
1768  _freq = frequency;
1770  matrix y (19);
1771 
1772  for (int i1 = 0; i1 < 19; i1++) {
1773  for (int i2 = 0; i2 < 19; i2++) {
1774  y (i1,i2) = rect (_jstat[i1][i2], _jdyna[i1][i2] * 2 * M_PI * _freq);
1775  }
1776  }
1777 
1778  return y;
1779 }
1780 
1781 /* Initialization of S-parameter analysis. */
1782 void HBT_X::initSP (void)
1783 {
1784  allocMatrixS ();
1785 }
1786 
1787 /* Perform S-parameter calculations. */
1788 void HBT_X::calcSP (nr_double_t frequency)
1789 {
1790  setMatrixS (ytos (calcMatrixY (frequency)));
1791 }
1792 
1793 /* Initialization of transient analysis. */
1794 void HBT_X::initTR (void)
1795 {
1796  setStates (2 * 19 * 19);
1797  initDC ();
1798 }
1799 
1800 /* Perform transient analysis iteration step. */
1801 void HBT_X::calcTR (nr_double_t)
1802 {
1803  doHB = 0;
1804  doAC = 1;
1805  doTR = 1;
1806  calcDC ();
1807 
1808  int i1, i2, i3, i4, state;
1809 
1810  // 2-node charge integrations
1811  for (i1 = 0; i1 < 19; i1++) {
1812  for (i2 = 0; i2 < 19; i2++) {
1813  state = 2 * (i2 + 19 * i1);
1814  if (i1 != i2)
1815  if (_charges[i1][i2] != 0.0)
1816  transientCapacitanceQ (state, i1, i2, _charges[i1][i2]);
1817  } }
1818 
1819  // 1-node charge integrations
1820  for (i1 = 0; i1 < 19; i1++) {
1821  state = 2 * (i1 + 19 * i1);
1822  if (_charges[i1][i1] != 0.0)
1823  transientCapacitanceQ (state, i1, _charges[i1][i1]);
1824  }
1825 
1826  // charge: 2-node, voltage: 2-node
1827  for (i1 = 0; i1 < 19; i1++) {
1828  for (i2 = 0; i2 < 19; i2++) {
1829  if (i1 != i2)
1830  for (i3 = 0; i3 < 19; i3++) {
1831  for (i4 = 0; i4 < 19; i4++) {
1832  if (i3 != i4)
1833  if (_caps[i1][i2][i3][i4] != 0.0)
1834  transientCapacitanceC (i1, i2, i3, i4, _caps[i1][i2][i3][i4], BP(i3,i4));
1835  } } } }
1836 
1837  // charge: 2-node, voltage: 1-node
1838  for (i1 = 0; i1 < 19; i1++) {
1839  for (i2 = 0; i2 < 19; i2++) {
1840  if (i1 != i2)
1841  for (i3 = 0; i3 < 19; i3++) {
1842  if (_caps[i1][i2][i3][i3] != 0.0)
1843  transientCapacitanceC2Q (i1, i2, i3, _caps[i1][i2][i3][i3], NP(i3));
1844  } } }
1845 
1846  // charge: 1-node, voltage: 2-node
1847  for (i1 = 0; i1 < 19; i1++) {
1848  for (i3 = 0; i3 < 19; i3++) {
1849  for (i4 = 0; i4 < 19; i4++) {
1850  if (i3 != i4)
1851  if (_caps[i1][i1][i3][i4] != 0.0)
1852  transientCapacitanceC2V (i1, i3, i4, _caps[i1][i1][i3][i4], BP(i3,i4));
1853  } } }
1854 
1855  // charge: 1-node, voltage: 1-node
1856  for (i1 = 0; i1 < 19; i1++) {
1857  for (i3 = 0; i3 < 19; i3++) {
1858  if (_caps[i1][i1][i3][i3] != 0.0)
1859  transientCapacitanceC (i1, i3, _caps[i1][i1][i3][i3], NP(i3));
1860  } }
1861 }
1862 
1863 /* Compute Cy-matrix for AC noise analysis. */
1864 matrix HBT_X::calcMatrixCy (nr_double_t frequency)
1865 {
1866  _freq = frequency;
1867  matrix cy (19);
1868 
1869  _load_flickernoise1 (niv,_flicker_pwr[niv][niv],_flicker_exp[niv][niv]);
1870  _load_flickernoise1 (niii,_flicker_pwr[niii][niii],_flicker_exp[niii][niii]);
1871  _load_whitenoise1 (nii,_white_pwr[nii][nii]);
1872  _load_whitenoise2 (cx,bii,_white_pwr[cx][bii]);
1873  _load_whitenoise2 (exx,bii,_white_pwr[exx][bii]);
1874  _load_whitenoise2 (ex,bii,_white_pwr[ex][bii]);
1875  _load_whitenoise2 (c,ci,_white_pwr[c][ci]);
1876  _load_whitenoise2 (e,ei,_white_pwr[e][ei]);
1877  _load_whitenoise2 (b,bi,_white_pwr[b][bi]);
1878  _load_whitenoise2 (bii,bi,_white_pwr[bii][bi]);
1879  _load_whitenoise1 (ni,_white_pwr[ni][ni]);
1880  _load_whitenoise2 (bii,ei,_white_pwr[bii][ei]);
1881 
1882  return cy;
1883 }
1884 
1885 /* Perform AC noise computations. */
1886 void HBT_X::calcNoiseAC (nr_double_t frequency)
1887 {
1888  setMatrixN (calcMatrixCy (frequency));
1889 }
1890 
1891 /* Perform S-parameter noise computations. */
1892 void HBT_X::calcNoiseSP (nr_double_t frequency)
1893 {
1894  setMatrixN (cytocs (calcMatrixCy (frequency) * z0, getMatrixS ()));
1895 }
1896 
1897 /* Initialization of HB analysis. */
1898 void HBT_X::initHB (int)
1899 {
1900  initDC ();
1901  allocMatrixHB ();
1902 }
1903 
1904 /* Perform HB analysis. */
1905 void HBT_X::calcHB (int)
1906 {
1907  doHB = 1;
1908  doAC = 1;
1909  doTR = 0;
1910 
1911  // jacobian dI/dV and currents get filled
1912  calcDC ();
1914 
1915  // fill in HB matrices
1916  for (int i1 = 0; i1 < 19; i1++) {
1917  setQ (i1, _qhs[i1]); // charges
1918  setCV (i1, _chs[i1]); // jacobian dQ/dV * V
1919  setGV (i1, _ghs[i1]); // jacobian dI/dV * V
1920  for (int i2 = 0; i2 < 19; i2++) {
1921  setQV (i1, i2, _jdyna[i1][i2]); // jacobian dQ/dV
1922  }
1923  }
1924 }
1925 
1926 #include "HBT_X.defs.h"