Qucs-core  0.0.18
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
msgap.cpp
Go to the documentation of this file.
1 /*
2  * msgap.cpp - microstrip gap class implementation
3  *
4  * Copyright (C) 2004, 2008, 2009 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 "msopen.h"
33 #include "msgap.h"
34 
35 using namespace qucs;
36 
37 msgap::msgap () : circuit (2) {
38  type = CIR_MSGAP;
39 }
40 
41 void msgap::calcSP (nr_double_t frequency) {
42  setMatrixS (ytos (calcMatrixY (frequency)));
43 }
44 
45 matrix msgap::calcMatrixY (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  nr_double_t s = getPropertyDouble ("S");
51  char * SModel = getPropertyString ("MSModel");
52  char * DModel = getPropertyString ("MSDispModel");
53 
54  /* how to get properties of the substrate, e.g. Er, H */
56  nr_double_t er = subst->getPropertyDouble ("er");
57  nr_double_t h = subst->getPropertyDouble ("h");
58  nr_double_t t = subst->getPropertyDouble ("t");
59 
60  nr_double_t Q1, Q2, Q3, Q4, Q5;
61  bool flip = false;
62  if (W2 < W1) { // equations are valid for 1 <= W2/W1 <= 3
63  Q1 = W1;
64  W1 = W2;
65  W2 = Q1;
66  flip = true;
67  }
68 
69  // calculate parallel open end capacitances
70  nr_double_t C1 = msopen::calcCend (frequency, W1, h, t, er,
71  SModel, DModel, "Kirschning");
72  nr_double_t C2 = msopen::calcCend (frequency, W2, h, t, er,
73  SModel, DModel, "Kirschning");
74 
75  W2 /= W1;
76  W1 /= h;
77  s /= h;
78 
79  // local variables
80  Q5 = 1.23 / (1.0 + 0.12 * qucs::pow (W2 - 1.0, 0.9));
81  Q1 = 0.04598 * (0.03 + qucs::pow (W1, Q5)) * (0.272 + 0.07 * er);
82  Q2 = 0.107 * (W1 + 9.0) * qucs::pow (s, 3.23) +
83  2.09 * qucs::pow (s, 1.05) * (1.5 + 0.3 * W1) / (1.0 + 0.6 * W1);
84  Q3 = qucs::exp (-0.5978 * qucs::pow (W2, +1.35)) - 0.55;
85  Q4 = qucs::exp (-0.5978 * qucs::pow (W2, -1.35)) - 0.55;
86 
87  nr_double_t Cs = 5e-10 * h * qucs::exp (-1.86 * s) * Q1 *
88  (1.0 + 4.19 * (1.0 - qucs::exp (-0.785 * qucs::sqrt (1.0 / W1) * W2)));
89  C1 *= (Q2 + Q3) / (Q2 + 1.0);
90  C2 *= (Q2 + Q4) / (Q2 + 1.0);
91 
92  if (flip) { // if necessary flip ports back
93  Q1 = C1;
94  C1 = C2;
95  C2 = Q1;
96  }
97 
98  // build Y-parameter matrix
99  nr_complex_t y21 = nr_complex_t (0.0, -2.0 * M_PI * frequency * Cs);
100  nr_complex_t y11 = nr_complex_t (0.0, 2.0 * M_PI * frequency * (C1 + Cs));
101  nr_complex_t y22 = nr_complex_t (0.0, 2.0 * M_PI * frequency * (C2 + Cs));
102  matrix y (2);
103  y.set (0, 0, y11);
104  y.set (0, 1, y21);
105  y.set (1, 0, y21);
106  y.set (1, 1, y22);
107  return y;
108 }
109 
110 void msgap::initDC (void) {
111  allocMatrixMNA ();
112  clearY ();
113 }
114 
115 void msgap::calcAC (nr_double_t frequency) {
116  setMatrixY (calcMatrixY (frequency));
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  { "S" , PROP_REAL, { 1e-3, PROP_NO_STR }, PROP_POS_RANGE },
124  { "Subst", PROP_STR, { PROP_NO_VAL, "Subst1" }, PROP_NO_RANGE },
125  { "MSDispModel", PROP_STR, { PROP_NO_VAL, "Kirschning" }, PROP_RNG_DIS },
126  { "MSModel", PROP_STR, { PROP_NO_VAL, "Hammerstad" }, PROP_RNG_MOD },
127  PROP_NO_PROP };
128 PROP_OPT [] = {
129  PROP_NO_PROP };
130 struct define_t msgap::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
matrix ytos(matrix y, qucs::vector z0)
Admittance matrix to scattering parameters.
Definition: matrix.cpp:1133
substrate * subst
Definition: circuit.h:350
PROP_OPT[]
Definition: msgap.cpp:128
PROP_REQ[]
Definition: msgap.cpp:120
#define PROP_DEF
Definition: netdefs.h:189
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
#define PROP_REAL
Definition: netdefs.h:174
substrate * getSubstrate(void)
Definition: circuit.cpp:332
t
Definition: parse_vcd.y:290
#define PROP_NO_PROP
Definition: netdefs.h:122
#define PROP_NO_RANGE
Definition: netdefs.h:126
#define PROP_NO_STR
Definition: netdefs.h:125
#define PROP_RNG_MOD
Definition: netdefs.h:169
#define PROP_LINEAR
Definition: netdefs.h:120
h
Definition: parse_vcd.y:214
void calcSP(nr_double_t)
Definition: msgap.cpp:41
#define PROP_RNG_DIS
Definition: netdefs.h:166
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
static nr_double_t calcCend(nr_double_t, nr_double_t, nr_double_t, nr_double_t, nr_double_t, char *, char *, const char *)
Definition: msopen.cpp:42
void initDC(void)
Definition: msgap.cpp:110
void setMatrixY(matrix)
Definition: circuit.cpp:685
#define M_PI
Archimedes' constant ( )
Definition: consts.h:47
void setMatrixS(matrix)
Definition: circuit.cpp:643
PROP_NO_SUBSTRATE
Definition: msgap.cpp:131
void allocMatrixMNA(void)
Definition: circuit.cpp:267
#define PROP_STR
Definition: netdefs.h:175
y
Definition: parse_mdl.y:499
nr_complex_t exp(const nr_complex_t z)
Compute complex exponential.
Definition: complex.cpp:205
void calcAC(nr_double_t)
Definition: msgap.cpp:115
#define PROP_NO_VAL
Definition: netdefs.h:124
char * getPropertyString(const char *)
Definition: object.cpp:159
Definition: msgap.cpp:130
qucs::matrix calcMatrixY(nr_double_t)
Definition: msgap.cpp:45