Qucs-core  0.0.18
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mscross.cpp
Go to the documentation of this file.
1 /*
2  * mscross.cpp - microstrip cross-junction class implementation
3  *
4  * Copyright (C) 2004, 2007, 2008 Stefan Jahn <stefan@lkcc.org>
5  *
6  * This is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * This software is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this package; see the file COPYING. If not, write to
18  * the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  *
21  * $Id$
22  *
23  */
24 
25 #if HAVE_CONFIG_H
26 # include <config.h>
27 #endif
28 
29 #include "component.h"
30 #include "substrate.h"
31 #include "msline.h"
32 #include "mscross.h"
33 
34 using namespace qucs;
35 
36 mscross::mscross () : circuit (6) {
37  type = CIR_MSCROSS;
38 }
39 
40 void mscross::initModel (void) {
41  setNode (NODE_5, createInternal (getName (), "i13"));
42  setNode (NODE_6, createInternal (getName (), "i24"));
43 }
44 
45 void mscross::initSP (void) {
46  initModel ();
47  allocMatrixS ();
48 }
49 
50 void mscross::calcSP (nr_double_t frequency) {
51  setMatrixS (ytos (calcMatrixY (frequency)));
52 }
53 
54 void mscross::initDC (void) {
55  initModel ();
57  allocMatrixMNA ();
63 }
64 
65 void mscross::initAC (void) {
66  initModel ();
68  allocMatrixMNA ();
69 }
70 
71 void mscross::calcAC (nr_double_t frequency) {
72  setMatrixY (calcMatrixY (frequency));
73 }
74 
75 nr_double_t mscross::capCorrection (nr_double_t W, nr_double_t f) {
77  nr_double_t er = subst->getPropertyDouble ("er");
78  nr_double_t h = subst->getPropertyDouble ("h");
79  nr_double_t t = subst->getPropertyDouble ("t");
80  char * SModel = getPropertyString ("MSModel");
81  char * DModel = getPropertyString ("MSDispModel");
82  nr_double_t Zl1, Er1, Zl2, Er2;
83  nr_double_t ZlEff, ErEff, WEff;
84  msline::analyseQuasiStatic (W, h, t, 9.9, SModel, ZlEff, ErEff, WEff);
85  msline::analyseDispersion (W, h, 9.9, ZlEff, ErEff, f, DModel,
86  Zl1, Er1);
87  msline::analyseQuasiStatic (W, h, t, er, SModel, ZlEff, ErEff, WEff);
88  msline::analyseDispersion (W, h, er, ZlEff, ErEff, f, DModel,
89  Zl2, Er2);
90  return Zl1 / Zl2 * qucs::sqrt (Er2 / Er1);
91 }
92 
93 nr_double_t mscross::calcCap (nr_double_t W1, nr_double_t h, nr_double_t W2) {
94  nr_double_t W1h = W1 / h;
95  nr_double_t W2h = W2 / h;
96  nr_double_t X = qucs::log10 (W1h) * (86.6 * W2h - 30.9 * qucs::sqrt (W2h) + 367) +
97  cubic (W2h) + 74 * W2h + 130;
98  return 1e-12 * W1 * (0.25 * X * qucs::pow (W1h, -1.0 / 3.0) - 60 +
99  1 / W2h / 2 - 0.375 * W1h * (1 - W2h));
100  }
101 
102 nr_double_t mscross::calcInd (nr_double_t W1, nr_double_t h, nr_double_t W2) {
103  nr_double_t W1h = W1 / h;
104  nr_double_t W2h = W2 / h;
105  nr_double_t Y = 165.6 * W2h + 31.2 * qucs::sqrt (W2h) - 11.8 * sqr (W2h);
106  return 1e-9 * h * (Y * W1h - 32 * W2h + 3) * qucs::pow (W1h, -1.5);
107 }
108 
109 matrix mscross::calcMatrixY (nr_double_t f) {
110  nr_double_t W1 = getPropertyDouble ("W1");
111  nr_double_t W2 = getPropertyDouble ("W2");
112  nr_double_t W3 = getPropertyDouble ("W3");
113  nr_double_t W4 = getPropertyDouble ("W4");
115  nr_double_t h = subst->getPropertyDouble ("h");
116  nr_double_t W1h = (W1 + W3) / 2 / h;
117  nr_double_t W2h = (W2 + W4) / 2 / h;
118  nr_double_t C1, C2, C3, C4, L1, L2, L3, L4, L5;
119 
120  // apply asymmetric modifications of original model
121  C1 = calcCap (W1, h, (W2 + W4) / 2);
122  C2 = calcCap (W2, h, (W1 + W3) / 2);
123  C3 = calcCap (W3, h, (W4 + W2) / 2);
124  C4 = calcCap (W4, h, (W3 + W1) / 2);
125 
126  L1 = calcInd (W1, h, (W2 + W4) / 2);
127  L2 = calcInd (W2, h, (W1 + W3) / 2);
128  L3 = calcInd (W3, h, (W4 + W2) / 2);
129  L4 = calcInd (W4, h, (W3 + W1) / 2);
130 
131  L5 = 1e-9 * h * (5 * W2h * qucs::cos (M_PI / 2 * (1.5 - W1h)) -
132  (1 + 7 / W1h ) / W2h - 337.5);
133 
134  // center inductance correction
135  L5 = L5 * 0.8;
136 
137  // capacitance corrections
138  C1 = C1 * capCorrection (W1, f);
139  C2 = C2 * capCorrection (W2, f);
140  C3 = C3 * capCorrection (W3, f);
141  C4 = C4 * capCorrection (W4, f);
142 
143  // compute admittance matrix
144  nr_double_t o = 2 * M_PI * f;
145  nr_complex_t yc1 = nr_complex_t (0, o * C1);
146  nr_complex_t yc2 = nr_complex_t (0, o * C2);
147  nr_complex_t yc3 = nr_complex_t (0, o * C3);
148  nr_complex_t yc4 = nr_complex_t (0, o * C4);
149  nr_complex_t yl1 = 1.0 / nr_complex_t (0, o * L1);
150  nr_complex_t yl2 = 1.0 / nr_complex_t (0, o * L2);
151  nr_complex_t yl3 = 1.0 / nr_complex_t (0, o * L3);
152  nr_complex_t yl4 = 1.0 / nr_complex_t (0, o * L4);
153  nr_complex_t yl5 = 1.0 / nr_complex_t (0, o * L5);
154  matrix Y (6);
155  Y.set (NODE_1, NODE_1, yl1 + yc1);
156  Y.set (NODE_2, NODE_2, yl2 + yc2);
157  Y.set (NODE_3, NODE_3, yl3 + yc3);
158  Y.set (NODE_4, NODE_4, yl4 + yc4);
159  Y.set (NODE_1, NODE_5, -yl1); Y.set (NODE_5, NODE_1, -yl1);
160  Y.set (NODE_3, NODE_5, -yl3); Y.set (NODE_5, NODE_3, -yl3);
161  Y.set (NODE_2, NODE_6, -yl2); Y.set (NODE_6, NODE_2, -yl2);
162  Y.set (NODE_4, NODE_6, -yl4); Y.set (NODE_6, NODE_4, -yl4);
163  Y.set (NODE_5, NODE_6, -yl5); Y.set (NODE_6, NODE_5, -yl5);
164  Y.set (NODE_5, NODE_5, yl1 + yl3 + yl5);
165  Y.set (NODE_6, NODE_6, yl2 + yl4 + yl5);
166  return Y;
167 }
168 
169 void mscross::initTR (void) {
170  initDC ();
171 }
172 
173 // properties
174 PROP_REQ [] = {
175  { "W1", PROP_REAL, { 1e-3, PROP_NO_STR }, PROP_POS_RANGE },
176  { "W2", PROP_REAL, { 2e-3, PROP_NO_STR }, PROP_POS_RANGE },
177  { "W3", PROP_REAL, { 1e-3, PROP_NO_STR }, PROP_POS_RANGE },
178  { "W4", PROP_REAL, { 2e-3, PROP_NO_STR }, PROP_POS_RANGE },
179  { "Subst", PROP_STR, { PROP_NO_VAL, "Subst1" }, PROP_NO_RANGE },
180  { "MSDispModel", PROP_STR, { PROP_NO_VAL, "Kirschning" }, PROP_RNG_DIS },
181  { "MSModel", PROP_STR, { PROP_NO_VAL, "Hammerstad" }, PROP_RNG_MOD },
182  PROP_NO_PROP };
183 PROP_OPT [] = {
184  PROP_NO_PROP };
185 struct define_t mscross::cirdef =
std::complex< nr_double_t > nr_complex_t
Definition: complex.h:31
#define PROP_POS_RANGE
Definition: netdefs.h:129
matrix ytos(matrix y, qucs::vector z0)
Admittance matrix to scattering parameters.
Definition: matrix.cpp:1133
#define NODE_2
Definition: circuit.h:35
substrate * subst
Definition: circuit.h:350
#define PROP_DEF
Definition: netdefs.h:189
PROP_REQ[]
Definition: mscross.cpp:174
void initModel(void)
Definition: mscross.cpp:40
nr_double_t getPropertyDouble(const char *)
Definition: object.cpp:176
nr_complex_t pow(const nr_complex_t z, const nr_double_t d)
Compute power function with real exponent.
Definition: complex.cpp:238
void calcSP(nr_double_t)
Definition: mscross.cpp:50
nr_complex_t cos(const nr_complex_t z)
Compute complex cosine.
Definition: complex.cpp:57
#define PROP_REAL
Definition: netdefs.h:174
qucs::matrix calcMatrixY(nr_double_t)
Definition: mscross.cpp:109
substrate * getSubstrate(void)
Definition: circuit.cpp:332
t
Definition: parse_vcd.y:290
#define VSRC_5
Definition: circuit.h:44
#define PROP_NO_PROP
Definition: netdefs.h:122
void setVoltageSources(int)
Definition: circuit.cpp:607
nr_double_t capCorrection(nr_double_t, nr_double_t)
Definition: mscross.cpp:75
#define PROP_NO_RANGE
Definition: netdefs.h:126
#define PROP_NO_STR
Definition: netdefs.h:125
void allocMatrixS(void)
Definition: circuit.cpp:251
#define PROP_RNG_MOD
Definition: netdefs.h:169
#define PROP_LINEAR
Definition: netdefs.h:120
h
Definition: parse_vcd.y:214
void initAC(void)
Definition: mscross.cpp:65
nr_double_t calcInd(nr_double_t, nr_double_t, nr_double_t)
Definition: mscross.cpp:102
#define PROP_RNG_DIS
Definition: netdefs.h:166
#define NODE_6
Definition: circuit.h:39
#define NODE_4
Definition: circuit.h:37
#define VSRC_1
Definition: circuit.h:40
nr_complex_t sqr(const nr_complex_t z)
Square of complex number.
Definition: complex.cpp:673
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
void initSP(void)
placehoder for S-Parameter initialisation function
Definition: mscross.cpp:45
void calcAC(nr_double_t)
Definition: mscross.cpp:71
#define VSRC_3
Definition: circuit.h:42
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
void initDC(void)
Definition: mscross.cpp:54
#define NODE_3
Definition: circuit.h:36
#define M_PI
Archimedes' constant ( )
Definition: consts.h:47
static char * createInternal(const char *, const char *)
Definition: circuit.cpp:626
void setMatrixS(matrix)
Definition: circuit.cpp:643
PROP_OPT[]
Definition: mscross.cpp:183
PROP_NO_SUBSTRATE
Definition: mscross.cpp:186
void allocMatrixMNA(void)
Definition: circuit.cpp:267
#define PROP_STR
Definition: netdefs.h:175
void setNode(int, const char *, int intern=0)
Definition: circuit.cpp:299
#define NODE_1
Definition: circuit.h:34
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
char * getName(void)
Definition: object.cpp:84
#define VSRC_4
Definition: circuit.h:43
#define PROP_NO_VAL
Definition: netdefs.h:124
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
void initTR(void)
Definition: mscross.cpp:169
#define VSRC_2
Definition: circuit.h:41
char * getPropertyString(const char *)
Definition: object.cpp:159
#define NODE_5
Definition: circuit.h:38
#define cubic(x)
Definition: constants.h:106
nr_double_t calcCap(nr_double_t, nr_double_t, nr_double_t)
Definition: mscross.cpp:93