LCOV - code coverage report
Current view: top level - src/components/microstrip - msrstub.cpp (source / functions) Hit Total Coverage
Test: qucs-core-0.0.19 Code Coverage Lines: 0 35 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 12 0.0 %

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :  * msrstub.cpp - microstrip radial stub class implementation
       3                 :            :  *
       4                 :            :  * Copyright (C) 2009 Stefan Jahn <stefan@lkcc.org>
       5                 :            :  *
       6                 :            :  * This is free software; you can redistribute it and/or modify
       7                 :            :  * it under the terms of the GNU General Public License as published by
       8                 :            :  * the Free Software Foundation; either version 2, or (at your option)
       9                 :            :  * any later version.
      10                 :            :  *
      11                 :            :  * This software is distributed in the hope that it will be useful,
      12                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      13                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      14                 :            :  * GNU General Public License for more details.
      15                 :            :  *
      16                 :            :  * You should have received a copy of the GNU General Public License
      17                 :            :  * along with this package; see the file COPYING.  If not, write to
      18                 :            :  * the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
      19                 :            :  * Boston, MA 02110-1301, USA.
      20                 :            :  *
      21                 :            :  * $Id$
      22                 :            :  *
      23                 :            :  */
      24                 :            : 
      25                 :            : #if HAVE_CONFIG_H
      26                 :            : # include <config.h>
      27                 :            : #endif
      28                 :            : 
      29                 :            : #include "component.h"
      30                 :            : #include "substrate.h"
      31                 :            : #include "msrstub.h"
      32                 :            : 
      33                 :            : using namespace qucs;
      34                 :            : 
      35                 :          0 : msrstub::msrstub () : circuit (1) {
      36                 :          0 :   type = CIR_MSRSTUB;
      37                 :          0 : }
      38                 :            : 
      39                 :            : // Returns the microstrip radial stub reactance.
      40                 :          0 : nr_double_t msrstub::calcReactance (nr_double_t r1, nr_double_t r2,
      41                 :            :                                     nr_double_t alpha, nr_double_t er,
      42                 :            :                                     nr_double_t h, nr_double_t frequency) {
      43                 :            : 
      44                 :          0 :   nr_double_t l0 = C0 / frequency;
      45                 :          0 :   nr_double_t W = (r1 + (r2 - r1) / 2) * rad (alpha);
      46                 :            :   nr_double_t ereff = (er + 1.0) / 2 + (er - 1.0) /
      47                 :          0 :     (2.0 * qucs::sqrt (1 + 10.0 * h / W));
      48                 :          0 :   nr_double_t k = 2.0 * M_PI * qucs::sqrt (ereff) / l0;
      49                 :          0 :   nr_double_t a = k * r1;
      50                 :          0 :   nr_double_t b = k * r2;
      51                 :          0 :   nr_double_t Z_0 = Z0 / qucs::sqrt (ereff) * qucs::sqrt (sqr (j0 (a)) + sqr (y0 (a))) /
      52                 :          0 :     qucs::sqrt (sqr (j1 (a)) + sqr (y1 (a)));
      53                 :          0 :   nr_double_t theta_1 = qucs::atan (y0 (a) / j0 (a));
      54                 :            :   //  nr_double_t theta_2 = atan (y0 (b) / j0 (b));
      55                 :          0 :   nr_double_t phi_1 = qucs::atan (-j1 (a) / y1 (a));
      56                 :          0 :   nr_double_t phi_2 = qucs::atan (-j1 (b) / y1 (b));
      57                 :            : 
      58                 :            :   nr_double_t X1 = h * Z_0 / (2.0 * M_PI * r1) * 360.0 / alpha *
      59                 :          0 :     qucs::cos (theta_1 - phi_2) / qucs::sin (phi_1 - phi_2);
      60                 :            : 
      61                 :          0 :   return X1;
      62                 :            : }
      63                 :            : 
      64                 :          0 : void msrstub::calcSP (nr_double_t frequency) {
      65 [ #  # ][ #  # ]:          0 :   setS (NODE_1, NODE_1, ztor (calcZ (frequency)));
                 [ #  # ]
      66                 :          0 : }
      67                 :            : 
      68                 :          0 : nr_complex_t msrstub::calcZ (nr_double_t frequency) {
      69                 :            : 
      70                 :            :   /* get properties of this component */
      71                 :          0 :   nr_double_t r1 = getPropertyDouble ("ri");
      72                 :          0 :   nr_double_t r2 = getPropertyDouble ("ro");
      73                 :          0 :   nr_double_t al = getPropertyDouble ("alpha");
      74                 :            : 
      75                 :            :   /* get properties of the substrate */
      76                 :          0 :   substrate * subst = getSubstrate ();
      77                 :          0 :   nr_double_t er    = subst->getPropertyDouble ("er");
      78                 :          0 :   nr_double_t h     = subst->getPropertyDouble ("h");
      79                 :            : 
      80                 :          0 :   return nr_complex_t (0, calcReactance (r1, r2, al, er, h, frequency));
      81                 :            : }
      82                 :            : 
      83                 :          0 : void msrstub::initDC (void) {
      84                 :          0 :   allocMatrixMNA ();
      85         [ #  # ]:          0 :   setY (NODE_1, NODE_1, 0);
      86                 :          0 : }
      87                 :            : 
      88                 :          0 : void msrstub::calcAC (nr_double_t frequency) {
      89 [ #  # ][ #  # ]:          0 :   setY (NODE_1, NODE_1, 1.0 / calcZ (frequency));
      90                 :          0 : }
      91                 :            : 
      92                 :            : // properties
      93                 :            : PROP_REQ [] = {
      94                 :            :   { "ri", PROP_REAL, { 1e-3, PROP_NO_STR }, PROP_POS_RANGE },
      95                 :            :   { "ro", PROP_REAL, { 10e-3, PROP_NO_STR }, PROP_POS_RANGE },
      96                 :            :   { "alpha", PROP_REAL, { 90, PROP_NO_STR }, PROP_RNGII (0, 180) },
      97                 :            :   { "Subst", PROP_STR, { PROP_NO_VAL, "Subst1" }, PROP_NO_RANGE },
      98                 :            :   PROP_NO_PROP };
      99                 :            : PROP_OPT [] = {
     100                 :            :   PROP_NO_PROP };
     101                 :            : struct define_t msrstub::cirdef =
     102                 :            :   { "MRSTUB", 1, PROP_COMPONENT, PROP_NO_SUBSTRATE, PROP_LINEAR, PROP_DEF };

Generated by: LCOV version 1.11