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