My Project  0.0.16
QUCS Mapping
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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: msgap.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 "msopen.h"
33 #include "msgap.h"
34 
35 msgap::msgap () : circuit (2) {
36  type = CIR_MSGAP;
37 }
38 
39 void msgap::calcSP (nr_double_t frequency) {
40  setMatrixS (ytos (calcMatrixY (frequency)));
41 }
42 
43 matrix msgap::calcMatrixY (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  nr_double_t s = getPropertyDouble ("S");
49  char * SModel = getPropertyString ("MSModel");
50  char * DModel = getPropertyString ("MSDispModel");
51 
52  /* how to get properties of the substrate, e.g. Er, H */
53  substrate * subst = getSubstrate ();
54  nr_double_t er = subst->getPropertyDouble ("er");
55  nr_double_t h = subst->getPropertyDouble ("h");
56  nr_double_t t = subst->getPropertyDouble ("t");
57 
58  nr_double_t Q1, Q2, Q3, Q4, Q5;
59  bool flip = false;
60  if (W2 < W1) { // equations are valid for 1 <= W2/W1 <= 3
61  Q1 = W1;
62  W1 = W2;
63  W2 = Q1;
64  flip = true;
65  }
66 
67  // calculate parallel open end capacitances
68  nr_double_t C1 = msopen::calcCend (frequency, W1, h, t, er,
69  SModel, DModel, "Kirschning");
70  nr_double_t C2 = msopen::calcCend (frequency, W2, h, t, er,
71  SModel, DModel, "Kirschning");
72 
73  W2 /= W1;
74  W1 /= h;
75  s /= h;
76 
77  // local variables
78  Q5 = 1.23 / (1.0 + 0.12 * pow (W2 - 1.0, 0.9));
79  Q1 = 0.04598 * (0.03 + pow (W1, Q5)) * (0.272 + 0.07 * er);
80  Q2 = 0.107 * (W1 + 9.0) * pow (s, 3.23) +
81  2.09 * pow (s, 1.05) * (1.5 + 0.3 * W1) / (1.0 + 0.6 * W1);
82  Q3 = exp (-0.5978 * pow (W2, +1.35)) - 0.55;
83  Q4 = exp (-0.5978 * pow (W2, -1.35)) - 0.55;
84 
85  nr_double_t Cs = 5e-10 * h * exp (-1.86 * s) * Q1 *
86  (1.0 + 4.19 * (1.0 - exp (-0.785 * sqrt (1.0 / W1) * W2)));
87  C1 *= (Q2 + Q3) / (Q2 + 1.0);
88  C2 *= (Q2 + Q4) / (Q2 + 1.0);
89 
90  if (flip) { // if necessary flip ports back
91  Q1 = C1;
92  C1 = C2;
93  C2 = Q1;
94  }
95 
96  // build Y-parameter matrix
97  nr_complex_t y21 = rect (0.0, -2.0 * M_PI * frequency * Cs);
98  nr_complex_t y11 = rect (0.0, 2.0 * M_PI * frequency * (C1 + Cs));
99  nr_complex_t y22 = rect (0.0, 2.0 * M_PI * frequency * (C2 + Cs));
100  matrix y (2);
101  y.set (0, 0, y11);
102  y.set (0, 1, y21);
103  y.set (1, 0, y21);
104  y.set (1, 1, y22);
105  return y;
106 }
107 
108 void msgap::initDC (void) {
109  allocMatrixMNA ();
110  clearY ();
111 }
112 
113 void msgap::calcAC (nr_double_t frequency) {
114  setMatrixY (calcMatrixY (frequency));
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  { "S" , PROP_REAL, { 1e-3, PROP_NO_STR }, PROP_POS_RANGE },
122  { "Subst", PROP_STR, { PROP_NO_VAL, "Subst1" }, PROP_NO_RANGE },
123  { "MSDispModel", PROP_STR, { PROP_NO_VAL, "Kirschning" }, PROP_RNG_DIS },
124  { "MSModel", PROP_STR, { PROP_NO_VAL, "Hammerstad" }, PROP_RNG_MOD },
125  PROP_NO_PROP };
126 PROP_OPT [] = {
127  PROP_NO_PROP };
128 struct define_t msgap::cirdef =