Qucs-core  0.0.18
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
msrstub.cpp
Go to the documentation of this file.
1 /*
2  * msrstub.cpp - microstrip radial stub class implementation
3  *
4  * Copyright (C) 2009 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 "msrstub.h"
32 
33 using namespace qucs;
34 
35 msrstub::msrstub () : circuit (1) {
36  type = CIR_MSRSTUB;
37 }
38 
39 // Returns the microstrip radial stub reactance.
40 nr_double_t msrstub::calcReactance (nr_double_t r1, nr_double_t r2,
41  nr_double_t alpha, nr_double_t er,
42  nr_double_t h, nr_double_t frequency) {
43 
44  nr_double_t l0 = C0 / frequency;
45  nr_double_t W = (r1 + (r2 - r1) / 2) * rad (alpha);
46  nr_double_t ereff = (er + 1.0) / 2 + (er - 1.0) /
47  (2.0 * qucs::sqrt (1 + 10.0 * h / W));
48  nr_double_t k = 2.0 * M_PI * qucs::sqrt (ereff) / l0;
49  nr_double_t a = k * r1;
50  nr_double_t b = k * r2;
51  nr_double_t Z_0 = Z0 / qucs::sqrt (ereff) * qucs::sqrt (sqr (j0 (a)) + sqr (y0 (a))) /
52  qucs::sqrt (sqr (j1 (a)) + sqr (y1 (a)));
53  nr_double_t theta_1 = qucs::atan (y0 (a) / j0 (a));
54  // nr_double_t theta_2 = atan (y0 (b) / j0 (b));
55  nr_double_t phi_1 = qucs::atan (-j1 (a) / y1 (a));
56  nr_double_t phi_2 = qucs::atan (-j1 (b) / y1 (b));
57 
58  nr_double_t X1 = h * Z_0 / (2.0 * M_PI * r1) * 360.0 / alpha *
59  qucs::cos (theta_1 - phi_2) / qucs::sin (phi_1 - phi_2);
60 
61  return X1;
62 }
63 
64 void msrstub::calcSP (nr_double_t frequency) {
65  setS (NODE_1, NODE_1, ztor (calcZ (frequency)));
66 }
67 
68 nr_complex_t msrstub::calcZ (nr_double_t frequency) {
69 
70  /* get properties of this component */
71  nr_double_t r1 = getPropertyDouble ("ri");
72  nr_double_t r2 = getPropertyDouble ("ro");
73  nr_double_t al = getPropertyDouble ("alpha");
74 
75  /* get properties of the substrate */
77  nr_double_t er = subst->getPropertyDouble ("er");
78  nr_double_t h = subst->getPropertyDouble ("h");
79 
80  return nr_complex_t (0, calcReactance (r1, r2, al, er, h, frequency));
81 }
82 
83 void msrstub::initDC (void) {
84  allocMatrixMNA ();
85  setY (NODE_1, NODE_1, 0);
86 }
87 
88 void msrstub::calcAC (nr_double_t frequency) {
89  setY (NODE_1, NODE_1, 1.0 / calcZ (frequency));
90 }
91 
92 // properties
93 PROP_REQ [] = {
94  { "ri", PROP_REAL, { 1e-3, PROP_NO_STR }, PROP_POS_RANGE },
95  { "ro", PROP_REAL, { 10e-3, PROP_NO_STR }, PROP_POS_RANGE },
96  { "alpha", PROP_REAL, { 90, PROP_NO_STR }, PROP_RNGII (0, 180) },
97  { "Subst", PROP_STR, { PROP_NO_VAL, "Subst1" }, PROP_NO_RANGE },
98  PROP_NO_PROP };
99 PROP_OPT [] = {
100  PROP_NO_PROP };
101 struct define_t msrstub::cirdef =
std::complex< nr_double_t > nr_complex_t
Definition: complex.h:31
#define PROP_POS_RANGE
Definition: netdefs.h:129
static nr_double_t calcReactance(nr_double_t, nr_double_t, nr_double_t, nr_double_t, nr_double_t, nr_double_t)
Definition: msrstub.cpp:40
#define PROP_RNGII(f, t)
Definition: netdefs.h:138
substrate * subst
Definition: circuit.h:350
#define PROP_DEF
Definition: netdefs.h:189
nr_double_t getPropertyDouble(const char *)
Definition: object.cpp:176
nr_complex_t calcZ(nr_double_t)
Definition: msrstub.cpp:68
nr_complex_t cos(const nr_complex_t z)
Compute complex cosine.
Definition: complex.cpp:57
#define PROP_REAL
Definition: netdefs.h:174
substrate * getSubstrate(void)
Definition: circuit.cpp:332
#define PROP_NO_PROP
Definition: netdefs.h:122
nr_complex_t atan(const nr_complex_t z)
Compute complex arc tangent.
Definition: complex.cpp:117
#define PROP_NO_RANGE
Definition: netdefs.h:126
#define PROP_NO_STR
Definition: netdefs.h:125
void initDC(void)
Definition: msrstub.cpp:83
#define PROP_LINEAR
Definition: netdefs.h:120
h
Definition: parse_vcd.y:214
PROP_OPT[]
Definition: msrstub.cpp:99
PROP_NO_SUBSTRATE
Definition: msrstub.cpp:102
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
void calcSP(nr_double_t)
Definition: msrstub.cpp:64
nr_complex_t sin(const nr_complex_t z)
Compute complex sine.
Definition: complex.cpp:66
nr_complex_t ztor(const nr_complex_t z, nr_complex_t zref)
Converts impedance to reflexion coefficient.
Definition: complex.cpp:581
#define PROP_COMPONENT
Definition: netdefs.h:116
#define M_PI
Archimedes' constant ( )
Definition: consts.h:47
#define rad(x)
Convert degree to radian.
Definition: constants.h:118
void setY(int, int, nr_complex_t)
Definition: circuit.cpp:452
void allocMatrixMNA(void)
Definition: circuit.cpp:267
#define PROP_STR
Definition: netdefs.h:175
#define NODE_1
Definition: circuit.h:34
#define C0
speed of light in vacuum ( )
Definition: constants.h:47
PROP_REQ[]
Definition: msrstub.cpp:93
void setS(int, int, nr_complex_t)
Definition: circuit.cpp:587
#define PROP_NO_VAL
Definition: netdefs.h:124
void calcAC(nr_double_t)
Definition: msrstub.cpp:88
#define Z0
Wave impedance in vacuum ( )
Definition: constants.h:53