My Project  0.0.16
QUCS Mapping
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
msstep.cpp
Go to the documentation of this file.
1 /*
2  * msstep.cpp - microstrip impedance step class implementation
3  *
4  * Copyright (C) 2004, 2007, 2008 Stefan Jahn <stefan@lkcc.org>
5  * Copyright (C) 2004 Michael Margraf <Michael.Margraf@alumni.TU-Berlin.DE>
6  *
7  * This is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2, or (at your option)
10  * any later version.
11  *
12  * This software is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this package; see the file COPYING. If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
20  * Boston, MA 02110-1301, USA.
21  *
22  * $Id: msstep.cpp 1825 2011-03-11 20:42:14Z ela $
23  *
24  */
25 
26 #if HAVE_CONFIG_H
27 # include <config.h>
28 #endif
29 
30 #include "component.h"
31 #include "substrate.h"
32 #include "msline.h"
33 #include "msstep.h"
34 
35 msstep::msstep () : circuit (2) {
36  type = CIR_MSSTEP;
37 }
38 
39 void msstep::calcSP (nr_double_t frequency) {
40  setMatrixS (ztos (calcMatrixZ (frequency)));
41 }
42 
43 matrix msstep::calcMatrixZ (nr_double_t frequency) {
44 
45  /* how to get properties of this component, e.g. W */
46  nr_double_t W1 = getPropertyDouble ("W1");
47  nr_double_t W2 = getPropertyDouble ("W2");
48  char * SModel = getPropertyString ("MSModel");
49  char * DModel = getPropertyString ("MSDispModel");
50 
51  /* how to get properties of the substrate, e.g. Er, H */
52  substrate * subst = getSubstrate ();
53  nr_double_t er = subst->getPropertyDouble ("er");
54  nr_double_t h = subst->getPropertyDouble ("h");
55  nr_double_t t = subst->getPropertyDouble ("t");
56 
57  // compute parallel capacitance
58  nr_double_t t1 = log10 (er);
59  nr_double_t t2 = W1 / W2;
60  nr_double_t Cs = sqrt (W1 * W2) *
61  (t2 * (10.1 * t1 + 2.33) - 12.6 * t1 - 3.17);
62 
63  // compute series inductance
64  t1 = log10 (t2);
65  t2 = t2 - 1;
66  nr_double_t Ls = h * (t2 * (40.5 + 0.2 * t2) - 75 * t1);
67 
68  nr_double_t ZlEff, ErEff, WEff, ZlEffFreq, ErEffFreq;
69  msline::analyseQuasiStatic (W1, h, t, er, SModel, ZlEff, ErEff, WEff);
70  msline::analyseDispersion (W1, h, er, ZlEff, ErEff, frequency, DModel,
71  ZlEffFreq, ErEffFreq);
72  nr_double_t L1 = ZlEffFreq * sqrt (ErEffFreq) / C0;
73 
74  msline::analyseQuasiStatic (W2, h, t, er, SModel, ZlEff, ErEff, WEff);
75  msline::analyseDispersion (W2, h, er, ZlEff, ErEff, frequency, DModel,
76  ZlEffFreq, ErEffFreq);
77  nr_double_t L2 = ZlEffFreq * sqrt (ErEffFreq) / C0;
78 
79  Ls /= (L1 + L2);
80  L1 *= Ls;
81  L2 *= Ls;
82 
83  // build Z-parameter matrix
84  nr_complex_t z21 = rect (0.0, -0.5e12 / (M_PI * frequency * Cs));
85  nr_complex_t z11 = rect (0.0, 2e-9 * M_PI * frequency * L1) + z21;
86  nr_complex_t z22 = rect (0.0, 2e-9 * M_PI * frequency * L2) + z21;
87  matrix z (2);
88  z.set (0, 0, z11);
89  z.set (0, 1, z21);
90  z.set (1, 0, z21);
91  z.set (1, 1, z22);
92  return z;
93 }
94 
95 void msstep::initDC (void) {
96  // a DC short (voltage source V = 0 volts)
99  allocMatrixMNA ();
100  clearY ();
102 }
103 
104 void msstep::initAC (void) {
105  setVoltageSources (0);
106  allocMatrixMNA ();
107 }
108 
109 void msstep::calcAC (nr_double_t frequency) {
110  setMatrixY (ztoy (calcMatrixZ (frequency)));
111 }
112 
113 void msstep::initTR (void) {
114  initDC ();
115 }
116 
117 // properties
118 PROP_REQ [] = {
119  { "W1", PROP_REAL, { 1e-3, PROP_NO_STR }, PROP_POS_RANGE },
120  { "W2", PROP_REAL, { 1e-3, PROP_NO_STR }, PROP_POS_RANGE },
121  { "Subst", PROP_STR, { PROP_NO_VAL, "Subst1" }, PROP_NO_RANGE },
122  { "MSDispModel", PROP_STR, { PROP_NO_VAL, "Kirschning" }, PROP_RNG_DIS },
123  { "MSModel", PROP_STR, { PROP_NO_VAL, "Hammerstad" }, PROP_RNG_MOD },
124  PROP_NO_PROP };
125 PROP_OPT [] = {
126  PROP_NO_PROP };
127 struct define_t msstep::cirdef =