LCOV - code coverage report
Current view: top level - src/components - iinoise.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 56 0.0 %

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :  * iinoise.cpp - correlated noise current sources class implementation
       3                 :            :  *
       4                 :            :  * Copyright (C) 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 "iinoise.h"
      31                 :            : 
      32                 :            : #define NODE_I1P 0
      33                 :            : #define NODE_I1N 3
      34                 :            : #define NODE_I2P 1
      35                 :            : #define NODE_I2N 2
      36                 :            : 
      37                 :            : using namespace qucs;
      38                 :            : 
      39                 :          0 : iinoise::iinoise () : circuit (4) {
      40                 :          0 :   type = CIR_IINOISE;
      41                 :          0 : }
      42                 :            : 
      43                 :          0 : void iinoise::initSP (void) {
      44                 :          0 :   allocMatrixS ();
      45         [ #  # ]:          0 :   setS (NODE_I1P, NODE_I1P, 1.0);
      46         [ #  # ]:          0 :   setS (NODE_I1N, NODE_I1N, 1.0);
      47         [ #  # ]:          0 :   setS (NODE_I2P, NODE_I2P, 1.0);
      48         [ #  # ]:          0 :   setS (NODE_I2N, NODE_I2N, 1.0);
      49                 :          0 : }
      50                 :            : 
      51                 :          0 : void iinoise::calcNoiseSP (nr_double_t frequency) {
      52 [ #  # ][ #  # ]:          0 :   setMatrixN (cytocs (calcMatrixCy (frequency) * z0, getMatrixS ()));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
      53                 :          0 : }
      54                 :            : 
      55                 :          0 : matrix iinoise::calcMatrixCy (nr_double_t frequency) {
      56                 :          0 :   nr_double_t C = getPropertyDouble ("C");
      57                 :          0 :   nr_double_t e = getPropertyDouble ("e");
      58                 :          0 :   nr_double_t c = getPropertyDouble ("c");
      59                 :          0 :   nr_double_t a = getPropertyDouble ("a");
      60                 :          0 :   nr_double_t k = a + c * qucs::pow (frequency, e);
      61                 :          0 :   nr_double_t i1 = getPropertyDouble ("i1") / k / kB / T0;
      62                 :          0 :   nr_double_t i2 = getPropertyDouble ("i2") / k / kB / T0;
      63                 :          0 :   nr_double_t ci = C * std::sqrt (i1 * i2);
      64                 :            : 
      65                 :          0 :   matrix cy = matrix (4);
      66                 :            :   // entries of source 1
      67 [ #  # ][ #  # ]:          0 :   cy.set (NODE_I1P, NODE_I1P, +i1); cy.set (NODE_I1N, NODE_I1N, +i1);
      68 [ #  # ][ #  # ]:          0 :   cy.set (NODE_I1P, NODE_I1N, -i1); cy.set (NODE_I1N, NODE_I1P, -i1);
      69                 :            :   // entries of source 2
      70 [ #  # ][ #  # ]:          0 :   cy.set (NODE_I2P, NODE_I2P, +i2); cy.set (NODE_I2N, NODE_I2N, +i2);
      71 [ #  # ][ #  # ]:          0 :   cy.set (NODE_I2P, NODE_I2N, -i2); cy.set (NODE_I2N, NODE_I2P, -i2);
      72                 :            :   // correlation entries
      73 [ #  # ][ #  # ]:          0 :   cy.set (NODE_I1P, NODE_I2P, +ci); cy.set (NODE_I1N, NODE_I2N, +ci);
      74 [ #  # ][ #  # ]:          0 :   cy.set (NODE_I1P, NODE_I2N, -ci); cy.set (NODE_I1N, NODE_I2P, -ci);
      75 [ #  # ][ #  # ]:          0 :   cy.set (NODE_I2P, NODE_I1P, +ci); cy.set (NODE_I2N, NODE_I1N, +ci);
      76 [ #  # ][ #  # ]:          0 :   cy.set (NODE_I2P, NODE_I1N, -ci); cy.set (NODE_I2N, NODE_I1P, -ci);
      77                 :          0 :   return cy;
      78                 :            : }
      79                 :            : 
      80                 :          0 : void iinoise::calcNoiseAC (nr_double_t frequency) {
      81         [ #  # ]:          0 :   setMatrixN (calcMatrixCy (frequency));
      82                 :          0 : }
      83                 :            : 
      84                 :            : // properties
      85                 :            : PROP_REQ [] = {
      86                 :            :   { "i1", PROP_REAL, { 1e-6, PROP_NO_STR }, PROP_POS_RANGE },
      87                 :            :   { "i2", PROP_REAL, { 1e-6, PROP_NO_STR }, PROP_POS_RANGE },
      88                 :            :   { "C", PROP_REAL, { 0.5, PROP_NO_STR }, PROP_RNGII (-1, 1) },
      89                 :            :   PROP_NO_PROP };
      90                 :            : PROP_OPT [] = {
      91                 :            :   { "a", PROP_REAL, { 0, PROP_NO_STR }, PROP_POS_RANGE },
      92                 :            :   { "c", PROP_REAL, { 1, PROP_NO_STR }, PROP_POS_RANGE },
      93                 :            :   { "e", PROP_REAL, { 0, PROP_NO_STR }, PROP_POS_RANGE },
      94                 :            :   PROP_NO_PROP };
      95                 :            : struct define_t iinoise::cirdef =
      96                 :            :   { "IInoise", 4, PROP_COMPONENT, PROP_NO_SUBSTRATE, PROP_LINEAR, PROP_DEF };

Generated by: LCOV version 1.11