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