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

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :  * isolator.cpp - isolator class implementation
       3                 :            :  *
       4                 :            :  * Copyright (C) 2003, 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 "isolator.h"
      31                 :            : 
      32                 :            : using namespace qucs;
      33                 :            : 
      34                 :          0 : isolator::isolator () : circuit (2) {
      35                 :          0 :   type = CIR_ISOLATOR;
      36                 :          0 : }
      37                 :            : 
      38                 :          0 : void isolator::initSP (void) {
      39                 :          0 :   nr_double_t z1 = getPropertyDouble ("Z1");
      40                 :          0 :   nr_double_t z2 = getPropertyDouble ("Z2");
      41                 :          0 :   nr_double_t s1 = (z1 - z0) / (z1 + z0);
      42                 :          0 :   nr_double_t s2 = (z2 - z0) / (z2 + z0);
      43                 :          0 :   allocMatrixS ();
      44         [ #  # ]:          0 :   setS (NODE_1, NODE_1, s1);
      45         [ #  # ]:          0 :   setS (NODE_2, NODE_2, s2);
      46         [ #  # ]:          0 :   setS (NODE_1, NODE_2, 0);
      47         [ #  # ]:          0 :   setS (NODE_2, NODE_1, std::sqrt (1 - s1 * s1) * std::sqrt (1 - s2 * s2));
      48                 :          0 : }
      49                 :            : 
      50                 :          0 : void isolator::calcNoiseSP (nr_double_t) {
      51                 :          0 :   nr_double_t T = getPropertyDouble ("Temp");
      52                 :          0 :   nr_double_t z1 = getPropertyDouble ("Z1");
      53                 :          0 :   nr_double_t z2 = getPropertyDouble ("Z2");
      54                 :          0 :   nr_double_t r = (z0 - z1) / (z0 + z2);
      55                 :          0 :   nr_double_t f = 4 * z0 / sqr (z1 + z0) * kelvin (T) / T0;
      56         [ #  # ]:          0 :   setN (NODE_1, NODE_1, f * z1);
      57         [ #  # ]:          0 :   setN (NODE_1, NODE_2, f * std::sqrt (z1 * z2) * r);
      58         [ #  # ]:          0 :   setN (NODE_2, NODE_1, f * std::sqrt (z1 * z2) * r);
      59         [ #  # ]:          0 :   setN (NODE_2, NODE_2, f * z2 * r * r);
      60                 :          0 : }
      61                 :            : 
      62                 :          0 : void isolator::calcNoiseAC (nr_double_t) {
      63                 :          0 :   nr_double_t T = getPropertyDouble ("Temp");
      64                 :          0 :   nr_double_t z1 = getPropertyDouble ("Z1");
      65                 :          0 :   nr_double_t z2 = getPropertyDouble ("Z2");
      66                 :          0 :   nr_double_t f = 4 * kelvin (T) / T0;
      67         [ #  # ]:          0 :   setN (NODE_1, NODE_1, +f / z1);
      68         [ #  # ]:          0 :   setN (NODE_1, NODE_2, 0);
      69         [ #  # ]:          0 :   setN (NODE_2, NODE_1, -f * 2 / std::sqrt (z1 * z2));
      70         [ #  # ]:          0 :   setN (NODE_2, NODE_2, +f / z2);
      71                 :          0 : }
      72                 :            : 
      73                 :          0 : void isolator::initDC (void) {
      74                 :          0 :   nr_double_t z1 = getPropertyDouble ("Z1");
      75                 :          0 :   nr_double_t z2 = getPropertyDouble ("Z2");
      76                 :            : #if AUGMENTED
      77                 :            :   nr_double_t z21 = 2 * std::sqrt (z1 * z2);
      78                 :            :   setVoltageSources (2);
      79                 :            :   allocMatrixMNA ();
      80                 :            :   setB (NODE_1, VSRC_1, +1.0); setB (NODE_1, VSRC_2, +0.0);
      81                 :            :   setB (NODE_2, VSRC_1, +0.0); setB (NODE_2, VSRC_2, +1.0);
      82                 :            :   setC (VSRC_1, NODE_1, -1.0); setC (VSRC_1, NODE_2, +0.0);
      83                 :            :   setC (VSRC_2, NODE_1, +0.0); setC (VSRC_2, NODE_2, -1.0);
      84                 :            :   setD (VSRC_1, VSRC_1,  +z1); setD (VSRC_2, VSRC_2,  +z2);
      85                 :            :   setD (VSRC_1, VSRC_2, +0.0); setD (VSRC_2, VSRC_1, +z21);
      86                 :            :   setE (VSRC_1, +0.0); setE (VSRC_2, +0.0);
      87                 :            : #else
      88                 :          0 :   setVoltageSources (0);
      89                 :          0 :   allocMatrixMNA ();
      90         [ #  # ]:          0 :   setY (NODE_1, NODE_1, 1 / z1);
      91         [ #  # ]:          0 :   setY (NODE_1, NODE_2, 0);
      92         [ #  # ]:          0 :   setY (NODE_2, NODE_1, -2 / std::sqrt (z1 * z2));
      93         [ #  # ]:          0 :   setY (NODE_2, NODE_2, 1 / z2);
      94                 :            : #endif
      95                 :          0 : }
      96                 :            : 
      97                 :          0 : void isolator::initAC (void) {
      98                 :          0 :   initDC ();
      99                 :          0 : }
     100                 :            : 
     101                 :          0 : void isolator::initTR (void) {
     102                 :          0 :   initDC ();
     103                 :          0 : }
     104                 :            : 
     105                 :            : // properties
     106                 :            : PROP_REQ [] = {
     107                 :            :   PROP_NO_PROP };
     108                 :            : PROP_OPT [] = {
     109                 :            :   { "Temp", PROP_REAL, { 26.85, PROP_NO_STR }, PROP_MIN_VAL (K) },
     110                 :            :   { "Z1", PROP_REAL, { 50, PROP_NO_STR }, PROP_POS_RANGE },
     111                 :            :   { "Z2", PROP_REAL, { 50, PROP_NO_STR }, PROP_POS_RANGE },
     112                 :            :   PROP_NO_PROP };
     113                 :            : struct define_t isolator::cirdef =
     114                 :            :   { "Isolator", 2, PROP_COMPONENT, PROP_NO_SUBSTRATE, PROP_LINEAR, PROP_DEF };

Generated by: LCOV version 1.11