LCOV - code coverage report
Current view: top level - src/components/microstrip - mscorner.cpp (source / functions) Hit Total Coverage
Test: qucs-core-0.0.19 Code Coverage Lines: 0 48 0.0 %
Date: 2015-01-05 16:01:02 Functions: 0 9 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 40 0.0 %

           Branch data     Line data    Source code
       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                 :          0 : mscorner::mscorner () : circuit (2) {
      37                 :          0 :   type = CIR_MSCORNER;
      38                 :          0 : }
      39                 :            : 
      40                 :          0 : void mscorner::initCheck (void) {
      41                 :            :   // get properties of substrate and corner
      42                 :          0 :   nr_double_t W = getPropertyDouble ("W");
      43                 :          0 :   substrate * subst = getSubstrate ();
      44                 :          0 :   nr_double_t er = subst->getPropertyDouble ("er");
      45                 :          0 :   h = subst->getPropertyDouble ("h");
      46                 :            : 
      47                 :            :   // local variables
      48                 :          0 :   nr_double_t Wh = W/h;
      49                 :            : 
      50                 :            :   // check validity
      51 [ #  # ][ #  # ]:          0 :   if (Wh < 0.2 || Wh > 6.0) {
      52                 :            :     logprint (LOG_ERROR, "WARNING: Model for microstrip corner defined for "
      53                 :          0 :               "0.2 <= W/h <= 6.0 (W/h = %g)\n", Wh);
      54                 :            :   }
      55 [ #  # ][ #  # ]:          0 :   if (er < 2.36 || er > 10.4) {
      56                 :            :     logprint (LOG_ERROR, "WARNING: Model for microstrip corner defined for "
      57                 :          0 :               "2.36 <= er <= 10.4 (er = %g)\n", er);
      58                 :            :   }
      59                 :            : 
      60                 :            :   // capacitance in pF
      61                 :          0 :   C = W * ((10.35 * er + 2.5) * Wh + (2.6 * er + 5.64));
      62                 :            :   // inductivity in nH
      63                 :          0 :   L = 220.0 * h * (1.0 - 1.35 * qucs::exp (-0.18 * qucs::pow (Wh, 1.39)));
      64                 :          0 : }
      65                 :            : 
      66                 :          0 : void mscorner::initSP (void) {
      67                 :            :   // allocate S-parameter matrix
      68                 :          0 :   allocMatrixS ();
      69                 :          0 :   initCheck ();
      70                 :          0 : }
      71                 :            : 
      72                 :          0 : void mscorner::calcSP (nr_double_t frequency) {
      73 [ #  # ][ #  # ]:          0 :   setMatrixS (ztos (calcMatrixZ (frequency)));
         [ #  # ][ #  # ]
                 [ #  # ]
      74                 :          0 : }
      75                 :            : 
      76                 :          0 : matrix mscorner::calcMatrixZ (nr_double_t frequency) {
      77                 :            :   // check frequency validity
      78         [ #  # ]:          0 :   if (frequency * h > 12e6) {
      79                 :            :     logprint (LOG_ERROR, "WARNING: Model for microstrip corner defined for "
      80         [ #  # ]:          0 :               "freq*h <= 12MHz (is %g)\n", frequency * h);
      81                 :            :   }
      82                 :            : 
      83                 :            :   // create Z-parameter matrix
      84         [ #  # ]:          0 :   matrix z (2);
      85                 :          0 :   nr_complex_t z21 = nr_complex_t (0.0, -0.5e12 / (M_PI * frequency * C));
      86         [ #  # ]:          0 :   nr_complex_t z11 = nr_complex_t (0.0, 2e-9 * M_PI * frequency * L) + z21;
      87         [ #  # ]:          0 :   z.set (0, 0, z11);
      88         [ #  # ]:          0 :   z.set (0, 1, z21);
      89         [ #  # ]:          0 :   z.set (1, 0, z21);
      90         [ #  # ]:          0 :   z.set (1, 1, z11);
      91                 :          0 :   return z;
      92                 :            : }
      93                 :            : 
      94                 :          0 : void mscorner::initDC (void) {
      95                 :            :   // a DC short (voltage source V = 0 volts)
      96                 :          0 :   setVoltageSources (1);
      97                 :          0 :   setInternalVoltageSource (1);
      98                 :          0 :   allocMatrixMNA ();
      99                 :          0 :   voltageSource (VSRC_1, NODE_1, NODE_2);
     100                 :          0 : }
     101                 :            : 
     102                 :          0 : void mscorner::initAC (void) {
     103                 :          0 :   setVoltageSources (0);
     104                 :          0 :   allocMatrixMNA ();
     105                 :          0 :   initCheck ();
     106                 :          0 : }
     107                 :            : 
     108                 :          0 : void mscorner::calcAC (nr_double_t frequency) {
     109 [ #  # ][ #  # ]:          0 :   setMatrixY (ztoy (calcMatrixZ (frequency)));
                 [ #  # ]
     110                 :          0 : }
     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 =
     120                 :            :   { "MCORN", 2, PROP_COMPONENT, PROP_NO_SUBSTRATE, PROP_LINEAR, PROP_DEF };

Generated by: LCOV version 1.11