Qucs-core  0.0.18
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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$
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 using namespace qucs;
35 
36 mscorner::mscorner () : circuit (2) {
37  type = CIR_MSCORNER;
38 }
39 
40 void mscorner::initCheck (void) {
41  // get properties of substrate and corner
42  nr_double_t W = getPropertyDouble ("W");
44  nr_double_t er = subst->getPropertyDouble ("er");
45  h = subst->getPropertyDouble ("h");
46 
47  // local variables
48  nr_double_t Wh = W/h;
49 
50  // check validity
51  if (Wh < 0.2 || Wh > 6.0) {
52  logprint (LOG_ERROR, "WARNING: Model for microstrip corner defined for "
53  "0.2 <= W/h <= 6.0 (W/h = %g)\n", Wh);
54  }
55  if (er < 2.36 || er > 10.4) {
56  logprint (LOG_ERROR, "WARNING: Model for microstrip corner defined for "
57  "2.36 <= er <= 10.4 (er = %g)\n", er);
58  }
59 
60  // capacitance in pF
61  C = W * ((10.35 * er + 2.5) * Wh + (2.6 * er + 5.64));
62  // inductivity in nH
63  L = 220.0 * h * (1.0 - 1.35 * qucs::exp (-0.18 * qucs::pow (Wh, 1.39)));
64 }
65 
66 void mscorner::initSP (void) {
67  // allocate S-parameter matrix
68  allocMatrixS ();
69  initCheck ();
70 }
71 
72 void mscorner::calcSP (nr_double_t frequency) {
73  setMatrixS (ztos (calcMatrixZ (frequency)));
74 }
75 
76 matrix mscorner::calcMatrixZ (nr_double_t frequency) {
77  // check frequency validity
78  if (frequency * h > 12e6) {
79  logprint (LOG_ERROR, "WARNING: Model for microstrip corner defined for "
80  "freq*h <= 12MHz (is %g)\n", frequency * h);
81  }
82 
83  // create Z-parameter matrix
84  matrix z (2);
85  nr_complex_t z21 = nr_complex_t (0.0, -0.5e12 / (M_PI * frequency * C));
86  nr_complex_t z11 = nr_complex_t (0.0, 2e-9 * M_PI * frequency * L) + z21;
87  z.set (0, 0, z11);
88  z.set (0, 1, z21);
89  z.set (1, 0, z21);
90  z.set (1, 1, z11);
91  return z;
92 }
93 
94 void mscorner::initDC (void) {
95  // a DC short (voltage source V = 0 volts)
98  allocMatrixMNA ();
100 }
101 
102 void mscorner::initAC (void) {
103  setVoltageSources (0);
104  allocMatrixMNA ();
105  initCheck ();
106 }
107 
108 void mscorner::calcAC (nr_double_t frequency) {
109  setMatrixY (ztoy (calcMatrixZ (frequency)));
110 }
111 
112 // properties
113 PROP_REQ [] = {
114  { "W", PROP_REAL, { 1e-3, PROP_NO_STR }, PROP_POS_RANGE },
115  { "Subst", PROP_STR, { PROP_NO_VAL, "Subst1" }, PROP_NO_RANGE },
116  PROP_NO_PROP };
117 PROP_OPT [] = {
118  PROP_NO_PROP };
119 struct define_t mscorner::cirdef =
std::complex< nr_double_t > nr_complex_t
Definition: complex.h:31
#define PROP_POS_RANGE
Definition: netdefs.h:129
#define NODE_2
Definition: circuit.h:35
substrate * subst
Definition: circuit.h:350
void initSP(void)
placehoder for S-Parameter initialisation function
Definition: mscorner.cpp:66
#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 PROP_REAL
Definition: netdefs.h:174
substrate * getSubstrate(void)
Definition: circuit.cpp:332
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
void allocMatrixS(void)
Definition: circuit.cpp:251
nr_double_t C
Definition: mscorner.h:42
#define PROP_LINEAR
Definition: netdefs.h:120
PROP_OPT[]
Definition: mscorner.cpp:117
nr_double_t L
Definition: mscorner.h:42
nr_double_t h
Definition: mscorner.h:42
#define VSRC_1
Definition: circuit.h:40
void initCheck(void)
Definition: mscorner.cpp:40
#define PROP_COMPONENT
Definition: netdefs.h:116
matrix ztos(matrix z, qucs::vector z0)
Convert impedance matrix scattering parameters.
Definition: matrix.cpp:1018
void initDC(void)
Definition: mscorner.cpp:94
void setMatrixY(matrix)
Definition: circuit.cpp:685
#define M_PI
Archimedes' constant ( )
Definition: consts.h:47
qucs::matrix calcMatrixZ(nr_double_t)
Definition: mscorner.cpp:76
void setMatrixS(matrix)
Definition: circuit.cpp:643
void calcAC(nr_double_t)
Definition: mscorner.cpp:108
void allocMatrixMNA(void)
Definition: circuit.cpp:267
PROP_NO_SUBSTRATE
Definition: mscorner.cpp:120
#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
void calcSP(nr_double_t)
Definition: mscorner.cpp:72
#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
PROP_REQ[]
Definition: mscorner.cpp:113
void initAC(void)
Definition: mscorner.cpp:102