My Project  0.0.16
QUCS Mapping
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
mscorner.cpp
Go to the documentation of this file.
1 /*
2  * mscorner.cpp - microstrip corner class implementation
3  *
4  * Copyright (C) 2004, 2006, 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: mscorner.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 "mscorner.h"
33 
34 mscorner::mscorner () : circuit (2) {
35  type = CIR_MSCORNER;
36 }
37 
38 void mscorner::initCheck (void) {
39  // get properties of substrate and corner
40  nr_double_t W = getPropertyDouble ("W");
41  substrate * subst = getSubstrate ();
42  nr_double_t er = subst->getPropertyDouble ("er");
43  h = subst->getPropertyDouble ("h");
44 
45  // local variables
46  nr_double_t Wh = W/h;
47 
48  // check validity
49  if (Wh < 0.2 || Wh > 6.0) {
50  logprint (LOG_ERROR, "WARNING: Model for microstrip corner defined for "
51  "0.2 <= W/h <= 6.0 (W/h = %g)\n", Wh);
52  }
53  if (er < 2.36 || er > 10.4) {
54  logprint (LOG_ERROR, "WARNING: Model for microstrip corner defined for "
55  "2.36 <= er <= 10.4 (er = %g)\n", er);
56  }
57 
58  // capacitance in pF
59  C = W * ((10.35 * er + 2.5) * Wh + (2.6 * er + 5.64));
60  // inductivity in nH
61  L = 220.0 * h * (1.0 - 1.35 * exp (-0.18 * pow (Wh, 1.39)));
62 }
63 
64 void mscorner::initSP (void) {
65  // allocate S-parameter matrix
66  allocMatrixS ();
67  initCheck ();
68 }
69 
70 void mscorner::calcSP (nr_double_t frequency) {
71  setMatrixS (ztos (calcMatrixZ (frequency)));
72 }
73 
74 matrix mscorner::calcMatrixZ (nr_double_t frequency) {
75  // check frequency validity
76  if (frequency * h > 12e6) {
77  logprint (LOG_ERROR, "WARNING: Model for microstrip corner defined for "
78  "freq*h <= 12MHz (is %g)\n", frequency * h);
79  }
80 
81  // create Z-parameter matrix
82  matrix z (2);
83  nr_complex_t z21 = rect (0.0, -0.5e12 / (M_PI * frequency * C));
84  nr_complex_t z11 = rect (0.0, 2e-9 * M_PI * frequency * L) + z21;
85  z.set (0, 0, z11);
86  z.set (0, 1, z21);
87  z.set (1, 0, z21);
88  z.set (1, 1, z11);
89  return z;
90 }
91 
92 void mscorner::initDC (void) {
93  // a DC short (voltage source V = 0 volts)
96  allocMatrixMNA ();
98 }
99 
100 void mscorner::initAC (void) {
101  setVoltageSources (0);
102  allocMatrixMNA ();
103  initCheck ();
104 }
105 
106 void mscorner::calcAC (nr_double_t frequency) {
107  setMatrixY (ztoy (calcMatrixZ (frequency)));
108 }
109 
110 // properties
111 PROP_REQ [] = {
112  { "W", PROP_REAL, { 1e-3, PROP_NO_STR }, PROP_POS_RANGE },
113  { "Subst", PROP_STR, { PROP_NO_VAL, "Subst1" }, PROP_NO_RANGE },
114  PROP_NO_PROP };
115 PROP_OPT [] = {
116  PROP_NO_PROP };
117 struct define_t mscorner::cirdef =