Qucs-core  0.0.18
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
msmbend.cpp
Go to the documentation of this file.
1 /*
2  * msmbend.cpp - microstrip mitered bend class implementation
3  *
4  * Copyright (C) 2004, 2008 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 "msmbend.h"
33 
34 using namespace qucs;
35 
36 msmbend::msmbend () : circuit (2) {
37  type = CIR_MSMBEND;
38 }
39 
40 void msmbend::calcSP (nr_double_t frequency) {
41  setMatrixS (ztos (calcMatrixZ (frequency)));
42 }
43 
44 matrix msmbend::calcMatrixZ (nr_double_t frequency) {
45 
46  /* how to get properties of this component, e.g. W */
47  nr_double_t W = getPropertyDouble ("W");
48 
49  /* how to get properties of the substrate, e.g. Er, H */
51  nr_double_t er = subst->getPropertyDouble ("er");
52  nr_double_t h = subst->getPropertyDouble ("h");
53 
54  /* local variables */
55  nr_complex_t z11, z21;
56  nr_double_t L, C, Wh = W / h;
57 
58  // check validity
59  if ((Wh < 0.2) || (Wh > 6.0)) {
60  logprint (LOG_ERROR, "WARNING: Model for microstrip mitered bend defined "
61  "for 0.2 <= W/h <= 6.0\n");
62  }
63  if ((er < 2.36) || (er > 10.4)) {
64  logprint (LOG_ERROR, "WARNING: Model for microstrip mitered bend defined "
65  "for 2.36 <= er <= 10.4\n");
66  }
67  if (frequency * h > 12e6) {
68  logprint (LOG_ERROR, "WARNING: Model for microstrip mitered bend defined "
69  "for freq*h <= 12MHz\n");
70  }
71 
72  // capacitance in pF
73  C = W * ((3.93 * er + 0.62) * Wh + (7.6 * er + 3.80));
74  // inductance in nH
75  L = 440.0 * h * (1.0 - 1.062 * qucs::exp (-0.177 * qucs::pow (Wh, 0.947)));
76 
77  // calculate Z-parameters
78  z21 = nr_complex_t (0.0, -0.5e12 / (M_PI * frequency * C));
79  z11 = nr_complex_t (0.0, 2e-9 * M_PI * frequency * L) + z21;
80  matrix z (2);
81  z.set (0, 0, z11);
82  z.set (0, 1, z21);
83  z.set (1, 0, z21);
84  z.set (1, 1, z11);
85  return z;
86 }
87 
88 void msmbend::initDC (void) {
89  // a DC short (voltage source V = 0 volts)
92  allocMatrixMNA ();
93  clearY ();
95 }
96 
97 void msmbend::initAC (void) {
99  allocMatrixMNA ();
100 }
101 
102 void msmbend::calcAC (nr_double_t frequency) {
103  setMatrixY (ztoy (calcMatrixZ (frequency)));
104 }
105 
106 // properties
107 PROP_REQ [] = {
108  { "W", PROP_REAL, { 1e-3, PROP_NO_STR }, PROP_POS_RANGE },
109  { "Subst", PROP_STR, { PROP_NO_VAL, "Subst1" }, PROP_NO_RANGE },
110  PROP_NO_PROP };
111 PROP_OPT [] = {
112  PROP_NO_PROP };
113 struct define_t msmbend::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
#define NODE_2
Definition: circuit.h:35
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 pow(const nr_complex_t z, const nr_double_t d)
Compute power function with real exponent.
Definition: complex.cpp:238
#define C(c)
Definition: eqndefined.cpp:73
#define PROP_REAL
Definition: netdefs.h:174
substrate * getSubstrate(void)
Definition: circuit.cpp:332
void calcAC(nr_double_t)
Definition: msmbend.cpp:102
void setInternalVoltageSource(bool i)
Definition: circuit.h:184
#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
#define PROP_LINEAR
Definition: netdefs.h:120
h
Definition: parse_vcd.y:214
PROP_OPT[]
Definition: msmbend.cpp:111
qucs::matrix calcMatrixZ(nr_double_t)
Definition: msmbend.cpp:44
void calcSP(nr_double_t)
Definition: msmbend.cpp:40
#define VSRC_1
Definition: circuit.h:40
#define PROP_COMPONENT
Definition: netdefs.h:116
matrix ztos(matrix z, qucs::vector z0)
Convert impedance matrix scattering parameters.
Definition: matrix.cpp:1018
PROP_NO_SUBSTRATE
Definition: msmbend.cpp:114
void setMatrixY(matrix)
Definition: circuit.cpp:685
#define M_PI
Archimedes' constant ( )
Definition: consts.h:47
void setMatrixS(matrix)
Definition: circuit.cpp:643
PROP_REQ[]
Definition: msmbend.cpp:107
void allocMatrixMNA(void)
Definition: circuit.cpp:267
void initAC(void)
Definition: msmbend.cpp:97
void initDC(void)
Definition: msmbend.cpp:88
#define PROP_STR
Definition: netdefs.h:175
#define NODE_1
Definition: circuit.h:34
void voltageSource(int, int, int, nr_double_t value=0.0)
Definition: circuit.cpp:748
nr_complex_t exp(const nr_complex_t z)
Compute complex exponential.
Definition: complex.cpp:205
#define LOG_ERROR
Definition: logging.h:28
#define PROP_NO_VAL
Definition: netdefs.h:124
void logprint(int level, const char *format,...)
Definition: logging.c:37
matrix ztoy(matrix z)
impedance matrix to admittance matrix.
Definition: matrix.cpp:1050