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