My Project  0.0.16
QUCS Mapping
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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: msmbend.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 "msmbend.h"
33 
34 msmbend::msmbend () : circuit (2) {
35  type = CIR_MSMBEND;
36 }
37 
38 void msmbend::calcSP (nr_double_t frequency) {
39  setMatrixS (ztos (calcMatrixZ (frequency)));
40 }
41 
42 matrix msmbend::calcMatrixZ (nr_double_t frequency) {
43 
44  /* how to get properties of this component, e.g. W */
45  nr_double_t W = getPropertyDouble ("W");
46 
47  /* how to get properties of the substrate, e.g. Er, H */
48  substrate * subst = getSubstrate ();
49  nr_double_t er = subst->getPropertyDouble ("er");
50  nr_double_t h = subst->getPropertyDouble ("h");
51 
52  /* local variables */
53  nr_complex_t z11, z21;
54  nr_double_t L, C, Wh = W / h;
55 
56  // check validity
57  if ((Wh < 0.2) || (Wh > 6.0)) {
58  logprint (LOG_ERROR, "WARNING: Model for microstrip mitered bend defined "
59  "for 0.2 <= W/h <= 6.0\n");
60  }
61  if ((er < 2.36) || (er > 10.4)) {
62  logprint (LOG_ERROR, "WARNING: Model for microstrip mitered bend defined "
63  "for 2.36 <= er <= 10.4\n");
64  }
65  if (frequency * h > 12e6) {
66  logprint (LOG_ERROR, "WARNING: Model for microstrip mitered bend defined "
67  "for freq*h <= 12MHz\n");
68  }
69 
70  // capacitance in pF
71  C = W * ((3.93 * er + 0.62) * Wh + (7.6 * er + 3.80));
72  // inductance in nH
73  L = 440.0 * h * (1.0 - 1.062 * exp (-0.177 * pow (Wh, 0.947)));
74 
75  // calculate Z-parameters
76  z21 = rect (0.0, -0.5e12 / (M_PI * frequency * C));
77  z11 = rect (0.0, 2e-9 * M_PI * frequency * L) + z21;
78  matrix z (2);
79  z.set (0, 0, z11);
80  z.set (0, 1, z21);
81  z.set (1, 0, z21);
82  z.set (1, 1, z11);
83  return z;
84 }
85 
86 void msmbend::initDC (void) {
87  // a DC short (voltage source V = 0 volts)
90  allocMatrixMNA ();
91  clearY ();
93 }
94 
95 void msmbend::initAC (void) {
97  allocMatrixMNA ();
98 }
99 
100 void msmbend::calcAC (nr_double_t frequency) {
101  setMatrixY (ztoy (calcMatrixZ (frequency)));
102 }
103 
104 // properties
105 PROP_REQ [] = {
106  { "W", PROP_REAL, { 1e-3, PROP_NO_STR }, PROP_POS_RANGE },
107  { "Subst", PROP_STR, { PROP_NO_VAL, "Subst1" }, PROP_NO_RANGE },
108  PROP_NO_PROP };
109 PROP_OPT [] = {
110  PROP_NO_PROP };
111 struct define_t msmbend::cirdef =