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

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :  * msgap.cpp - microstrip gap class implementation
       3                 :            :  *
       4                 :            :  * Copyright (C) 2004, 2008, 2009 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 "msopen.h"
      33                 :            : #include "msgap.h"
      34                 :            : 
      35                 :            : using namespace qucs;
      36                 :            : 
      37                 :          0 : msgap::msgap () : circuit (2) {
      38                 :          0 :   type = CIR_MSGAP;
      39                 :          0 : }
      40                 :            : 
      41                 :          0 : void msgap::calcSP (nr_double_t frequency) {
      42 [ #  # ][ #  # ]:          0 :   setMatrixS (ytos (calcMatrixY (frequency)));
         [ #  # ][ #  # ]
                 [ #  # ]
      43                 :          0 : }
      44                 :            : 
      45                 :          0 : matrix msgap::calcMatrixY (nr_double_t frequency) {
      46                 :            : 
      47                 :            :   /* how to get properties of this component, e.g. W */
      48         [ #  # ]:          0 :   nr_double_t W1 = getPropertyDouble ("W1");
      49         [ #  # ]:          0 :   nr_double_t W2 = getPropertyDouble ("W2");
      50         [ #  # ]:          0 :   nr_double_t s  = getPropertyDouble ("S");
      51         [ #  # ]:          0 :   const char * SModel  = getPropertyString ("MSModel");
      52         [ #  # ]:          0 :   const char * DModel  = getPropertyString ("MSDispModel");
      53                 :            : 
      54                 :            :   /* how to get properties of the substrate, e.g. Er, H */
      55         [ #  # ]:          0 :   substrate * subst = getSubstrate ();
      56         [ #  # ]:          0 :   nr_double_t er    = subst->getPropertyDouble ("er");
      57         [ #  # ]:          0 :   nr_double_t h     = subst->getPropertyDouble ("h");
      58         [ #  # ]:          0 :   nr_double_t t     = subst->getPropertyDouble ("t");
      59                 :            : 
      60                 :            :   nr_double_t Q1, Q2, Q3, Q4, Q5;
      61                 :          0 :   bool flip = false;
      62         [ #  # ]:          0 :   if (W2 < W1) {  // equations are valid for 1 <= W2/W1 <= 3
      63                 :          0 :     Q1 = W1;
      64                 :          0 :     W1 = W2;
      65                 :          0 :     W2 = Q1;
      66                 :          0 :     flip = true;
      67                 :            :   }
      68                 :            : 
      69                 :            :   // calculate parallel open end capacitances
      70                 :            :   nr_double_t C1 = msopen::calcCend (frequency, W1, h, t, er,
      71         [ #  # ]:          0 :                                      SModel, DModel, "Kirschning");
      72                 :            :   nr_double_t C2 = msopen::calcCend (frequency, W2, h, t, er,
      73         [ #  # ]:          0 :                                      SModel, DModel, "Kirschning");
      74                 :            : 
      75                 :          0 :   W2 /= W1;
      76                 :          0 :   W1 /= h;
      77                 :          0 :   s  /= h;
      78                 :            : 
      79                 :            :   // local variables
      80         [ #  # ]:          0 :   Q5 = 1.23 / (1.0 + 0.12 * qucs::pow (W2 - 1.0, 0.9));
      81         [ #  # ]:          0 :   Q1 = 0.04598 * (0.03 + qucs::pow (W1, Q5)) * (0.272 + 0.07 * er);
      82         [ #  # ]:          0 :   Q2 = 0.107 * (W1 + 9.0) * qucs::pow (s, 3.23) +
      83         [ #  # ]:          0 :     2.09 * qucs::pow (s, 1.05) * (1.5 + 0.3 * W1) / (1.0 + 0.6 * W1);
      84 [ #  # ][ #  # ]:          0 :   Q3 = qucs::exp (-0.5978 * qucs::pow (W2, +1.35)) - 0.55;
      85 [ #  # ][ #  # ]:          0 :   Q4 = qucs::exp (-0.5978 * qucs::pow (W2, -1.35)) - 0.55;
      86                 :            : 
      87         [ #  # ]:          0 :   nr_double_t Cs = 5e-10 * h * qucs::exp (-1.86 * s) * Q1 *
      88 [ #  # ][ #  # ]:          0 :     (1.0 + 4.19 * (1.0 - qucs::exp (-0.785 * qucs::sqrt (1.0 / W1) * W2)));
      89                 :          0 :   C1 *= (Q2 + Q3) / (Q2 + 1.0);
      90                 :          0 :   C2 *= (Q2 + Q4) / (Q2 + 1.0);
      91                 :            : 
      92         [ #  # ]:          0 :   if (flip) { // if necessary flip ports back
      93                 :          0 :     Q1 = C1;
      94                 :          0 :     C1 = C2;
      95                 :          0 :     C2 = Q1;
      96                 :            :   }
      97                 :            : 
      98                 :            :   // build Y-parameter matrix
      99                 :          0 :   nr_complex_t y21 = nr_complex_t (0.0, -2.0 * M_PI * frequency * Cs);
     100                 :          0 :   nr_complex_t y11 = nr_complex_t (0.0,  2.0 * M_PI * frequency * (C1 + Cs));
     101                 :          0 :   nr_complex_t y22 = nr_complex_t (0.0,  2.0 * M_PI * frequency * (C2 + Cs));
     102         [ #  # ]:          0 :   matrix y (2);
     103         [ #  # ]:          0 :   y.set (0, 0, y11);
     104         [ #  # ]:          0 :   y.set (0, 1, y21);
     105         [ #  # ]:          0 :   y.set (1, 0, y21);
     106         [ #  # ]:          0 :   y.set (1, 1, y22);
     107                 :          0 :   return y;
     108                 :            : }
     109                 :            : 
     110                 :          0 : void msgap::initDC (void) {
     111                 :          0 :   allocMatrixMNA ();
     112                 :          0 :   clearY ();
     113                 :          0 : }
     114                 :            : 
     115                 :          0 : void msgap::calcAC (nr_double_t frequency) {
     116         [ #  # ]:          0 :   setMatrixY (calcMatrixY (frequency));
     117                 :          0 : }
     118                 :            : 
     119                 :            : // properties
     120                 :            : PROP_REQ [] = {
     121                 :            :   { "W1", PROP_REAL, { 1e-3, PROP_NO_STR }, PROP_POS_RANGE },
     122                 :            :   { "W2", PROP_REAL, { 1e-3, PROP_NO_STR }, PROP_POS_RANGE },
     123                 :            :   { "S" , PROP_REAL, { 1e-3, PROP_NO_STR }, PROP_POS_RANGE },
     124                 :            :   { "Subst", PROP_STR, { PROP_NO_VAL, "Subst1" }, PROP_NO_RANGE },
     125                 :            :   { "MSDispModel", PROP_STR, { PROP_NO_VAL, "Kirschning" }, PROP_RNG_DIS },
     126                 :            :   { "MSModel", PROP_STR, { PROP_NO_VAL, "Hammerstad" }, PROP_RNG_MOD },
     127                 :            :   PROP_NO_PROP };
     128                 :            : PROP_OPT [] = {
     129                 :            :   PROP_NO_PROP };
     130                 :            : struct define_t msgap::cirdef =
     131                 :            :   { "MGAP", 2, PROP_COMPONENT, PROP_NO_SUBSTRATE, PROP_LINEAR, PROP_DEF };

Generated by: LCOV version 1.11