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

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :  * phaseshifter.cpp - phase shifter class implementation
       3                 :            :  *
       4                 :            :  * Copyright (C) 2004, 2008 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 "phaseshifter.h"
      31                 :            : 
      32                 :            : using namespace qucs;
      33                 :            : 
      34                 :          0 : phaseshifter::phaseshifter () : circuit (2) {
      35                 :          0 :   type = CIR_PHASESHIFTER;
      36                 :          0 : }
      37                 :            : 
      38                 :          0 : void phaseshifter::initSP (void) {
      39         [ #  # ]:          0 :   nr_double_t p = rad (getPropertyDouble ("phi"));
      40         [ #  # ]:          0 :   nr_double_t z = getPropertyDouble ("Zref");
      41                 :          0 :   nr_double_t r = (z0 - z) / (z0 + z);
      42         [ #  # ]:          0 :   nr_complex_t d = 1.0 - qucs::polar (r * r, 2 * p);
      43 [ #  # ][ #  # ]:          0 :   nr_complex_t s11 = r * (qucs::polar (1.0, 2 * p) - 1.0) / d;
      44 [ #  # ][ #  # ]:          0 :   nr_complex_t s21 = (1.0 - r * r) * qucs::polar (1.0, p) / d;
      45         [ #  # ]:          0 :   allocMatrixS ();
      46         [ #  # ]:          0 :   setS (NODE_1, NODE_1, s11);
      47         [ #  # ]:          0 :   setS (NODE_2, NODE_2, s11);
      48         [ #  # ]:          0 :   setS (NODE_1, NODE_2, s21);
      49         [ #  # ]:          0 :   setS (NODE_2, NODE_1, s21);
      50                 :          0 : }
      51                 :            : 
      52                 :          0 : void phaseshifter::initDC (void) {
      53                 :          0 :   setVoltageSources (1);
      54                 :          0 :   allocMatrixMNA ();
      55                 :          0 :   clearY ();
      56                 :          0 :   voltageSource (VSRC_1, NODE_1, NODE_2);
      57                 :          0 : }
      58                 :            : 
      59                 :          0 : void phaseshifter::initAC (void) {
      60                 :          0 :   nr_double_t p = rad (getPropertyDouble ("phi"));
      61                 :            : 
      62         [ #  # ]:          0 :   if (p == 0.0) { // no phase shift, thus a short
      63                 :          0 :     initDC ();
      64                 :            :   }
      65                 :            :   else { // compute Y-parameters directly
      66                 :          0 :     setVoltageSources (0);
      67                 :          0 :     allocMatrixMNA ();
      68                 :          0 :     nr_double_t z = getPropertyDouble ("Zref");
      69                 :          0 :     nr_double_t y11 =  1 / z / std::tan (p);
      70                 :          0 :     nr_double_t y21 = -1 / z / std::sin (p);
      71 [ #  # ][ #  # ]:          0 :     setY (NODE_1, NODE_1, nr_complex_t (0, y11)); setY (NODE_2, NODE_2, nr_complex_t (0, y11));
      72 [ #  # ][ #  # ]:          0 :     setY (NODE_1, NODE_2, nr_complex_t (0, y21)); setY (NODE_2, NODE_1, nr_complex_t (0, y21));
      73                 :            :   }
      74                 :          0 : }
      75                 :            : 
      76                 :            : // properties
      77                 :            : PROP_REQ [] = {
      78                 :            :   { "phi", PROP_REAL, { 1e-90, PROP_NO_STR }, PROP_NO_RANGE },
      79                 :            :   PROP_NO_PROP };
      80                 :            : PROP_OPT [] = {
      81                 :            :   { "Zref", PROP_REAL, { 50, PROP_NO_STR }, PROP_POS_RANGE },
      82                 :            :   PROP_NO_PROP };
      83                 :            : struct define_t phaseshifter::cirdef =
      84                 :            :   { "PShift", 2, PROP_COMPONENT, PROP_NO_SUBSTRATE, PROP_LINEAR, PROP_DEF };

Generated by: LCOV version 1.11