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