Qucs-core  0.0.18
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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$
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 using namespace qucs;
36 
37 msstep::msstep () : circuit (2) {
38  type = CIR_MSSTEP;
39 }
40 
41 void msstep::calcSP (nr_double_t frequency) {
42  setMatrixS (ztos (calcMatrixZ (frequency)));
43 }
44 
45 matrix msstep::calcMatrixZ (nr_double_t frequency) {
46 
47  /* how to get properties of this component, e.g. W */
48  nr_double_t W1 = getPropertyDouble ("W1");
49  nr_double_t W2 = getPropertyDouble ("W2");
50  char * SModel = getPropertyString ("MSModel");
51  char * DModel = getPropertyString ("MSDispModel");
52 
53  /* how to get properties of the substrate, e.g. Er, H */
55  nr_double_t er = subst->getPropertyDouble ("er");
56  nr_double_t h = subst->getPropertyDouble ("h");
57  nr_double_t t = subst->getPropertyDouble ("t");
58 
59  // compute parallel capacitance
60  nr_double_t t1 = std::log10 (er);
61  nr_double_t t2 = W1 / W2;
62  nr_double_t Cs = std::sqrt (W1 * W2) *
63  (t2 * (10.1 * t1 + 2.33) - 12.6 * t1 - 3.17);
64 
65  // compute series inductance
66  t1 = std::log10 (t2);
67  t2 = t2 - 1;
68  nr_double_t Ls = h * (t2 * (40.5 + 0.2 * t2) - 75 * t1);
69 
70  nr_double_t ZlEff, ErEff, WEff, ZlEffFreq, ErEffFreq;
71  msline::analyseQuasiStatic (W1, h, t, er, SModel, ZlEff, ErEff, WEff);
72  msline::analyseDispersion (W1, h, er, ZlEff, ErEff, frequency, DModel,
73  ZlEffFreq, ErEffFreq);
74  nr_double_t L1 = ZlEffFreq * std::sqrt (ErEffFreq) / C0;
75 
76  msline::analyseQuasiStatic (W2, h, t, er, SModel, ZlEff, ErEff, WEff);
77  msline::analyseDispersion (W2, h, er, ZlEff, ErEff, frequency, DModel,
78  ZlEffFreq, ErEffFreq);
79  nr_double_t L2 = ZlEffFreq * std::sqrt (ErEffFreq) / C0;
80 
81  Ls /= (L1 + L2);
82  L1 *= Ls;
83  L2 *= Ls;
84 
85  // build Z-parameter matrix
86  nr_complex_t z21 = nr_complex_t (0.0, -0.5e12 / (M_PI * frequency * Cs));
87  nr_complex_t z11 = nr_complex_t (0.0, 2e-9 * M_PI * frequency * L1) + z21;
88  nr_complex_t z22 = nr_complex_t (0.0, 2e-9 * M_PI * frequency * L2) + z21;
89  matrix z (2);
90  z.set (0, 0, z11);
91  z.set (0, 1, z21);
92  z.set (1, 0, z21);
93  z.set (1, 1, z22);
94  return z;
95 }
96 
97 void msstep::initDC (void) {
98  // a DC short (voltage source V = 0 volts)
101  allocMatrixMNA ();
102  clearY ();
104 }
105 
106 void msstep::initAC (void) {
107  setVoltageSources (0);
108  allocMatrixMNA ();
109 }
110 
111 void msstep::calcAC (nr_double_t frequency) {
112  setMatrixY (ztoy (calcMatrixZ (frequency)));
113 }
114 
115 void msstep::initTR (void) {
116  initDC ();
117 }
118 
119 // properties
120 PROP_REQ [] = {
121  { "W1", PROP_REAL, { 1e-3, PROP_NO_STR }, PROP_POS_RANGE },
122  { "W2", PROP_REAL, { 1e-3, PROP_NO_STR }, PROP_POS_RANGE },
123  { "Subst", PROP_STR, { PROP_NO_VAL, "Subst1" }, PROP_NO_RANGE },
124  { "MSDispModel", PROP_STR, { PROP_NO_VAL, "Kirschning" }, PROP_RNG_DIS },
125  { "MSModel", PROP_STR, { PROP_NO_VAL, "Hammerstad" }, PROP_RNG_MOD },
126  PROP_NO_PROP };
127 PROP_OPT [] = {
128  PROP_NO_PROP };
129 struct define_t msstep::cirdef =
std::complex< nr_double_t > nr_complex_t
Definition: complex.h:31
#define PROP_POS_RANGE
Definition: netdefs.h:129
void clearY(void)
Definition: circuit.cpp:740
#define NODE_2
Definition: circuit.h:35
substrate * subst
Definition: circuit.h:350
#define PROP_DEF
Definition: netdefs.h:189
nr_double_t getPropertyDouble(const char *)
Definition: object.cpp:176
#define PROP_REAL
Definition: netdefs.h:174
substrate * getSubstrate(void)
Definition: circuit.cpp:332
void setInternalVoltageSource(bool i)
Definition: circuit.h:184
t
Definition: parse_vcd.y:290
#define PROP_NO_PROP
Definition: netdefs.h:122
void setVoltageSources(int)
Definition: circuit.cpp:607
#define PROP_NO_RANGE
Definition: netdefs.h:126
#define PROP_NO_STR
Definition: netdefs.h:125
void initDC(void)
Definition: msstep.cpp:97
#define PROP_RNG_MOD
Definition: netdefs.h:169
#define PROP_LINEAR
Definition: netdefs.h:120
h
Definition: parse_vcd.y:214
#define PROP_RNG_DIS
Definition: netdefs.h:166
#define VSRC_1
Definition: circuit.h:40
nr_complex_t sqrt(const nr_complex_t z)
Compute principal value of square root.
Definition: complex.cpp:271
#define PROP_COMPONENT
Definition: netdefs.h:116
matrix ztos(matrix z, qucs::vector z0)
Convert impedance matrix scattering parameters.
Definition: matrix.cpp:1018
PROP_OPT[]
Definition: msstep.cpp:127
void initTR(void)
Definition: msstep.cpp:115
void setMatrixY(matrix)
Definition: circuit.cpp:685
nr_complex_t log10(const nr_complex_t z)
Compute principal value of decimal logarithm of z.
Definition: complex.cpp:225
qucs::matrix calcMatrixZ(nr_double_t)
Definition: msstep.cpp:45
#define M_PI
Archimedes' constant ( )
Definition: consts.h:47
void setMatrixS(matrix)
Definition: circuit.cpp:643
void initAC(void)
Definition: msstep.cpp:106
void allocMatrixMNA(void)
Definition: circuit.cpp:267
#define PROP_STR
Definition: netdefs.h:175
void calcAC(nr_double_t)
Definition: msstep.cpp:111
#define NODE_1
Definition: circuit.h:34
#define C0
speed of light in vacuum ( )
Definition: constants.h:47
void voltageSource(int, int, int, nr_double_t value=0.0)
Definition: circuit.cpp:748
static void analyseQuasiStatic(nr_double_t, nr_double_t, nr_double_t, nr_double_t, char *, nr_double_t &, nr_double_t &, nr_double_t &)
Definition: msline.cpp:115
PROP_NO_SUBSTRATE
Definition: msstep.cpp:130
#define PROP_NO_VAL
Definition: netdefs.h:124
PROP_REQ[]
Definition: msstep.cpp:120
static void analyseDispersion(nr_double_t, nr_double_t, nr_double_t, nr_double_t, nr_double_t, nr_double_t, char *, nr_double_t &, nr_double_t &)
Definition: msline.cpp:229
char * getPropertyString(const char *)
Definition: object.cpp:159
void calcSP(nr_double_t)
Definition: msstep.cpp:41
matrix ztoy(matrix z)
impedance matrix to admittance matrix.
Definition: matrix.cpp:1050