LCOV - code coverage report
Current view: top level - src/components - gyrator.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 6 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 48 0.0 %

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :  * gyrator.cpp - gyrator class implementation
       3                 :            :  *
       4                 :            :  * Copyright (C) 2004, 2005, 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 "gyrator.h"
      31                 :            : 
      32                 :            : using namespace qucs;
      33                 :            : 
      34                 :          0 : gyrator::gyrator () : circuit (4) {
      35                 :          0 :   type = CIR_GYRATOR;
      36                 :            : #if AUGMENTED
      37                 :            :   setVoltageSources (2);
      38                 :            : #endif
      39                 :          0 : }
      40                 :            : 
      41                 :          0 : void gyrator::initSP (void) {
      42                 :          0 :   nr_double_t R = getPropertyDouble ("R");
      43                 :          0 :   nr_double_t z = getPropertyDouble ("Zref");
      44                 :          0 :   nr_double_t r = R / z;
      45                 :          0 :   nr_double_t s1 = r * r / (r * r + 4.0);
      46                 :          0 :   nr_double_t s2 = 2.0 * r / (r * r + 4.0);
      47                 :          0 :   allocMatrixS ();
      48 [ #  # ][ #  # ]:          0 :   setS (NODE_1, NODE_1, s1); setS (NODE_2, NODE_2, s1);
      49 [ #  # ][ #  # ]:          0 :   setS (NODE_3, NODE_3, s1); setS (NODE_4, NODE_4, s1);
      50         [ #  # ]:          0 :   setS (NODE_1, NODE_4, 1.0 - s1);
      51         [ #  # ]:          0 :   setS (NODE_2, NODE_3, 1.0 - s1);
      52         [ #  # ]:          0 :   setS (NODE_3, NODE_2, 1.0 - s1);
      53         [ #  # ]:          0 :   setS (NODE_4, NODE_1, 1.0 - s1);
      54 [ #  # ][ #  # ]:          0 :   setS (NODE_1, NODE_2, +s2); setS (NODE_2, NODE_4, +s2);
      55 [ #  # ][ #  # ]:          0 :   setS (NODE_3, NODE_1, +s2); setS (NODE_4, NODE_3, +s2);
      56 [ #  # ][ #  # ]:          0 :   setS (NODE_1, NODE_3, -s2); setS (NODE_2, NODE_1, -s2);
      57 [ #  # ][ #  # ]:          0 :   setS (NODE_3, NODE_4, -s2); setS (NODE_4, NODE_2, -s2);
      58                 :          0 : }
      59                 :            : 
      60                 :          0 : void gyrator::initDC (void) {
      61                 :          0 :   nr_double_t r = getPropertyDouble ("R");
      62                 :          0 :   allocMatrixMNA ();
      63                 :            : #if AUGMENTED
      64                 :            :   setB (NODE_1, VSRC_1, +1.0); setB (NODE_2, VSRC_1, +0.0);
      65                 :            :   setB (NODE_3, VSRC_1, +0.0); setB (NODE_4, VSRC_1, -1.0);
      66                 :            :   setB (NODE_2, VSRC_1, +0.0); setB (NODE_2, VSRC_2, +1.0);
      67                 :            :   setB (NODE_3, VSRC_2, -1.0); setB (NODE_4, VSRC_2, +0.0);
      68                 :            :   setC (VSRC_1, NODE_1, +0.0); setC (VSRC_1, NODE_2, +1/r);
      69                 :            :   setC (VSRC_1, NODE_3, -1/r); setC (VSRC_1, NODE_4, +0.0);
      70                 :            :   setC (VSRC_2, NODE_1, -1/r); setC (VSRC_2, NODE_2, +0.0);
      71                 :            :   setC (VSRC_2, NODE_3, +0.0); setC (VSRC_2, NODE_4, +1/r);
      72                 :            :   setD (VSRC_1, VSRC_1, -1.0); setD (VSRC_2, VSRC_2, -1.0);
      73                 :            :   setD (VSRC_1, VSRC_2, +0.0); setD (VSRC_2, VSRC_1, +0.0);
      74                 :            :   setE (VSRC_1, +0.0);
      75                 :            :   setE (VSRC_2, +0.0);
      76                 :            : #else
      77 [ #  # ][ #  # ]:          0 :   setY (NODE_1, NODE_2, +1/r); setY (NODE_1, NODE_3, -1/r);
      78 [ #  # ][ #  # ]:          0 :   setY (NODE_2, NODE_1, -1/r); setY (NODE_2, NODE_4, +1/r);
      79 [ #  # ][ #  # ]:          0 :   setY (NODE_3, NODE_1, +1/r); setY (NODE_3, NODE_4, -1/r);
      80 [ #  # ][ #  # ]:          0 :   setY (NODE_4, NODE_2, -1/r); setY (NODE_4, NODE_3, +1/r);
      81                 :            : #endif
      82                 :          0 : }
      83                 :            : 
      84                 :          0 : void gyrator::initAC (void) {
      85                 :          0 :   initDC ();
      86                 :          0 : }
      87                 :            : 
      88                 :          0 : void gyrator::initTR (void) {
      89                 :          0 :   initDC ();
      90                 :          0 : }
      91                 :            : 
      92                 :            : // properties
      93                 :            : PROP_REQ [] = {
      94                 :            :   { "R", PROP_REAL, { 50, PROP_NO_STR }, PROP_NO_RANGE }, PROP_NO_PROP };
      95                 :            : PROP_OPT [] = {
      96                 :            :   { "Zref", PROP_REAL, { 50, PROP_NO_STR }, PROP_POS_RANGE },
      97                 :            :   PROP_NO_PROP };
      98                 :            : struct define_t gyrator::cirdef =
      99                 :            :   { "Gyrator", 4, PROP_COMPONENT, PROP_NO_SUBSTRATE, PROP_LINEAR, PROP_DEF };

Generated by: LCOV version 1.11