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