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

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :  * ctline.cpp - ideal coupled transmission line class implementation
       3                 :            :  *
       4                 :            :  * Copyright (C) 2011 Michael Margraf <michael.margraf@alumni.tu-berlin.de>
       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: ctline.cpp 1876 2013-03-11 08:00:11Z fransschreuder $
      22                 :            :  *
      23                 :            :  */
      24                 :            : 
      25                 :            : #if HAVE_CONFIG_H
      26                 :            : # include <config.h>
      27                 :            : #endif
      28                 :            : 
      29                 :            : #include "component.h"
      30                 :            : #include "ctline.h"
      31                 :            : 
      32                 :            : using namespace qucs;
      33                 :            : 
      34                 :          0 : ctline::ctline () : circuit (4) {
      35                 :          0 :   type = CIR_CTLINE;
      36                 :          0 : }
      37                 :            : 
      38                 :          0 : void ctline::calcSP (nr_double_t frequency) {
      39         [ #  # ]:          0 :   nr_double_t l   = getPropertyDouble ("L");
      40         [ #  # ]:          0 :   nr_double_t ze  = getPropertyDouble ("Ze");
      41         [ #  # ]:          0 :   nr_double_t zo  = getPropertyDouble ("Zo");
      42         [ #  # ]:          0 :   nr_double_t ere = getPropertyDouble ("Ere");
      43         [ #  # ]:          0 :   nr_double_t ero = getPropertyDouble ("Ero");
      44         [ #  # ]:          0 :   nr_double_t ae  = getPropertyDouble ("Ae");
      45         [ #  # ]:          0 :   nr_double_t ao  = getPropertyDouble ("Ao");
      46                 :          0 :   nr_double_t o   = 2.0 * M_PI * frequency;
      47                 :            : 
      48                 :          0 :   nr_complex_t ge = nr_complex_t (std::log (ae) / 2, o / C0 * std::sqrt (ere)) * l;
      49                 :          0 :   nr_complex_t go = nr_complex_t (std::log (ao) / 2, o / C0 * std::sqrt (ero)) * l;
      50         [ #  # ]:          0 :   nr_complex_t xe = 2.0 * ze * z0 * std::cosh (ge) + (ze*ze + z0*z0) * std::sinh (ge);
      51         [ #  # ]:          0 :   nr_complex_t xo = 2.0 * zo * z0 * std::cosh (go) + (zo*zo + z0*z0) * std::sinh (go);
      52         [ #  # ]:          0 :   nr_complex_t ye = ze * z0 / xe;
      53         [ #  # ]:          0 :   nr_complex_t yo = zo * z0 / xo;
      54         [ #  # ]:          0 :   xe = (ze*ze - z0*z0) * std::sinh (ge) / 2.0 / xe;
      55         [ #  # ]:          0 :   xo = (zo*zo - z0*z0) * std::sinh (go) / 2.0 / xo;
      56                 :            : 
      57 [ #  # ][ #  # ]:          0 :   setS (NODE_1, NODE_1, xe+xo); setS (NODE_2, NODE_2, xe+xo);
         [ #  # ][ #  # ]
      58 [ #  # ][ #  # ]:          0 :   setS (NODE_3, NODE_3, xe+xo); setS (NODE_4, NODE_4, xe+xo);
         [ #  # ][ #  # ]
      59 [ #  # ][ #  # ]:          0 :   setS (NODE_1, NODE_4, xe-xo); setS (NODE_4, NODE_1, xe-xo);
         [ #  # ][ #  # ]
      60 [ #  # ][ #  # ]:          0 :   setS (NODE_2, NODE_3, xe-xo); setS (NODE_3, NODE_2, xe-xo);
         [ #  # ][ #  # ]
      61 [ #  # ][ #  # ]:          0 :   setS (NODE_1, NODE_2, ye+yo); setS (NODE_2, NODE_1, ye+yo);
         [ #  # ][ #  # ]
      62 [ #  # ][ #  # ]:          0 :   setS (NODE_3, NODE_4, ye+yo); setS (NODE_4, NODE_3, ye+yo);
         [ #  # ][ #  # ]
      63 [ #  # ][ #  # ]:          0 :   setS (NODE_1, NODE_3, ye-yo); setS (NODE_3, NODE_1, ye-yo);
         [ #  # ][ #  # ]
      64 [ #  # ][ #  # ]:          0 :   setS (NODE_2, NODE_4, ye-yo); setS (NODE_4, NODE_2, ye-yo);
         [ #  # ][ #  # ]
      65                 :          0 : }
      66                 :            : 
      67                 :          0 : void ctline::calcNoiseSP (nr_double_t) {
      68         [ #  # ]:          0 :   nr_double_t l = getPropertyDouble ("L");
      69         [ #  # ]:          0 :   if (l < 0) return;
      70                 :            :   // calculate noise using Bosma's theorem
      71         [ #  # ]:          0 :   nr_double_t T = getPropertyDouble ("Temp");
      72         [ #  # ]:          0 :   matrix s = getMatrixS ();
      73         [ #  # ]:          0 :   matrix e = eye (getSize ());
      74 [ #  # ][ #  # ]:          0 :   setMatrixN (kelvin (T) / T0 * (e - s * transpose (conj (s))));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
      75                 :            : }
      76                 :            : 
      77                 :          0 : void ctline::calcNoiseAC (nr_double_t) {
      78                 :          0 :   nr_double_t l = getPropertyDouble ("L");
      79         [ #  # ]:          0 :   if (l < 0) return;
      80                 :            :   // calculate noise using Bosma's theorem
      81                 :          0 :   nr_double_t T = getPropertyDouble ("Temp");
      82 [ #  # ][ #  # ]:          0 :   setMatrixN (4 * kelvin (T) / T0 * real (getMatrixY ()));
         [ #  # ][ #  # ]
                 [ #  # ]
      83                 :            : }
      84                 :            : 
      85                 :          0 : void ctline::initDC (void) {
      86                 :          0 :   setVoltageSources (2);
      87                 :          0 :   allocMatrixMNA ();
      88                 :          0 :   voltageSource (VSRC_1, NODE_1, NODE_2);
      89                 :          0 :   voltageSource (VSRC_2, NODE_3, NODE_4);
      90                 :          0 : }
      91                 :            : 
      92                 :          0 : void ctline::initAC (void) {
      93                 :          0 :   nr_double_t l = getPropertyDouble ("L");
      94         [ #  # ]:          0 :   if (l != 0.0) {
      95                 :          0 :     setVoltageSources (0);
      96                 :          0 :     allocMatrixMNA ();
      97                 :            :   } else {
      98                 :          0 :     setVoltageSources (2);
      99                 :          0 :     allocMatrixMNA ();
     100                 :          0 :     voltageSource (VSRC_1, NODE_1, NODE_2);
     101                 :          0 :     voltageSource (VSRC_2, NODE_3, NODE_4);
     102                 :            :   }
     103                 :          0 : }
     104                 :            : 
     105                 :          0 : void ctline::calcAC (nr_double_t frequency) {
     106         [ #  # ]:          0 :   nr_double_t l   = getPropertyDouble ("L");
     107         [ #  # ]:          0 :   nr_double_t ze  = getPropertyDouble ("Ze");
     108         [ #  # ]:          0 :   nr_double_t zo  = getPropertyDouble ("Zo");
     109         [ #  # ]:          0 :   nr_double_t ere = getPropertyDouble ("Ere");
     110         [ #  # ]:          0 :   nr_double_t ero = getPropertyDouble ("Ero");
     111         [ #  # ]:          0 :   nr_double_t ae  = getPropertyDouble ("Ae");
     112         [ #  # ]:          0 :   nr_double_t ao  = getPropertyDouble ("Ao");
     113                 :          0 :   nr_double_t o   = 2.0 * M_PI * frequency;
     114                 :            : 
     115         [ #  # ]:          0 :   if (l != 0.0) {
     116                 :          0 :     nr_complex_t y11, y12, y13, y14;
     117                 :          0 :     nr_complex_t arg_e = nr_complex_t (std::log (ae) / 2.0, o / C0 * std::sqrt (ere)) * l;
     118                 :          0 :     nr_complex_t arg_o = nr_complex_t (std::log (ao) / 2.0, o / C0 * std::sqrt (ero)) * l;
     119                 :            : 
     120 [ #  # ][ #  # ]:          0 :     y12   =  0.5 / sinh (arg_e) / ze;
     121 [ #  # ][ #  # ]:          0 :     y13   = -0.5 / sinh (arg_o) / zo;
     122         [ #  # ]:          0 :     arg_e = std::cosh (arg_e) * y12;
     123         [ #  # ]:          0 :     arg_o = std::cosh (arg_o) * y13;
     124         [ #  # ]:          0 :     y11   = arg_e - arg_o;
     125         [ #  # ]:          0 :     y14   = arg_e + arg_o;
     126                 :          0 :     arg_e = y12;
     127         [ #  # ]:          0 :     y12   =  y13 - y12;
     128         [ #  # ]:          0 :     y13   = -y13 - arg_e;
     129                 :            : 
     130 [ #  # ][ #  # ]:          0 :     setY (NODE_1, NODE_1, +y11); setY (NODE_2, NODE_2, +y11);
     131 [ #  # ][ #  # ]:          0 :     setY (NODE_3, NODE_3, +y11); setY (NODE_4, NODE_4, +y11);
     132 [ #  # ][ #  # ]:          0 :     setY (NODE_1, NODE_2, +y12); setY (NODE_2, NODE_1, +y12);
     133 [ #  # ][ #  # ]:          0 :     setY (NODE_3, NODE_4, +y12); setY (NODE_4, NODE_3, +y12);
     134 [ #  # ][ #  # ]:          0 :     setY (NODE_1, NODE_3, +y13); setY (NODE_3, NODE_1, +y13);
     135 [ #  # ][ #  # ]:          0 :     setY (NODE_2, NODE_4, +y13); setY (NODE_4, NODE_2, +y13);
     136 [ #  # ][ #  # ]:          0 :     setY (NODE_1, NODE_4, +y14); setY (NODE_4, NODE_1, +y14);
     137 [ #  # ][ #  # ]:          0 :     setY (NODE_2, NODE_3, +y14); setY (NODE_3, NODE_2, +y14);
     138                 :            :   }
     139                 :          0 : }
     140                 :            : 
     141                 :            : // properties
     142                 :            : PROP_REQ [] = {
     143                 :            :   { "Ze", PROP_REAL, { 50, PROP_NO_STR }, PROP_POS_RANGE },
     144                 :            :   { "Zo", PROP_REAL, { 50, PROP_NO_STR }, PROP_POS_RANGE },
     145                 :            :   { "L", PROP_REAL, { 1e-3, PROP_NO_STR }, PROP_NO_RANGE },
     146                 :            :   PROP_NO_PROP };
     147                 :            : PROP_OPT [] = {
     148                 :            :   { "Ere", PROP_REAL, { 1, PROP_NO_STR }, PROP_POS_RANGE },
     149                 :            :   { "Ero", PROP_REAL, { 1, PROP_NO_STR }, PROP_POS_RANGE },
     150                 :            :   { "Ae", PROP_REAL, { 1, PROP_NO_STR }, PROP_POS_RANGEX },
     151                 :            :   { "Ao", PROP_REAL, { 1, PROP_NO_STR }, PROP_POS_RANGEX },
     152                 :            :   { "Temp", PROP_REAL, { 26.85, PROP_NO_STR }, PROP_MIN_VAL (K) },
     153                 :            :   PROP_NO_PROP };
     154                 :            : struct define_t ctline::cirdef =
     155                 :            :   { "CTLIN", 4, PROP_COMPONENT, PROP_NO_SUBSTRATE, PROP_LINEAR, PROP_DEF };

Generated by: LCOV version 1.11