My Project  0.0.16
QUCS Mapping
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
fa1b.core.cpp
Go to the documentation of this file.
1 /*
2  * fa1b.core.cpp - device implementations for fa1b 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 "fa1b.analogfunction.h"
16 #include "component.h"
17 #include "device.h"
18 #include "fa1b.core.h"
19 
20 #ifndef CIR_fa1b
21 #define CIR_fa1b -1
22 #endif
23 
24 // external nodes
25 #define A 0
26 #define B 1
27 #define CI 2
28 #define CO 3
29 #define S 4
30 // internal nodes
31 #define Sn1 5
32 #define Sn2 6
33 #define COn1 7
34 #define COn2 8
35 
36 // useful macro definitions
37 #define NP(node) real (getV (node))
38 #define BP(pnode,nnode) (NP(pnode) - NP(nnode))
39 #define _load_static_residual2(pnode,nnode,current)\
40  _rhs[pnode] -= current;\
41  _rhs[nnode] += current;
42 #define _load_static_augmented_residual2(pnode,nnode,current)\
43  _rhs[pnode] -= current;\
44  _rhs[nnode] += current;
45 #define _load_static_residual1(node,current)\
46  _rhs[node] -= current;
47 #define _load_static_augmented_residual1(node,current)\
48  _rhs[node] -= current;
49 #define _load_static_jacobian4(pnode,nnode,vpnode,vnnode,conductance)\
50  _jstat[pnode][vpnode] += conductance;\
51  _jstat[nnode][vnnode] += conductance;\
52  _jstat[pnode][vnnode] -= conductance;\
53  _jstat[nnode][vpnode] -= conductance;\
54  if (doHB) {\
55  _ghs[pnode] += conductance * BP(vpnode,vnnode);\
56  _ghs[nnode] -= conductance * BP(vpnode,vnnode);\
57  } else {\
58  _rhs[pnode] += conductance * BP(vpnode,vnnode);\
59  _rhs[nnode] -= conductance * BP(vpnode,vnnode);\
60  }
61 #define _load_static_jacobian2p(node,vpnode,vnnode,conductance)\
62  _jstat[node][vpnode] += conductance;\
63  _jstat[node][vnnode] -= conductance;\
64  if (doHB) {\
65  _ghs[node] += conductance * BP(vpnode,vnnode);\
66  } else {\
67  _rhs[node] += conductance * BP(vpnode,vnnode);\
68  }
69 #define _load_static_jacobian2s(pnode,nnode,node,conductance)\
70  _jstat[pnode][node] += conductance;\
71  _jstat[nnode][node] -= conductance;\
72  if (doHB) {\
73  _ghs[pnode] += conductance * NP(node);\
74  _ghs[nnode] -= conductance * NP(node);\
75  } else {\
76  _rhs[pnode] += conductance * NP(node);\
77  _rhs[nnode] -= conductance * NP(node);\
78  }
79 #define _load_static_jacobian1(node,vnode,conductance)\
80  _jstat[node][vnode] += conductance;\
81  if (doHB) {\
82  _ghs[node] += conductance * NP(vnode);\
83  } else {\
84  _rhs[node] += conductance * NP(vnode);\
85  }
86 #define _load_dynamic_residual2(pnode,nnode,charge)\
87  if (doTR) _charges[pnode][nnode] += charge;\
88  if (doHB) {\
89  _qhs[pnode] -= charge;\
90  _qhs[nnode] += charge;\
91  }
92 #define _load_dynamic_residual1(node,charge)\
93  if (doTR) _charges[node][node] += charge;\
94  if (doHB) {\
95  _qhs[node] -= charge;\
96  }
97 #define _load_dynamic_jacobian4(pnode,nnode,vpnode,vnnode,capacitance)\
98  if (doAC) {\
99  _jdyna[pnode][vpnode] += capacitance;\
100  _jdyna[nnode][vnnode] += capacitance;\
101  _jdyna[pnode][vnnode] -= capacitance;\
102  _jdyna[nnode][vpnode] -= capacitance;\
103  }\
104  if (doTR) {\
105  _caps[pnode][nnode][vpnode][vnnode] += capacitance;\
106  }\
107  if (doHB) {\
108  _chs[pnode] += capacitance * BP(vpnode,vnnode);\
109  _chs[nnode] -= capacitance * BP(vpnode,vnnode);\
110  }
111 #define _load_dynamic_jacobian2s(pnode,nnode,vnode,capacitance)\
112  if (doAC) {\
113  _jdyna[pnode][vnode] += capacitance;\
114  _jdyna[nnode][vnode] -= capacitance;\
115  }\
116  if (doTR) {\
117  _caps[pnode][nnode][vnode][vnode] += capacitance;\
118  }\
119  if (doHB) {\
120  _chs[pnode] += capacitance * NP(vnode);\
121  _chs[nnode] -= capacitance * NP(vnode);\
122  }
123 #define _load_dynamic_jacobian2p(node,vpnode,vnnode,capacitance)\
124  if (doAC) {\
125  _jdyna[node][vpnode] += capacitance;\
126  _jdyna[node][vnnode] -= capacitance;\
127  }\
128  if (doTR) {\
129  _caps[node][node][vpnode][vnnode] += capacitance;\
130  }\
131  if (doHB) {\
132  _chs[node] += capacitance * BP(vpnode,vnnode);\
133  }
134 #define _load_dynamic_jacobian1(node,vnode,capacitance)\
135  if (doAC) {\
136  _jdyna[node][vnode] += capacitance;\
137  }\
138  if (doTR) {\
139  _caps[node][node][vnode][vnode] += capacitance;\
140  }\
141  if (doHB) {\
142  _chs[node] += capacitance * NP(vnode);\
143  }
144 
145 #define _save_whitenoise1(n1,pwr,type)\
146  _white_pwr[n1][n1] += pwr;
147 #define _save_whitenoise2(n1,n2,pwr,type)\
148  _white_pwr[n1][n2] += pwr;
149 #define _save_flickernoise1(n1,pwr,exp,type)\
150  _flicker_pwr[n1][n1] += pwr;\
151  _flicker_exp[n1][n1] += exp;
152 #define _save_flickernoise2(n1,n2,pwr,exp,type)\
153  _flicker_pwr[n1][n2] += pwr;\
154  _flicker_exp[n1][n2] += exp;
155 #define _load_whitenoise2(n1,n2,pwr)\
156  cy (n1,n2) -= pwr/kB/T0; cy (n2,n1) -= pwr/kB/T0;\
157  cy (n1,n1) += pwr/kB/T0; cy (n2,n2) += pwr/kB/T0;
158 #define _load_whitenoise1(n1,pwr)\
159  cy (n1,n1) += pwr/kB/T0;
160 #define _load_flickernoise2(n1,n2,pwr,exp)\
161  cy (n1,n2) -= pwr*pow(_freq,-exp)/kB/T0;\
162  cy (n2,n1) -= pwr*pow(_freq,-exp)/kB/T0;\
163  cy (n1,n1) += pwr*pow(_freq,-exp)/kB/T0;\
164  cy (n2,n2) += pwr*pow(_freq,-exp)/kB/T0;
165 #define _load_flickernoise1(n1,pwr,exp)\
166  cy (n1,n1) += pwr*pow(_freq,-exp)/kB/T0;
167 
168 // derivative helper macros
169 #define m00_hypot(v00,x,y) v00 = xhypot(x,y);
170 #define m10_hypot(v10,v00,x,y) v10 = (x)/(v00);
171 #define m11_hypot(v11,v00,x,y) v11 = (y)/(v00);
172 #define m00_max(v00,x,y) v00 = ((x)>(y))?(x):(y);
173 #define m10_max(v10,v00,x,y) v10 = ((x)>(y))?1.0:0.0;
174 #define m11_max(v11,v00,x,y) v11 = ((x)>(y))?0.0:1.0;
175 #define m00_min(v00,x,y) v00 = ((x)<(y))?(x):(y);
176 #define m10_min(v10,v00,x,y) v10 = ((x)<(y))?1.0:0.0;
177 #define m11_min(v11,v00,x,y) v11 = ((x)<(y))?0.0:1.0;
178 #define m00_pow(v00,x,y) v00 = pow(x,y);
179 #define m10_pow(v10,v00,x,y) v10 = (x==0.0)?0.0:(v00)*(y)/(x);
180 #define m11_pow(v11,v00,x,y) v11 = (x==0.0)?0.0:(log(x)*(v00));
181 
182 #define m00_div(v00,v10,x,y) double v10=1/(y); double v00=(x)*v10;
183 #define m10_div(v10,v00,vv,x,y)
184 #define m11_div(v11,v00,vv,x,y) double v11 = -v00*vv;
185 
186 #define m00_mult(v00,v10,v11,x,y) double v10=(x); double v11=(y); double v00=v10*v11;
187 #define m00_add(v00,x,y) double v00=(x)+(y);
188 
189 #define m00_cos(v00,x) v00 = cos(x);
190 #define m10_cos(v10,v00,x) v10 = (-sin(x));
191 #define m00_sin(v00,x) v00 = sin(x);
192 #define m10_sin(v10,v00,x) v10 = (cos(x));
193 #define m00_tan(v00,x) v00 = tan(x);
194 #define m10_tan(v10,v00,x) v10 = (1.0/cos(x)/cos(x));
195 #define m00_cosh(v00,x) v00 = cosh(x);
196 #define m10_cosh(v10,v00,x) v10 = (sinh(x));
197 #define m00_sinh(v00,x) v00 = sinh(x);
198 #define m10_sinh(v10,v00,x) v10 = (cosh(x));
199 #define m00_tanh(v00,x) v00 = tanh(x);
200 #define m10_tanh(v10,v00,x) v10 = (1.0/cosh(x)/cosh(x));
201 #define m00_acos(v00,x) v00 = acos(x);
202 #define m10_acos(v10,v00,x) v10 = (-1.0/sqrt(1-x*x));
203 #define m00_asin(v00,x) v00 = asin(x);
204 #define m10_asin(v10,v00,x) v10 = (+1.0/sqrt(1-x*x));
205 #define m00_atan(v00,x) v00 = atan(x);
206 #define m10_atan(v10,v00,x) v10 = (+1.0/(1+x*x));
207 #define m00_atanh(v00,x) v00 = atanh(x);
208 #define m10_atanh(v10,v00,x) v10 = (+1.0/(1-x*x));
209 #define m00_logE(v00,x) v00 = log(x);
210 #define m10_logE(v10,v00,x) v10 = (1.0/x);
211 #define m00_log10(v00,x) v00 = log10(x);
212 #define m10_log10(v10,v00,x) v10 = (1.0/x/M_LN10);
213 #define m00_sqrt(v00,x) v00 = sqrt(x);
214 #define m10_sqrt(v10,v00,x) v10 = (0.5/v00);
215 #define m00_fabs(v00,x) v00 = fabs(x);
216 #define m10_fabs(v10,v00,x) v10 = (((x)>=0)?(+1.0):(-1.0));
217 
218 #define m00_exp(v00,x) v00 = exp(x);
219 #define m10_exp(v10,v00,x) v10 = v00;
220 
221 #define m00_abs(v00) ((v00)<(0)?(-(v00)):(v00))
222 #define m00_floor(v00,x) v00 = floor(x);
223 #define m00_limexp(v00,x) v00 = ((x)<80.0?exp(x):exp(80.0)*(x-79.0));
224 #define m10_limexp(v10,v00,x) v10 = ((x)<80.0?(v00):exp(80.0));
225 
226 #define m20_logE(v00) (-1.0/v00/v00)
227 #define m20_exp(v00) exp(v00)
228 #define m20_limexp(v00) ((v00)<80.0?exp(v00):0.0)
229 #define m20_sqrt(v00) (-0.25/(v00)/sqrt(v00))
230 #define m20_fabs(v00) 0.0
231 #define m20_pow(x,y) ((y)*((y)-1.0)*pow(x,y)/(x)/(x))
232 #define m00_vt(x) (kBoverQ*(x))
233 #define m10_vt(x) (kBoverQ)
234 
235 // simulator specific definitions
236 #define _modelname "fa1b"
237 #define _instancename getName()
238 #define _circuit_temp (getPropertyDouble("Temp")+273.15)
239 #define _param_given(p) (isPropertyGiven(p)?1:0)
240 
241 
242 // $vt and $vt() functions
243 #define _vt_nom (kBoverQ*_circuit_temp)
244 
245 using namespace device;
246 
247 /* Device constructor. */
248 fa1b::fa1b() : circuit (9)
249 {
250  type = CIR_fa1b;
251 }
252 
253 /* Initialization of model. */
254 void fa1b::initModel (void)
255 {
256  // create internal nodes
257  setInternalNode (Sn1, "Sn1");
258  setInternalNode (Sn2, "Sn2");
259  setInternalNode (COn1, "COn1");
260  setInternalNode (COn2, "COn2");
261 
262  // get device model parameters
263  loadVariables ();
264  // evaluate global model equations
265  initializeModel ();
266  // evaluate initial step equations
267  initialStep ();
268  // evaluate global instance equations
269  initializeInstance ();
270 }
271 
272 /* Initialization of DC analysis. */
273 void fa1b::initDC (void)
274 {
275  allocMatrixMNA ();
276  initModel ();
277  pol = 1;
278  restartDC ();
279  doAC = 1;
280  doTR = 0;
281  doHB = 0;
282 }
283 
284 /* Run when DC is restarted (fallback algorithms). */
285 void fa1b::restartDC (void)
286 {
287 }
288 
289 /* Initialize Verilog-AMS code. */
290 void fa1b::initVerilog (void)
291 {
292  // initialization of noise variables
293 
294  int i1, i2, i3, i4;
295 
296  // zero charges
297  for (i1 = 0; i1 < 9; i1++) {
298  for (i2 = 0; i2 < 9; i2++) {
299  _charges[i1][i2] = 0.0;
300  } }
301 
302  // zero capacitances
303  for (i1 = 0; i1 < 9; i1++) {
304  for (i2 = 0; i2 < 9; i2++) {
305  for (i3 = 0; i3 < 9; i3++) {
306  for (i4 = 0; i4 < 9; i4++) {
307  _caps[i1][i2][i3][i4] = 0.0;
308  } } } }
309 
310  // zero right hand side, static and dynamic jacobian
311  for (i1 = 0; i1 < 9; i1++) {
312  _rhs[i1] = 0.0;
313  _qhs[i1] = 0.0;
314  _chs[i1] = 0.0;
315  _ghs[i1] = 0.0;
316  for (i2 = 0; i2 < 9; i2++) {
317  _jstat[i1][i2] = 0.0;
318  _jdyna[i1][i2] = 0.0;
319  }
320  }
321 }
322 
323 /* Load device model input parameters. */
324 void fa1b::loadVariables (void)
325 {
326  TR = getPropertyDouble ("TR");
327  Delay = getPropertyDouble ("Delay");
328 }
329 
330 /* #define's for translated code */
331 #undef _DDT
332 #define _DDT(q) q
333 #define _DYNAMIC
334 #define _DERIVATE
335 #define _DDX
336 #define _DERIVATEFORDDX
337 
338 /* Evaluate Verilog-AMS equations in model initialization. */
339 void fa1b::initializeModel (void)
340 {
341 #if defined(_DYNAMIC)
342 #endif
343 {
344 Rd=1e3;
345 #if defined(_DYNAMIC)
346 Cd=((Delay*1.43)/Rd);
347 #endif
348 }
349 }
350 
351 /* Evaluate Verilog-AMS equations in instance initialization. */
352 void fa1b::initializeInstance (void)
353 {
354 }
355 
356 /* Evaluate Verilog-AMS equations in initial step. */
357 void fa1b::initialStep (void)
358 {
359 }
360 
361 /* Evaluate Verilog-AMS equations in final step. */
362 void fa1b::finalStep (void)
363 {
364 }
365 
366 /* Evaluate Verilog-AMS equations in analog block. */
367 void fa1b::calcVerilog (void)
368 {
369 
370 /* ----------------- evaluate verilog analog equations -------------------- */
371 double IS;
372 #if defined(_DERIVATE)
373 double IS_VCI_GND;
374 double IS_VA_GND;
375 double IS_VB_GND;
376 #endif
377 double ICO;
378 #if defined(_DERIVATE)
379 double ICO_VA_GND;
380 double ICO_VB_GND;
381 double ICO_VCI_GND;
382 #endif
383 double HCO;
384 #if defined(_DERIVATE)
385 double HCO_VA_GND;
386 double HCO_VB_GND;
387 #endif
388 double KS;
389 #if defined(_DERIVATE)
390 double KS_VA_GND;
391 double KS_VB_GND;
392 #endif
393 #if defined(_DERIVATE)
394 KS_VA_GND=(NP(B));
395 KS_VB_GND=(NP(A));
396 #endif
397 KS=(NP(A)*NP(B));
398 #if defined(_DERIVATE)
399 HCO_VA_GND=(((1-NP(B)))+(-1.0)*NP(B));
400 HCO_VB_GND=((NP(A)*(-1.0))+((1-NP(A))));
401 #endif
402 HCO=((NP(A)*(1-NP(B)))+((1-NP(A))*NP(B)));
403 #if defined(_DERIVATE)
404 ICO_VA_GND=(KS_VA_GND+(NP(CI)*HCO_VA_GND));
405 ICO_VB_GND=(KS_VB_GND+(NP(CI)*HCO_VB_GND));
406 ICO_VCI_GND=(HCO);
407 #endif
408 ICO=(KS+(NP(CI)*HCO));
409 #if defined(_DERIVATE)
410 IS_VCI_GND=(((1-HCO))+(-1.0)*HCO);
411 IS_VA_GND=((NP(CI)*(-HCO_VA_GND))+((1-NP(CI))*HCO_VA_GND));
412 IS_VB_GND=((NP(CI)*(-HCO_VB_GND))+((1-NP(CI))*HCO_VB_GND));
413 #endif
414 IS=((NP(CI)*(1-HCO))+((1-NP(CI))*HCO));
415 if
416 ((ICO>=0.5))
417 {
418 #if defined(_DERIVATE)
419 ICO_VA_GND=0.0;
420 ICO_VB_GND=0.0;
421 ICO_VCI_GND=0.0;
422 #endif
423 ICO=1;
424 }
425 else
426 {
427 #if defined(_DERIVATE)
428 ICO_VA_GND=0.0;
429 ICO_VB_GND=0.0;
430 ICO_VCI_GND=0.0;
431 #endif
432 ICO=0;
433 }
434 if
435 ((IS>=0.5))
436 {
437 #if defined(_DERIVATE)
438 IS_VCI_GND=0.0;
439 IS_VA_GND=0.0;
440 IS_VB_GND=0.0;
441 #endif
442 IS=1;
443 }
444 else
445 {
446 #if defined(_DERIVATE)
447 IS_VCI_GND=0.0;
448 IS_VA_GND=0.0;
449 IS_VB_GND=0.0;
450 #endif
451 IS=0;
452 }
453 {
454 double m00_tanh(d00_tanh0,(TR*(IS-0.5)))
455 #if defined(_DERIVATE)
456 double m10_tanh(d10_tanh0,d00_tanh0,(TR*(IS-0.5)))
457 #endif
458 _load_static_residual1(Sn1,((-0.5)*(1+d00_tanh0)));
459 #if defined(_DERIVATE)
460 _load_static_jacobian1(Sn1,B,((-0.5)*(TR*IS_VB_GND)*d10_tanh0));
461 _load_static_jacobian1(Sn1,A,((-0.5)*(TR*IS_VA_GND)*d10_tanh0));
462 _load_static_jacobian1(Sn1,CI,((-0.5)*(TR*IS_VCI_GND)*d10_tanh0));
463 #endif
464 }
466 #if defined(_DERIVATE)
468 #endif
470 #if defined(_DERIVATE)
472 #endif
473 #if defined(_DYNAMIC)
475 #if defined(_DERIVATE)
477 #endif
478 #endif
480 #if defined(_DERIVATE)
482 #endif
484 #if defined(_DERIVATE)
486 #endif
487 {
488 double m00_tanh(d00_tanh0,(TR*(ICO-0.5)))
489 #if defined(_DERIVATE)
490 double m10_tanh(d10_tanh0,d00_tanh0,(TR*(ICO-0.5)))
491 #endif
492 _load_static_residual1(COn1,((-0.5)*(1+d00_tanh0)));
493 #if defined(_DERIVATE)
494 _load_static_jacobian1(COn1,CI,((-0.5)*(TR*ICO_VCI_GND)*d10_tanh0));
495 _load_static_jacobian1(COn1,B,((-0.5)*(TR*ICO_VB_GND)*d10_tanh0));
496 _load_static_jacobian1(COn1,A,((-0.5)*(TR*ICO_VA_GND)*d10_tanh0));
497 #endif
498 }
500 #if defined(_DERIVATE)
502 #endif
504 #if defined(_DERIVATE)
506 #endif
507 #if defined(_DYNAMIC)
509 #if defined(_DERIVATE)
511 #endif
512 #endif
514 #if defined(_DERIVATE)
516 #endif
518 #if defined(_DERIVATE)
520 #endif
521 
522 /* ------------------ end of verilog analog equations --------------------- */
523 
524 /* ------------------ evaluate verilog noise equations -------------------- */
525 
526 /* ------------------- end of verilog noise equations --------------------- */
527 }
528 
529 /* Perform DC iteration. */
530 void fa1b::calcDC (void)
531 {
532  // evaluate Verilog code
533  initVerilog ();
534  calcVerilog ();
535 
536  // fill right hand side and static jacobian
537  for (int i1 = 0; i1 < 9; i1++) {
538  setI (i1, _rhs[i1]);
539  for (int i2 = 0; i2 < 9; i2++) {
540  setY (i1, i2, _jstat[i1][i2]);
541  }
542  }
543 }
544 
545 /* Save operating points. */
547 {
548  // save global instance operating points
549 }
550 
551 /* Load operating points. */
553 {
554 }
555 
556 /* Calculate operating points. */
558 {
559 }
560 
561 /* Initialization of AC analysis. */
562 void fa1b::initAC (void)
563 {
564  allocMatrixMNA ();
565 }
566 
567 /* Perform AC calculations. */
568 void fa1b::calcAC (nr_double_t frequency)
569 {
570  setMatrixY (calcMatrixY (frequency));
571 }
572 
573 /* Compute Y-matrix for AC analysis. */
574 matrix fa1b::calcMatrixY (nr_double_t frequency)
575 {
576  _freq = frequency;
578  matrix y (9);
579 
580  for (int i1 = 0; i1 < 9; i1++) {
581  for (int i2 = 0; i2 < 9; i2++) {
582  y (i1,i2) = rect (_jstat[i1][i2], _jdyna[i1][i2] * 2 * M_PI * _freq);
583  }
584  }
585 
586  return y;
587 }
588 
589 /* Initialization of S-parameter analysis. */
590 void fa1b::initSP (void)
591 {
592  allocMatrixS ();
593 }
594 
595 /* Perform S-parameter calculations. */
596 void fa1b::calcSP (nr_double_t frequency)
597 {
598  setMatrixS (ytos (calcMatrixY (frequency)));
599 }
600 
601 /* Initialization of transient analysis. */
602 void fa1b::initTR (void)
603 {
604  setStates (2 * 9 * 9);
605  initDC ();
606 }
607 
608 /* Perform transient analysis iteration step. */
609 void fa1b::calcTR (nr_double_t)
610 {
611  doHB = 0;
612  doAC = 1;
613  doTR = 1;
614  calcDC ();
615 
616  int i1, i2, i3, i4, state;
617 
618  // 2-node charge integrations
619  for (i1 = 0; i1 < 9; i1++) {
620  for (i2 = 0; i2 < 9; i2++) {
621  state = 2 * (i2 + 9 * i1);
622  if (i1 != i2)
623  if (_charges[i1][i2] != 0.0)
624  transientCapacitanceQ (state, i1, i2, _charges[i1][i2]);
625  } }
626 
627  // 1-node charge integrations
628  for (i1 = 0; i1 < 9; i1++) {
629  state = 2 * (i1 + 9 * i1);
630  if (_charges[i1][i1] != 0.0)
631  transientCapacitanceQ (state, i1, _charges[i1][i1]);
632  }
633 
634  // charge: 2-node, voltage: 2-node
635  for (i1 = 0; i1 < 9; i1++) {
636  for (i2 = 0; i2 < 9; i2++) {
637  if (i1 != i2)
638  for (i3 = 0; i3 < 9; i3++) {
639  for (i4 = 0; i4 < 9; i4++) {
640  if (i3 != i4)
641  if (_caps[i1][i2][i3][i4] != 0.0)
642  transientCapacitanceC (i1, i2, i3, i4, _caps[i1][i2][i3][i4], BP(i3,i4));
643  } } } }
644 
645  // charge: 2-node, voltage: 1-node
646  for (i1 = 0; i1 < 9; i1++) {
647  for (i2 = 0; i2 < 9; i2++) {
648  if (i1 != i2)
649  for (i3 = 0; i3 < 9; i3++) {
650  if (_caps[i1][i2][i3][i3] != 0.0)
651  transientCapacitanceC2Q (i1, i2, i3, _caps[i1][i2][i3][i3], NP(i3));
652  } } }
653 
654  // charge: 1-node, voltage: 2-node
655  for (i1 = 0; i1 < 9; i1++) {
656  for (i3 = 0; i3 < 9; i3++) {
657  for (i4 = 0; i4 < 9; i4++) {
658  if (i3 != i4)
659  if (_caps[i1][i1][i3][i4] != 0.0)
660  transientCapacitanceC2V (i1, i3, i4, _caps[i1][i1][i3][i4], BP(i3,i4));
661  } } }
662 
663  // charge: 1-node, voltage: 1-node
664  for (i1 = 0; i1 < 9; i1++) {
665  for (i3 = 0; i3 < 9; i3++) {
666  if (_caps[i1][i1][i3][i3] != 0.0)
667  transientCapacitanceC (i1, i3, _caps[i1][i1][i3][i3], NP(i3));
668  } }
669 }
670 
671 /* Compute Cy-matrix for AC noise analysis. */
672 matrix fa1b::calcMatrixCy (nr_double_t frequency)
673 {
674  _freq = frequency;
675  matrix cy (9);
676 
677 
678  return cy;
679 }
680 
681 /* Perform AC noise computations. */
682 void fa1b::calcNoiseAC (nr_double_t frequency)
683 {
684  setMatrixN (calcMatrixCy (frequency));
685 }
686 
687 /* Perform S-parameter noise computations. */
688 void fa1b::calcNoiseSP (nr_double_t frequency)
689 {
690  setMatrixN (cytocs (calcMatrixCy (frequency) * z0, getMatrixS ()));
691 }
692 
693 /* Initialization of HB analysis. */
694 void fa1b::initHB (int)
695 {
696  initDC ();
697  allocMatrixHB ();
698 }
699 
700 /* Perform HB analysis. */
701 void fa1b::calcHB (int)
702 {
703  doHB = 1;
704  doAC = 1;
705  doTR = 0;
706 
707  // jacobian dI/dV and currents get filled
708  calcDC ();
710 
711  // fill in HB matrices
712  for (int i1 = 0; i1 < 9; i1++) {
713  setQ (i1, _qhs[i1]); // charges
714  setCV (i1, _chs[i1]); // jacobian dQ/dV * V
715  setGV (i1, _ghs[i1]); // jacobian dI/dV * V
716  for (int i2 = 0; i2 < 9; i2++) {
717  setQV (i1, i2, _jdyna[i1][i2]); // jacobian dQ/dV
718  }
719  }
720 }
721 
722 #include "fa1b.defs.h"