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