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

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :  * msmbend.cpp - microstrip mitered bend class implementation
       3                 :            :  *
       4                 :            :  * Copyright (C) 2004, 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 "msmbend.h"
      33                 :            : 
      34                 :            : using namespace qucs;
      35                 :            : 
      36                 :          0 : msmbend::msmbend () : circuit (2) {
      37                 :          0 :   type = CIR_MSMBEND;
      38                 :          0 : }
      39                 :            : 
      40                 :          0 : void msmbend::calcSP (nr_double_t frequency) {
      41 [ #  # ][ #  # ]:          0 :   setMatrixS (ztos (calcMatrixZ (frequency)));
         [ #  # ][ #  # ]
                 [ #  # ]
      42                 :          0 : }
      43                 :            : 
      44                 :          0 : matrix msmbend::calcMatrixZ (nr_double_t frequency) {
      45                 :            : 
      46                 :            :   /* how to get properties of this component, e.g. W */
      47         [ #  # ]:          0 :   nr_double_t W = getPropertyDouble ("W");
      48                 :            : 
      49                 :            :   /* how to get properties of the substrate, e.g. Er, H */
      50         [ #  # ]:          0 :   substrate * subst = getSubstrate ();
      51         [ #  # ]:          0 :   nr_double_t er    = subst->getPropertyDouble ("er");
      52         [ #  # ]:          0 :   nr_double_t h     = subst->getPropertyDouble ("h");
      53                 :            : 
      54                 :            :   /* local variables */
      55                 :          0 :   nr_complex_t z11, z21;
      56                 :          0 :   nr_double_t L, C, Wh = W / h;
      57                 :            : 
      58                 :            :   // check validity
      59 [ #  # ][ #  # ]:          0 :   if ((Wh < 0.2) || (Wh > 6.0)) {
      60                 :            :     logprint (LOG_ERROR, "WARNING: Model for microstrip mitered bend defined "
      61         [ #  # ]:          0 :               "for 0.2 <= W/h <= 6.0\n");
      62                 :            :   }
      63 [ #  # ][ #  # ]:          0 :   if ((er < 2.36) || (er > 10.4)) {
      64                 :            :     logprint (LOG_ERROR, "WARNING: Model for microstrip mitered bend defined "
      65         [ #  # ]:          0 :               "for 2.36 <= er <= 10.4\n");
      66                 :            :   }
      67         [ #  # ]:          0 :   if (frequency * h > 12e6) {
      68                 :            :     logprint (LOG_ERROR, "WARNING: Model for microstrip mitered bend defined "
      69         [ #  # ]:          0 :               "for freq*h <= 12MHz\n");
      70                 :            :   }
      71                 :            : 
      72                 :            :   // capacitance in pF
      73                 :          0 :   C = W * ((3.93 * er + 0.62) * Wh + (7.6 * er + 3.80));
      74                 :            :   // inductance in nH
      75 [ #  # ][ #  # ]:          0 :   L = 440.0 * h * (1.0 - 1.062 * qucs::exp (-0.177 * qucs::pow (Wh, 0.947)));
      76                 :            : 
      77                 :            :   // calculate Z-parameters
      78                 :          0 :   z21 = nr_complex_t (0.0, -0.5e12 / (M_PI * frequency * C));
      79         [ #  # ]:          0 :   z11 = nr_complex_t (0.0, 2e-9 * M_PI * frequency * L) + z21;
      80         [ #  # ]:          0 :   matrix z (2);
      81         [ #  # ]:          0 :   z.set (0, 0, z11);
      82         [ #  # ]:          0 :   z.set (0, 1, z21);
      83         [ #  # ]:          0 :   z.set (1, 0, z21);
      84         [ #  # ]:          0 :   z.set (1, 1, z11);
      85                 :          0 :   return z;
      86                 :            : }
      87                 :            : 
      88                 :          0 : void msmbend::initDC (void) {
      89                 :            :   // a DC short (voltage source V = 0 volts)
      90                 :          0 :   setVoltageSources (1);
      91                 :          0 :   setInternalVoltageSource (1);
      92                 :          0 :   allocMatrixMNA ();
      93                 :          0 :   clearY ();
      94                 :          0 :   voltageSource (VSRC_1, NODE_1, NODE_2);
      95                 :          0 : }
      96                 :            : 
      97                 :          0 : void msmbend::initAC (void) {
      98                 :          0 :   setVoltageSources (0);
      99                 :          0 :   allocMatrixMNA ();
     100                 :          0 : }
     101                 :            : 
     102                 :          0 : void msmbend::calcAC (nr_double_t frequency) {
     103 [ #  # ][ #  # ]:          0 :   setMatrixY (ztoy (calcMatrixZ (frequency)));
                 [ #  # ]
     104                 :          0 : }
     105                 :            : 
     106                 :            : // properties
     107                 :            : PROP_REQ [] = {
     108                 :            :   { "W", PROP_REAL, { 1e-3, PROP_NO_STR }, PROP_POS_RANGE },
     109                 :            :   { "Subst", PROP_STR, { PROP_NO_VAL, "Subst1" }, PROP_NO_RANGE },
     110                 :            :   PROP_NO_PROP };
     111                 :            : PROP_OPT [] = {
     112                 :            :   PROP_NO_PROP };
     113                 :            : struct define_t msmbend::cirdef =
     114                 :            :   { "MMBEND", 2, PROP_COMPONENT, PROP_NO_SUBSTRATE, PROP_LINEAR, PROP_DEF };

Generated by: LCOV version 1.11