Qucs-core  0.0.18
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cpwstep.cpp
Go to the documentation of this file.
1 /*
2  * cpwstep.cpp - coplanar waveguide step class implementation
3  *
4  * Copyright (C) 2005, 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 "cpwline.h"
32 #include "cpwstep.h"
33 
34 using namespace qucs;
35 
36 cpwstep::cpwstep () : circuit (2) {
37  type = CIR_CPWSTEP;
38 }
39 
40 // Returns the coplanar step capacitances per unit length.
41 void cpwstep::calcCends (nr_double_t frequency,
42  nr_double_t& C1, nr_double_t& C2) {
43 
44  // get properties of substrate and coplanar step
45  nr_double_t W1 = getPropertyDouble ("W1");
46  nr_double_t W2 = getPropertyDouble ("W2");
47  nr_double_t s = getPropertyDouble ("S");
48  nr_double_t s1 = (s - W1) / 2;
49  nr_double_t s2 = (s - W2) / 2;
51  nr_double_t er = subst->getPropertyDouble ("er");
52  nr_double_t h = subst->getPropertyDouble ("h");
53  nr_double_t t = subst->getPropertyDouble ("t");
54  int backMetal = !strcmp (getPropertyString ("Backside"), "Metal");
55 
56  nr_double_t ZlEff, ErEff, ZlEffFreq, ErEffFreq;
57  cpwline::analyseQuasiStatic (W1, s1, h, t, er, backMetal, ZlEff, ErEff);
58  cpwline::analyseDispersion (W1, s1, h, er, ZlEff, ErEff, frequency,
59  ZlEffFreq, ErEffFreq);
60  C1 = ErEffFreq / C0 / ZlEffFreq;
61  cpwline::analyseQuasiStatic (W2, s2, h, t, er, backMetal, ZlEff, ErEff);
62  cpwline::analyseDispersion (W2, s2, h, er, ZlEff, ErEff, frequency,
63  ZlEffFreq, ErEffFreq);
64  C2 = ErEffFreq / C0 / ZlEffFreq;
65 }
66 
67 void cpwstep::initSP (void) {
68  allocMatrixS ();
69  checkProperties ();
70 }
71 
72 void cpwstep::calcSP (nr_double_t frequency) {
73  nr_complex_t z = 2.0 / calcY (frequency) / z0;
74  nr_complex_t s11 = -1.0 / (z + 1.0);
75  nr_complex_t s21 = +z / (z + 1.0);
76  setS (NODE_1, NODE_1, s11);
77  setS (NODE_2, NODE_2, s11);
78  setS (NODE_1, NODE_2, s21);
79  setS (NODE_2, NODE_1, s21);
80 }
81 
83  nr_double_t W1 = getPropertyDouble ("W1");
84  nr_double_t W2 = getPropertyDouble ("W2");
85  nr_double_t s = getPropertyDouble ("S");
86  if (W1 == W2) {
87  logprint (LOG_ERROR, "ERROR: Strip widths of step discontinuity do not "
88  "differ\n");
89  }
90  if (W1 >= s || W2 >= s) {
91  logprint (LOG_ERROR, "ERROR: Strip widths of step discontinuity larger "
92  "than groundplane gap\n");
93  }
95  nr_double_t er = subst->getPropertyDouble ("er");
96  if (er < 2 || er > 14) {
97  logprint (LOG_ERROR, "WARNING: Model for coplanar step valid for "
98  "2 < er < 14 (er = %g)\n", er);
99  }
100 }
101 
102 nr_complex_t cpwstep::calcY (nr_double_t frequency) {
103  nr_double_t W1 = getPropertyDouble ("W1");
104  nr_double_t W2 = getPropertyDouble ("W2");
105  nr_double_t s = getPropertyDouble ("S");
106  nr_double_t s1 = (s - W1) / 2;
107  nr_double_t s2 = (s - W2) / 2;
108  nr_double_t a, c, c1, c2, x1, x2;
109  nr_double_t o = 2 * M_PI * frequency;
110  calcCends (frequency, c1, c2);
111  x1 = c1 * s1;
112  x2 = c2 * s2;
113  a = s1 > s2 ? s2 / s1 : s1 / s2;
114  c = M_1_PI * ((a * a + 1) / a * std::log ((1 + a) / (1 - a)) -
115  2 * std::log (4 * a / (1 - a * a)));
116  c = c * (x1 + x2) / 2;
117  return nr_complex_t (0, c * o);
118 }
119 
120 void cpwstep::initDC (void) {
121  setVoltageSources (1);
123  allocMatrixMNA ();
125 }
126 
127 void cpwstep::initAC (void) {
128  setVoltageSources (2);
130  allocMatrixMNA ();
131  setB (NODE_1, VSRC_1, +1.0); setB (NODE_1, VSRC_2, +0.0);
132  setB (NODE_2, VSRC_1, +0.0); setB (NODE_2, VSRC_2, +1.0);
133  setC (VSRC_1, NODE_1, -1.0); setC (VSRC_1, NODE_2, +0.0);
134  setC (VSRC_2, NODE_1, +0.0); setC (VSRC_2, NODE_2, -1.0);
135  setE (VSRC_1, +0.0); setE (VSRC_2, +0.0);
136  checkProperties ();
137 }
138 
139 void cpwstep::calcAC (nr_double_t frequency) {
140  nr_complex_t z = 1.0 / calcY (frequency);
141  setD (VSRC_1, VSRC_1, z); setD (VSRC_2, VSRC_2, z);
142  setD (VSRC_1, VSRC_2, z); setD (VSRC_2, VSRC_1, z);
143 }
144 
145 // properties
146 PROP_REQ [] = {
147  { "W1", PROP_REAL, { 1e-3, PROP_NO_STR }, PROP_POS_RANGE },
148  { "W2", PROP_REAL, { 2e-3, PROP_NO_STR }, PROP_POS_RANGE },
149  { "S", PROP_REAL, { 4e-3, PROP_NO_STR }, PROP_POS_RANGE },
150  { "Subst", PROP_STR, { PROP_NO_VAL, "Subst1" }, PROP_NO_RANGE },
151  PROP_NO_PROP };
152 PROP_OPT [] = {
153  { "Backside", PROP_STR, { PROP_NO_VAL, "Metal" },
154  PROP_RNG_STR2 ("Metal", "Air") },
155  PROP_NO_PROP };
156 struct define_t cpwstep::cirdef =
std::complex< nr_double_t > nr_complex_t
Definition: complex.h:31
#define PROP_POS_RANGE
Definition: netdefs.h:129
#define NODE_2
Definition: circuit.h:35
PROP_NO_SUBSTRATE
Definition: cpwstep.cpp:157
substrate * subst
Definition: circuit.h:350
void initAC(void)
Definition: cpwstep.cpp:127
#define PROP_DEF
Definition: netdefs.h:189
#define PROP_RNG_STR2(s1, s2)
Definition: netdefs.h:145
nr_complex_t calcY(nr_double_t)
Definition: cpwstep.cpp:102
nr_double_t getPropertyDouble(const char *)
Definition: object.cpp:176
PROP_OPT[]
Definition: cpwstep.cpp:152
void setD(int, int, nr_complex_t)
Definition: circuit.cpp:373
#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 setB(int, int, nr_complex_t)
Definition: circuit.cpp:349
void allocMatrixS(void)
Definition: circuit.cpp:251
#define PROP_LINEAR
Definition: netdefs.h:120
static const nr_double_t z0
Definition: circuit.h:320
h
Definition: parse_vcd.y:214
#define VSRC_1
Definition: circuit.h:40
void calcSP(nr_double_t)
Definition: cpwstep.cpp:72
static void analyseDispersion(nr_double_t, nr_double_t, nr_double_t, nr_double_t, nr_double_t, nr_double_t, nr_double_t, nr_double_t &, nr_double_t &)
Definition: cpwline.cpp:349
void checkProperties(void)
Definition: cpwstep.cpp:82
#define PROP_COMPONENT
Definition: netdefs.h:116
void setE(int, nr_complex_t)
Definition: circuit.cpp:385
eqn::constant * c1
eqn::constant * c2
void calcCends(nr_double_t, nr_double_t &, nr_double_t &)
Definition: cpwstep.cpp:41
#define M_PI
Archimedes' constant ( )
Definition: consts.h:47
void initSP(void)
placehoder for S-Parameter initialisation function
Definition: cpwstep.cpp:67
void initDC(void)
Definition: cpwstep.cpp:120
void allocMatrixMNA(void)
Definition: circuit.cpp:267
void calcAC(nr_double_t)
Definition: cpwstep.cpp:139
#define M_1_PI
Inverse of Archimedes' constant ( )
Definition: consts.h:59
PROP_REQ[]
Definition: cpwstep.cpp:146
#define PROP_STR
Definition: netdefs.h:175
static void analyseQuasiStatic(nr_double_t, nr_double_t, nr_double_t, nr_double_t, nr_double_t, int, nr_double_t &, nr_double_t &)
Definition: cpwline.cpp:287
#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
#define LOG_ERROR
Definition: logging.h:28
void setS(int, int, nr_complex_t)
Definition: circuit.cpp:587
#define PROP_NO_VAL
Definition: netdefs.h:124
void setC(int, int, nr_complex_t)
Definition: circuit.cpp:361
#define VSRC_2
Definition: circuit.h:41
char * getPropertyString(const char *)
Definition: object.cpp:159
void logprint(int level, const char *format,...)
Definition: logging.c:37
nr_complex_t log(const nr_complex_t z)
Compute principal value of natural logarithm of z.
Definition: complex.cpp:215