My Project  0.0.16
QUCS Mapping
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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: mscross.cpp 1825 2011-03-11 20:42:14Z ela $
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 mscross::mscross () : circuit (6) {
35  type = CIR_MSCROSS;
36 }
37 
38 void mscross::initModel (void) {
39  setNode (NODE_5, createInternal (getName (), "i13"));
40  setNode (NODE_6, createInternal (getName (), "i24"));
41 }
42 
43 void mscross::initSP (void) {
44  initModel ();
45  allocMatrixS ();
46 }
47 
48 void mscross::calcSP (nr_double_t frequency) {
49  setMatrixS (ytos (calcMatrixY (frequency)));
50 }
51 
52 void mscross::initDC (void) {
53  initModel ();
55  allocMatrixMNA ();
61 }
62 
63 void mscross::initAC (void) {
64  initModel ();
66  allocMatrixMNA ();
67 }
68 
69 void mscross::calcAC (nr_double_t frequency) {
70  setMatrixY (calcMatrixY (frequency));
71 }
72 
73 nr_double_t mscross::capCorrection (nr_double_t W, nr_double_t f) {
74  substrate * subst = getSubstrate ();
75  nr_double_t er = subst->getPropertyDouble ("er");
76  nr_double_t h = subst->getPropertyDouble ("h");
77  nr_double_t t = subst->getPropertyDouble ("t");
78  char * SModel = getPropertyString ("MSModel");
79  char * DModel = getPropertyString ("MSDispModel");
80  nr_double_t Zl1, Er1, Zl2, Er2;
81  nr_double_t ZlEff, ErEff, WEff;
82  msline::analyseQuasiStatic (W, h, t, 9.9, SModel, ZlEff, ErEff, WEff);
83  msline::analyseDispersion (W, h, 9.9, ZlEff, ErEff, f, DModel,
84  Zl1, Er1);
85  msline::analyseQuasiStatic (W, h, t, er, SModel, ZlEff, ErEff, WEff);
86  msline::analyseDispersion (W, h, er, ZlEff, ErEff, f, DModel,
87  Zl2, Er2);
88  return Zl1 / Zl2 * sqrt (Er2 / Er1);
89 }
90 
91 nr_double_t mscross::calcCap (nr_double_t W1, nr_double_t h, nr_double_t W2) {
92  nr_double_t W1h = W1 / h;
93  nr_double_t W2h = W2 / h;
94  nr_double_t X = log10 (W1h) * (86.6 * W2h - 30.9 * sqrt (W2h) + 367) +
95  cubic (W2h) + 74 * W2h + 130;
96  return 1e-12 * W1 * (0.25 * X * pow (W1h, -1.0 / 3.0) - 60 +
97  1 / W2h / 2 - 0.375 * W1h * (1 - W2h));
98  }
99 
100 nr_double_t mscross::calcInd (nr_double_t W1, nr_double_t h, nr_double_t W2) {
101  nr_double_t W1h = W1 / h;
102  nr_double_t W2h = W2 / h;
103  nr_double_t Y = 165.6 * W2h + 31.2 * sqrt (W2h) - 11.8 * sqr (W2h);
104  return 1e-9 * h * (Y * W1h - 32 * W2h + 3) * pow (W1h, -1.5);
105 }
106 
107 matrix mscross::calcMatrixY (nr_double_t f) {
108  nr_double_t W1 = getPropertyDouble ("W1");
109  nr_double_t W2 = getPropertyDouble ("W2");
110  nr_double_t W3 = getPropertyDouble ("W3");
111  nr_double_t W4 = getPropertyDouble ("W4");
112  substrate * subst = getSubstrate ();
113  nr_double_t h = subst->getPropertyDouble ("h");
114  nr_double_t W1h = (W1 + W3) / 2 / h;
115  nr_double_t W2h = (W2 + W4) / 2 / h;
116  nr_double_t C1, C2, C3, C4, L1, L2, L3, L4, L5;
117 
118  // apply asymmetric modifications of original model
119  C1 = calcCap (W1, h, (W2 + W4) / 2);
120  C2 = calcCap (W2, h, (W1 + W3) / 2);
121  C3 = calcCap (W3, h, (W4 + W2) / 2);
122  C4 = calcCap (W4, h, (W3 + W1) / 2);
123 
124  L1 = calcInd (W1, h, (W2 + W4) / 2);
125  L2 = calcInd (W2, h, (W1 + W3) / 2);
126  L3 = calcInd (W3, h, (W4 + W2) / 2);
127  L4 = calcInd (W4, h, (W3 + W1) / 2);
128 
129  L5 = 1e-9 * h * (5 * W2h * cos (M_PI / 2 * (1.5 - W1h)) -
130  (1 + 7 / W1h ) / W2h - 337.5);
131 
132  // center inductance correction
133  L5 = L5 * 0.8;
134 
135  // capacitance corrections
136  C1 = C1 * capCorrection (W1, f);
137  C2 = C2 * capCorrection (W2, f);
138  C3 = C3 * capCorrection (W3, f);
139  C4 = C4 * capCorrection (W4, f);
140 
141  // compute admittance matrix
142  nr_double_t o = 2 * M_PI * f;
143  nr_complex_t yc1 = rect (0, o * C1);
144  nr_complex_t yc2 = rect (0, o * C2);
145  nr_complex_t yc3 = rect (0, o * C3);
146  nr_complex_t yc4 = rect (0, o * C4);
147  nr_complex_t yl1 = 1.0 / rect (0, o * L1);
148  nr_complex_t yl2 = 1.0 / rect (0, o * L2);
149  nr_complex_t yl3 = 1.0 / rect (0, o * L3);
150  nr_complex_t yl4 = 1.0 / rect (0, o * L4);
151  nr_complex_t yl5 = 1.0 / rect (0, o * L5);
152  matrix Y (6);
153  Y.set (NODE_1, NODE_1, yl1 + yc1);
154  Y.set (NODE_2, NODE_2, yl2 + yc2);
155  Y.set (NODE_3, NODE_3, yl3 + yc3);
156  Y.set (NODE_4, NODE_4, yl4 + yc4);
157  Y.set (NODE_1, NODE_5, -yl1); Y.set (NODE_5, NODE_1, -yl1);
158  Y.set (NODE_3, NODE_5, -yl3); Y.set (NODE_5, NODE_3, -yl3);
159  Y.set (NODE_2, NODE_6, -yl2); Y.set (NODE_6, NODE_2, -yl2);
160  Y.set (NODE_4, NODE_6, -yl4); Y.set (NODE_6, NODE_4, -yl4);
161  Y.set (NODE_5, NODE_6, -yl5); Y.set (NODE_6, NODE_5, -yl5);
162  Y.set (NODE_5, NODE_5, yl1 + yl3 + yl5);
163  Y.set (NODE_6, NODE_6, yl2 + yl4 + yl5);
164  return Y;
165 }
166 
167 void mscross::initTR (void) {
168  initDC ();
169 }
170 
171 // properties
172 PROP_REQ [] = {
173  { "W1", PROP_REAL, { 1e-3, PROP_NO_STR }, PROP_POS_RANGE },
174  { "W2", PROP_REAL, { 2e-3, PROP_NO_STR }, PROP_POS_RANGE },
175  { "W3", PROP_REAL, { 1e-3, PROP_NO_STR }, PROP_POS_RANGE },
176  { "W4", PROP_REAL, { 2e-3, PROP_NO_STR }, PROP_POS_RANGE },
177  { "Subst", PROP_STR, { PROP_NO_VAL, "Subst1" }, PROP_NO_RANGE },
178  { "MSDispModel", PROP_STR, { PROP_NO_VAL, "Kirschning" }, PROP_RNG_DIS },
179  { "MSModel", PROP_STR, { PROP_NO_VAL, "Hammerstad" }, PROP_RNG_MOD },
180  PROP_NO_PROP };
181 PROP_OPT [] = {
182  PROP_NO_PROP };
183 struct define_t mscross::cirdef =