LCOV - code coverage report
Current view: top level - src/components - trafo.cpp (source / functions) Hit Total Coverage
Test: qucs-core-0.0.19 Code Coverage Lines: 23 39 59.0 %
Date: 2015-01-05 16:01:02 Functions: 4 6 66.7 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 10 52 19.2 %

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :  * trafo.cpp - trafo class implementation
       3                 :            :  *
       4                 :            :  * Copyright (C) 2003, 2004, 2005, 2008, 2011 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 "trafo.h"
      31                 :            : 
      32                 :            : using namespace qucs;
      33                 :            : 
      34                 :          8 : trafo::trafo () : circuit (4) {
      35                 :          8 :   type = CIR_TRAFO;
      36                 :          8 : }
      37                 :            : 
      38                 :          0 : void trafo::initSP (void) {
      39                 :          0 :   nr_double_t  t = getPropertyDouble ("T");
      40                 :          0 :   nr_double_t  d = t * t + 1.0;
      41                 :          0 :   nr_double_t z1 = t * t / d;
      42                 :          0 :   nr_double_t z2 = t / d;
      43                 :          0 :   nr_double_t z3 = 1 / d;
      44                 :          0 :   allocMatrixS ();
      45 [ #  # ][ #  # ]:          0 :   setS (NODE_1, NODE_1,  z1); setS (NODE_1, NODE_2,  z2);
      46 [ #  # ][ #  # ]:          0 :   setS (NODE_1, NODE_3, -z2); setS (NODE_1, NODE_4,  z3);
      47 [ #  # ][ #  # ]:          0 :   setS (NODE_2, NODE_1,  z2); setS (NODE_2, NODE_2,  z3);
      48 [ #  # ][ #  # ]:          0 :   setS (NODE_2, NODE_3,  z1); setS (NODE_2, NODE_4, -z2);
      49 [ #  # ][ #  # ]:          0 :   setS (NODE_3, NODE_1, -z2); setS (NODE_3, NODE_2,  z1);
      50 [ #  # ][ #  # ]:          0 :   setS (NODE_3, NODE_3,  z3); setS (NODE_3, NODE_4,  z2);
      51 [ #  # ][ #  # ]:          0 :   setS (NODE_4, NODE_1,  z3); setS (NODE_4, NODE_2, -z2);
      52 [ #  # ][ #  # ]:          0 :   setS (NODE_4, NODE_3,  z2); setS (NODE_4, NODE_4,  z1);
      53                 :          0 : }
      54                 :            : 
      55                 :          7 : void trafo::initDC (void) {
      56                 :          7 :   setVoltageSources (2);
      57                 :          7 :   allocMatrixMNA ();
      58                 :          7 :   voltageSource (VSRC_1, NODE_1, NODE_4);
      59                 :          7 :   voltageSource (VSRC_2, NODE_2, NODE_3);
      60                 :          7 : }
      61                 :            : 
      62                 :        206 : void trafo::initAC (void) {
      63                 :        206 :   nr_double_t t = getPropertyDouble ("T");
      64                 :        206 :   setVoltageSources (1);
      65                 :        206 :   allocMatrixMNA ();
      66 [ +  - ][ +  - ]:        206 :   setB (NODE_1, VSRC_1, -1); setB (NODE_2, VSRC_1, +t);
      67 [ +  - ][ +  - ]:        206 :   setB (NODE_3, VSRC_1, -t); setB (NODE_4, VSRC_1, +1);
      68 [ +  - ][ +  - ]:        206 :   setC (VSRC_1, NODE_1, +1); setC (VSRC_1, NODE_2, -t);
      69 [ +  - ][ +  - ]:        206 :   setC (VSRC_1, NODE_3, +t); setC (VSRC_1, NODE_4, -1);
      70         [ +  - ]:        206 :   setD (VSRC_1, VSRC_1, +0);
      71         [ +  - ]:        206 :   setE (VSRC_1, 0);
      72                 :        206 : }
      73                 :            : 
      74                 :          6 : void trafo::initTR (void) {
      75                 :          6 :   initAC ();
      76                 :          6 : }
      77                 :            : 
      78                 :            : // properties
      79                 :            : PROP_REQ [] = {
      80                 :            :   { "T", PROP_REAL, { 1, PROP_NO_STR }, PROP_POS_RANGE }, PROP_NO_PROP };
      81                 :            : PROP_OPT [] = {
      82                 :            :   PROP_NO_PROP };
      83                 :            : struct define_t trafo::cirdef =
      84                 :            :   { "Tr", 4, PROP_COMPONENT, PROP_NO_SUBSTRATE, PROP_LINEAR, PROP_DEF };

Generated by: LCOV version 1.11