My Project  0.0.16
QUCS Mapping
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
comp_1bit.core.cpp
Go to the documentation of this file.
1 /*
2  * comp_1bit.core.cpp - device implementations for comp_1bit 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 "comp_1bit.core.h"
19 
20 #ifndef CIR_comp_1bit
21 #define CIR_comp_1bit -1
22 #endif
23 
24 // external nodes
25 #define X 0
26 #define Y 1
27 #define L 2
28 #define G 3
29 #define E 4
30 // internal nodes
31 #define Ln1 5
32 #define Ln2 6
33 #define Gn1 7
34 #define Gn2 8
35 #define En1 9
36 #define En2 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 "comp_1bit"
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_comp_1bit;
253 }
254 
255 /* Initialization of model. */
256 void comp_1bit::initModel (void)
257 {
258  // create internal nodes
259  setInternalNode (Ln1, "Ln1");
260  setInternalNode (Ln2, "Ln2");
261  setInternalNode (Gn1, "Gn1");
262  setInternalNode (Gn2, "Gn2");
263  setInternalNode (En1, "En1");
264  setInternalNode (En2, "En2");
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 comp_1bit::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 comp_1bit::initVerilog (void)
295 {
296  // initialization of noise variables
297 
298  int i1, i2, i3, i4;
299 
300  // zero charges
301  for (i1 = 0; i1 < 11; i1++) {
302  for (i2 = 0; i2 < 11; i2++) {
303  _charges[i1][i2] = 0.0;
304  } }
305 
306  // zero capacitances
307  for (i1 = 0; i1 < 11; i1++) {
308  for (i2 = 0; i2 < 11; i2++) {
309  for (i3 = 0; i3 < 11; i3++) {
310  for (i4 = 0; i4 < 11; 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 < 11; 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 < 11; 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 comp_1bit::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 comp_1bit::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 comp_1bit::initializeInstance (void)
357 {
358 }
359 
360 /* Evaluate Verilog-AMS equations in initial step. */
361 void comp_1bit::initialStep (void)
362 {
363 }
364 
365 /* Evaluate Verilog-AMS equations in final step. */
366 void comp_1bit::finalStep (void)
367 {
368 }
369 
370 /* Evaluate Verilog-AMS equations in analog block. */
371 void comp_1bit::calcVerilog (void)
372 {
373 
374 /* ----------------- evaluate verilog analog equations -------------------- */
375 double mL;
376 #if defined(_DERIVATE)
377 double mL_VX_GND;
378 double mL_VY_GND;
379 #endif
380 double mG;
381 #if defined(_DERIVATE)
382 double mG_VX_GND;
383 double mG_VY_GND;
384 #endif
385 double mE;
386 #if defined(_DERIVATE)
387 double mE_VX_GND;
388 double mE_VY_GND;
389 #endif
390 #if defined(_DERIVATE)
391 mE_VX_GND=(-(((1-NP(Y)))+(-1.0)*NP(Y)));
392 mE_VY_GND=(-((NP(X)*(-1.0))+((1-NP(X)))));
393 #endif
394 mE=(1-((NP(X)*(1-NP(Y)))+((1-NP(X))*NP(Y))));
395 #if defined(_DERIVATE)
396 mG_VX_GND=((1-NP(Y)));
397 mG_VY_GND=(NP(X)*(-1.0));
398 #endif
399 mG=(NP(X)*(1-NP(Y)));
400 #if defined(_DERIVATE)
401 mL_VX_GND=(-1.0)*NP(Y);
402 mL_VY_GND=((1-NP(X)));
403 #endif
404 mL=((1-NP(X))*NP(Y));
405 {
406 double m00_tanh(d00_tanh0,(TR*(mE-0.5)))
407 #if defined(_DERIVATE)
408 double m10_tanh(d10_tanh0,d00_tanh0,(TR*(mE-0.5)))
409 #endif
410 _load_static_residual1(En1,((-0.5)*(1+d00_tanh0)));
411 #if defined(_DERIVATE)
412 _load_static_jacobian1(En1,Y,((-0.5)*(TR*mE_VY_GND)*d10_tanh0));
413 _load_static_jacobian1(En1,X,((-0.5)*(TR*mE_VX_GND)*d10_tanh0));
414 #endif
415 }
417 #if defined(_DERIVATE)
419 #endif
421 #if defined(_DERIVATE)
423 #endif
424 #if defined(_DYNAMIC)
426 #if defined(_DERIVATE)
428 #endif
429 #endif
431 #if defined(_DERIVATE)
433 #endif
435 #if defined(_DERIVATE)
437 #endif
438 {
439 double m00_tanh(d00_tanh0,(TR*(mG-0.5)))
440 #if defined(_DERIVATE)
441 double m10_tanh(d10_tanh0,d00_tanh0,(TR*(mG-0.5)))
442 #endif
443 _load_static_residual1(Gn1,((-0.5)*(1+d00_tanh0)));
444 #if defined(_DERIVATE)
445 _load_static_jacobian1(Gn1,Y,((-0.5)*(TR*mG_VY_GND)*d10_tanh0));
446 _load_static_jacobian1(Gn1,X,((-0.5)*(TR*mG_VX_GND)*d10_tanh0));
447 #endif
448 }
450 #if defined(_DERIVATE)
452 #endif
454 #if defined(_DERIVATE)
456 #endif
457 #if defined(_DYNAMIC)
459 #if defined(_DERIVATE)
461 #endif
462 #endif
464 #if defined(_DERIVATE)
466 #endif
468 #if defined(_DERIVATE)
470 #endif
471 {
472 double m00_tanh(d00_tanh0,(TR*(mL-0.5)))
473 #if defined(_DERIVATE)
474 double m10_tanh(d10_tanh0,d00_tanh0,(TR*(mL-0.5)))
475 #endif
476 _load_static_residual1(Ln1,((-0.5)*(1+d00_tanh0)));
477 #if defined(_DERIVATE)
478 _load_static_jacobian1(Ln1,Y,((-0.5)*(TR*mL_VY_GND)*d10_tanh0));
479 _load_static_jacobian1(Ln1,X,((-0.5)*(TR*mL_VX_GND)*d10_tanh0));
480 #endif
481 }
483 #if defined(_DERIVATE)
485 #endif
487 #if defined(_DERIVATE)
489 #endif
490 #if defined(_DYNAMIC)
492 #if defined(_DERIVATE)
494 #endif
495 #endif
497 #if defined(_DERIVATE)
499 #endif
501 #if defined(_DERIVATE)
503 #endif
504 
505 /* ------------------ end of verilog analog equations --------------------- */
506 
507 /* ------------------ evaluate verilog noise equations -------------------- */
508 
509 /* ------------------- end of verilog noise equations --------------------- */
510 }
511 
512 /* Perform DC iteration. */
513 void comp_1bit::calcDC (void)
514 {
515  // evaluate Verilog code
516  initVerilog ();
517  calcVerilog ();
518 
519  // fill right hand side and static jacobian
520  for (int i1 = 0; i1 < 11; i1++) {
521  setI (i1, _rhs[i1]);
522  for (int i2 = 0; i2 < 11; i2++) {
523  setY (i1, i2, _jstat[i1][i2]);
524  }
525  }
526 }
527 
528 /* Save operating points. */
530 {
531  // save global instance operating points
532 }
533 
534 /* Load operating points. */
536 {
537 }
538 
539 /* Calculate operating points. */
541 {
542 }
543 
544 /* Initialization of AC analysis. */
545 void comp_1bit::initAC (void)
546 {
547  allocMatrixMNA ();
548 }
549 
550 /* Perform AC calculations. */
551 void comp_1bit::calcAC (nr_double_t frequency)
552 {
553  setMatrixY (calcMatrixY (frequency));
554 }
555 
556 /* Compute Y-matrix for AC analysis. */
557 matrix comp_1bit::calcMatrixY (nr_double_t frequency)
558 {
559  _freq = frequency;
561  matrix y (11);
562 
563  for (int i1 = 0; i1 < 11; i1++) {
564  for (int i2 = 0; i2 < 11; i2++) {
565  y (i1,i2) = rect (_jstat[i1][i2], _jdyna[i1][i2] * 2 * M_PI * _freq);
566  }
567  }
568 
569  return y;
570 }
571 
572 /* Initialization of S-parameter analysis. */
573 void comp_1bit::initSP (void)
574 {
575  allocMatrixS ();
576 }
577 
578 /* Perform S-parameter calculations. */
579 void comp_1bit::calcSP (nr_double_t frequency)
580 {
581  setMatrixS (ytos (calcMatrixY (frequency)));
582 }
583 
584 /* Initialization of transient analysis. */
585 void comp_1bit::initTR (void)
586 {
587  setStates (2 * 11 * 11);
588  initDC ();
589 }
590 
591 /* Perform transient analysis iteration step. */
592 void comp_1bit::calcTR (nr_double_t)
593 {
594  doHB = 0;
595  doAC = 1;
596  doTR = 1;
597  calcDC ();
598 
599  int i1, i2, i3, i4, state;
600 
601  // 2-node charge integrations
602  for (i1 = 0; i1 < 11; i1++) {
603  for (i2 = 0; i2 < 11; i2++) {
604  state = 2 * (i2 + 11 * i1);
605  if (i1 != i2)
606  if (_charges[i1][i2] != 0.0)
607  transientCapacitanceQ (state, i1, i2, _charges[i1][i2]);
608  } }
609 
610  // 1-node charge integrations
611  for (i1 = 0; i1 < 11; i1++) {
612  state = 2 * (i1 + 11 * i1);
613  if (_charges[i1][i1] != 0.0)
614  transientCapacitanceQ (state, i1, _charges[i1][i1]);
615  }
616 
617  // charge: 2-node, voltage: 2-node
618  for (i1 = 0; i1 < 11; i1++) {
619  for (i2 = 0; i2 < 11; i2++) {
620  if (i1 != i2)
621  for (i3 = 0; i3 < 11; i3++) {
622  for (i4 = 0; i4 < 11; i4++) {
623  if (i3 != i4)
624  if (_caps[i1][i2][i3][i4] != 0.0)
625  transientCapacitanceC (i1, i2, i3, i4, _caps[i1][i2][i3][i4], BP(i3,i4));
626  } } } }
627 
628  // charge: 2-node, voltage: 1-node
629  for (i1 = 0; i1 < 11; i1++) {
630  for (i2 = 0; i2 < 11; i2++) {
631  if (i1 != i2)
632  for (i3 = 0; i3 < 11; i3++) {
633  if (_caps[i1][i2][i3][i3] != 0.0)
634  transientCapacitanceC2Q (i1, i2, i3, _caps[i1][i2][i3][i3], NP(i3));
635  } } }
636 
637  // charge: 1-node, voltage: 2-node
638  for (i1 = 0; i1 < 11; i1++) {
639  for (i3 = 0; i3 < 11; i3++) {
640  for (i4 = 0; i4 < 11; i4++) {
641  if (i3 != i4)
642  if (_caps[i1][i1][i3][i4] != 0.0)
643  transientCapacitanceC2V (i1, i3, i4, _caps[i1][i1][i3][i4], BP(i3,i4));
644  } } }
645 
646  // charge: 1-node, voltage: 1-node
647  for (i1 = 0; i1 < 11; i1++) {
648  for (i3 = 0; i3 < 11; i3++) {
649  if (_caps[i1][i1][i3][i3] != 0.0)
650  transientCapacitanceC (i1, i3, _caps[i1][i1][i3][i3], NP(i3));
651  } }
652 }
653 
654 /* Compute Cy-matrix for AC noise analysis. */
655 matrix comp_1bit::calcMatrixCy (nr_double_t frequency)
656 {
657  _freq = frequency;
658  matrix cy (11);
659 
660 
661  return cy;
662 }
663 
664 /* Perform AC noise computations. */
665 void comp_1bit::calcNoiseAC (nr_double_t frequency)
666 {
667  setMatrixN (calcMatrixCy (frequency));
668 }
669 
670 /* Perform S-parameter noise computations. */
671 void comp_1bit::calcNoiseSP (nr_double_t frequency)
672 {
673  setMatrixN (cytocs (calcMatrixCy (frequency) * z0, getMatrixS ()));
674 }
675 
676 /* Initialization of HB analysis. */
678 {
679  initDC ();
680  allocMatrixHB ();
681 }
682 
683 /* Perform HB analysis. */
685 {
686  doHB = 1;
687  doAC = 1;
688  doTR = 0;
689 
690  // jacobian dI/dV and currents get filled
691  calcDC ();
693 
694  // fill in HB matrices
695  for (int i1 = 0; i1 < 11; i1++) {
696  setQ (i1, _qhs[i1]); // charges
697  setCV (i1, _chs[i1]); // jacobian dQ/dV * V
698  setGV (i1, _ghs[i1]); // jacobian dI/dV * V
699  for (int i2 = 0; i2 < 11; i2++) {
700  setQV (i1, i2, _jdyna[i1][i2]); // jacobian dQ/dV
701  }
702  }
703 }
704 
705 #include "comp_1bit.defs.h"