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