Qucs-core  0.0.19
msstep.cpp
Go to the documentation of this file.
00001 /*
00002  * msstep.cpp - microstrip impedance step class implementation
00003  *
00004  * Copyright (C) 2004, 2007, 2008 Stefan Jahn <stefan@lkcc.org>
00005  * Copyright (C) 2004 Michael Margraf <Michael.Margraf@alumni.TU-Berlin.DE>
00006  *
00007  * This is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 2, or (at your option)
00010  * any later version.
00011  *
00012  * This software is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this package; see the file COPYING.  If not, write to
00019  * the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
00020  * Boston, MA 02110-1301, USA.
00021  *
00022  * $Id$
00023  *
00024  */
00025 
00026 #if HAVE_CONFIG_H
00027 # include <config.h>
00028 #endif
00029 
00030 #include "component.h"
00031 #include "substrate.h"
00032 #include "msline.h"
00033 #include "msstep.h"
00034 
00035 using namespace qucs;
00036 
00037 msstep::msstep () : circuit (2) {
00038   type = CIR_MSSTEP;
00039 }
00040 
00041 void msstep::calcSP (nr_double_t frequency) {
00042   setMatrixS (ztos (calcMatrixZ (frequency)));
00043 }
00044 
00045 matrix msstep::calcMatrixZ (nr_double_t frequency) {
00046 
00047   /* how to get properties of this component, e.g. W */
00048   nr_double_t W1 = getPropertyDouble ("W1");
00049   nr_double_t W2 = getPropertyDouble ("W2");
00050   const char * SModel = getPropertyString ("MSModel");
00051   const char * DModel = getPropertyString ("MSDispModel");
00052 
00053   /* how to get properties of the substrate, e.g. Er, H */
00054   substrate * subst = getSubstrate ();
00055   nr_double_t er    = subst->getPropertyDouble ("er");
00056   nr_double_t h     = subst->getPropertyDouble ("h");
00057   nr_double_t t     = subst->getPropertyDouble ("t");
00058 
00059   // compute parallel capacitance
00060   nr_double_t t1 = std::log10 (er);
00061   nr_double_t t2 = W1 / W2;
00062   nr_double_t Cs = std::sqrt (W1 * W2) *
00063     (t2 * (10.1 * t1 + 2.33) - 12.6 * t1 - 3.17);
00064 
00065   // compute series inductance
00066   t1 = std::log10 (t2);
00067   t2 = t2 - 1;
00068   nr_double_t Ls = h * (t2 * (40.5 + 0.2 * t2) - 75 * t1);
00069 
00070   nr_double_t ZlEff, ErEff, WEff, ZlEffFreq, ErEffFreq;
00071   msline::analyseQuasiStatic (W1, h, t, er, SModel, ZlEff, ErEff, WEff);
00072   msline::analyseDispersion  (W1, h, er, ZlEff, ErEff, frequency, DModel,
00073                               ZlEffFreq, ErEffFreq);
00074   nr_double_t L1 = ZlEffFreq * std::sqrt (ErEffFreq) / C0;
00075 
00076   msline::analyseQuasiStatic (W2, h, t, er, SModel, ZlEff, ErEff, WEff);
00077   msline::analyseDispersion  (W2, h, er, ZlEff, ErEff, frequency, DModel,
00078                               ZlEffFreq, ErEffFreq);
00079   nr_double_t L2 = ZlEffFreq * std::sqrt (ErEffFreq) / C0;
00080 
00081   Ls /= (L1 + L2);
00082   L1 *= Ls;
00083   L2 *= Ls;
00084 
00085   // build Z-parameter matrix
00086   nr_complex_t z21 = nr_complex_t (0.0, -0.5e12 / (pi * frequency * Cs));
00087   nr_complex_t z11 = nr_complex_t (0.0, 2e-9 * pi * frequency * L1) + z21;
00088   nr_complex_t z22 = nr_complex_t (0.0, 2e-9 * pi * frequency * L2) + z21;
00089   matrix z (2);
00090   z.set (0, 0, z11);
00091   z.set (0, 1, z21);
00092   z.set (1, 0, z21);
00093   z.set (1, 1, z22);
00094   return z;
00095 }
00096 
00097 void msstep::initDC (void) {
00098   // a DC short (voltage source V = 0 volts)
00099   setVoltageSources (1);
00100   setInternalVoltageSource (1);
00101   allocMatrixMNA ();
00102   clearY ();
00103   voltageSource (VSRC_1, NODE_1, NODE_2);
00104 }
00105 
00106 void msstep::initAC (void) {
00107   setVoltageSources (0);
00108   allocMatrixMNA ();
00109 }
00110 
00111 void msstep::calcAC (nr_double_t frequency) {
00112   setMatrixY (ztoy (calcMatrixZ (frequency)));
00113 }
00114 
00115 void msstep::initTR (void) {
00116   initDC ();
00117 }
00118 
00119 // properties
00120 PROP_REQ [] = {
00121   { "W1", PROP_REAL, { 1e-3, PROP_NO_STR }, PROP_POS_RANGE },
00122   { "W2", PROP_REAL, { 1e-3, PROP_NO_STR }, PROP_POS_RANGE },
00123   { "Subst", PROP_STR, { PROP_NO_VAL, "Subst1" }, PROP_NO_RANGE },
00124   { "MSDispModel", PROP_STR, { PROP_NO_VAL, "Kirschning" }, PROP_RNG_DIS },
00125   { "MSModel", PROP_STR, { PROP_NO_VAL, "Hammerstad" }, PROP_RNG_MOD },
00126   PROP_NO_PROP };
00127 PROP_OPT [] = {
00128   PROP_NO_PROP };
00129 struct define_t msstep::cirdef =
00130   { "MSTEP", 2, PROP_COMPONENT, PROP_NO_SUBSTRATE, PROP_LINEAR, PROP_DEF };