Qucs-core
0.0.19
|
00001 /* 00002 * msrstub.cpp - microstrip radial stub class implementation 00003 * 00004 * Copyright (C) 2009 Stefan Jahn <stefan@lkcc.org> 00005 * 00006 * This is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 2, or (at your option) 00009 * any later version. 00010 * 00011 * This software is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this package; see the file COPYING. If not, write to 00018 * the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, 00019 * Boston, MA 02110-1301, USA. 00020 * 00021 * $Id$ 00022 * 00023 */ 00024 00025 #if HAVE_CONFIG_H 00026 # include <config.h> 00027 #endif 00028 00029 #include "component.h" 00030 #include "substrate.h" 00031 #include "msrstub.h" 00032 00033 using namespace qucs; 00034 00035 msrstub::msrstub () : circuit (1) { 00036 type = CIR_MSRSTUB; 00037 } 00038 00039 // Returns the microstrip radial stub reactance. 00040 nr_double_t msrstub::calcReactance (nr_double_t r1, nr_double_t r2, 00041 nr_double_t alpha, nr_double_t er, 00042 nr_double_t h, nr_double_t frequency) { 00043 00044 nr_double_t l0 = C0 / frequency; 00045 nr_double_t W = (r1 + (r2 - r1) / 2) * deg2rad (alpha); 00046 nr_double_t ereff = (er + 1.0) / 2 + (er - 1.0) / 00047 (2.0 * qucs::sqrt (1 + 10.0 * h / W)); 00048 nr_double_t k = 2.0 * pi * qucs::sqrt (ereff) / l0; 00049 nr_double_t a = k * r1; 00050 nr_double_t b = k * r2; 00051 nr_double_t Z_0 = Z0 / qucs::sqrt (ereff) * qucs::sqrt (sqr (j0 (a)) + sqr (y0 (a))) / 00052 qucs::sqrt (sqr (j1 (a)) + sqr (y1 (a))); 00053 nr_double_t theta_1 = qucs::atan (y0 (a) / j0 (a)); 00054 // nr_double_t theta_2 = atan (y0 (b) / j0 (b)); 00055 nr_double_t phi_1 = qucs::atan (-j1 (a) / y1 (a)); 00056 nr_double_t phi_2 = qucs::atan (-j1 (b) / y1 (b)); 00057 00058 nr_double_t X1 = h * Z_0 / (2.0 * pi * r1) * 360.0 / alpha * 00059 qucs::cos (theta_1 - phi_2) / qucs::sin (phi_1 - phi_2); 00060 00061 return X1; 00062 } 00063 00064 void msrstub::calcSP (nr_double_t frequency) { 00065 setS (NODE_1, NODE_1, ztor (calcZ (frequency))); 00066 } 00067 00068 nr_complex_t msrstub::calcZ (nr_double_t frequency) { 00069 00070 /* get properties of this component */ 00071 nr_double_t r1 = getPropertyDouble ("ri"); 00072 nr_double_t r2 = getPropertyDouble ("ro"); 00073 nr_double_t al = getPropertyDouble ("alpha"); 00074 00075 /* get properties of the substrate */ 00076 substrate * subst = getSubstrate (); 00077 nr_double_t er = subst->getPropertyDouble ("er"); 00078 nr_double_t h = subst->getPropertyDouble ("h"); 00079 00080 return nr_complex_t (0, calcReactance (r1, r2, al, er, h, frequency)); 00081 } 00082 00083 void msrstub::initDC (void) { 00084 allocMatrixMNA (); 00085 setY (NODE_1, NODE_1, 0); 00086 } 00087 00088 void msrstub::calcAC (nr_double_t frequency) { 00089 setY (NODE_1, NODE_1, 1.0 / calcZ (frequency)); 00090 } 00091 00092 // properties 00093 PROP_REQ [] = { 00094 { "ri", PROP_REAL, { 1e-3, PROP_NO_STR }, PROP_POS_RANGE }, 00095 { "ro", PROP_REAL, { 10e-3, PROP_NO_STR }, PROP_POS_RANGE }, 00096 { "alpha", PROP_REAL, { 90, PROP_NO_STR }, PROP_RNGII (0, 180) }, 00097 { "Subst", PROP_STR, { PROP_NO_VAL, "Subst1" }, PROP_NO_RANGE }, 00098 PROP_NO_PROP }; 00099 PROP_OPT [] = { 00100 PROP_NO_PROP }; 00101 struct define_t msrstub::cirdef = 00102 { "MRSTUB", 1, PROP_COMPONENT, PROP_NO_SUBSTRATE, PROP_LINEAR, PROP_DEF };