My Project  0.0.16
QUCS Mapping
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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: msrstub.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 "msrstub.h"
32 
33 msrstub::msrstub () : circuit (1) {
34  type = CIR_MSRSTUB;
35 }
36 
37 // Returns the microstrip radial stub reactance.
38 nr_double_t msrstub::calcReactance (nr_double_t r1, nr_double_t r2,
39  nr_double_t alpha, nr_double_t er,
40  nr_double_t h, nr_double_t frequency) {
41 
42  nr_double_t l0 = C0 / frequency;
43  nr_double_t W = (r1 + (r2 - r1) / 2) * rad (alpha);
44  nr_double_t ereff = (er + 1.0) / 2 + (er - 1.0) /
45  (2.0 * sqrt (1 + 10.0 * h / W));
46  nr_double_t k = 2.0 * M_PI * sqrt (ereff) / l0;
47  nr_double_t a = k * r1;
48  nr_double_t b = k * r2;
49  nr_double_t Z_0 = Z0 / sqrt (ereff) * sqrt (sqr (j0 (a)) + sqr (y0 (a))) /
50  sqrt (sqr (j1 (a)) + sqr (y1 (a)));
51  nr_double_t theta_1 = atan (y0 (a) / j0 (a));
52  // nr_double_t theta_2 = atan (y0 (b) / j0 (b));
53  nr_double_t phi_1 = atan (-j1 (a) / y1 (a));
54  nr_double_t phi_2 = atan (-j1 (b) / y1 (b));
55 
56  nr_double_t X1 = h * Z_0 / (2.0 * M_PI * r1) * 360.0 / alpha *
57  cos (theta_1 - phi_2) / sin (phi_1 - phi_2);
58 
59  return X1;
60 }
61 
62 void msrstub::calcSP (nr_double_t frequency) {
63  setS (NODE_1, NODE_1, ztor (calcZ (frequency)));
64 }
65 
66 nr_complex_t msrstub::calcZ (nr_double_t frequency) {
67 
68  /* get properties of this component */
69  nr_double_t r1 = getPropertyDouble ("ri");
70  nr_double_t r2 = getPropertyDouble ("ro");
71  nr_double_t al = getPropertyDouble ("alpha");
72 
73  /* get properties of the substrate */
74  substrate * subst = getSubstrate ();
75  nr_double_t er = subst->getPropertyDouble ("er");
76  nr_double_t h = subst->getPropertyDouble ("h");
77 
78  return rect (0, calcReactance (r1, r2, al, er, h, frequency));
79 }
80 
81 void msrstub::initDC (void) {
82  allocMatrixMNA ();
83  setY (NODE_1, NODE_1, 0);
84 }
85 
86 void msrstub::calcAC (nr_double_t frequency) {
87  setY (NODE_1, NODE_1, 1.0 / calcZ (frequency));
88 }
89 
90 // properties
91 PROP_REQ [] = {
92  { "ri", PROP_REAL, { 1e-3, PROP_NO_STR }, PROP_POS_RANGE },
93  { "ro", PROP_REAL, { 10e-3, PROP_NO_STR }, PROP_POS_RANGE },
94  { "alpha", PROP_REAL, { 90, PROP_NO_STR }, PROP_RNGII (0, 180) },
95  { "Subst", PROP_STR, { PROP_NO_VAL, "Subst1" }, PROP_NO_RANGE },
96  PROP_NO_PROP };
97 PROP_OPT [] = {
98  PROP_NO_PROP };
99 struct define_t msrstub::cirdef =