My Project  0.0.16
QUCS Mapping
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
iinoise.cpp
Go to the documentation of this file.
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: iinoise.cpp 1825 2011-03-11 20:42:14Z ela $
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 iinoise::iinoise () : circuit (4) {
38  type = CIR_IINOISE;
39 }
40 
41 void iinoise::initSP (void) {
42  allocMatrixS ();
43  setS (NODE_I1P, NODE_I1P, 1.0);
44  setS (NODE_I1N, NODE_I1N, 1.0);
45  setS (NODE_I2P, NODE_I2P, 1.0);
46  setS (NODE_I2N, NODE_I2N, 1.0);
47 }
48 
49 void iinoise::calcNoiseSP (nr_double_t frequency) {
50  setMatrixN (cytocs (calcMatrixCy (frequency) * z0, getMatrixS ()));
51 }
52 
53 matrix iinoise::calcMatrixCy (nr_double_t frequency) {
54  nr_double_t C = getPropertyDouble ("C");
55  nr_double_t e = getPropertyDouble ("e");
56  nr_double_t c = getPropertyDouble ("c");
57  nr_double_t a = getPropertyDouble ("a");
58  nr_double_t k = a + c * pow (frequency, e);
59  nr_double_t i1 = getPropertyDouble ("i1") / k / kB / T0;
60  nr_double_t i2 = getPropertyDouble ("i2") / k / kB / T0;
61  nr_double_t ci = C * sqrt (i1 * i2);
62 
63  matrix cy = matrix (4);
64  // entries of source 1
65  cy.set (NODE_I1P, NODE_I1P, +i1); cy.set (NODE_I1N, NODE_I1N, +i1);
66  cy.set (NODE_I1P, NODE_I1N, -i1); cy.set (NODE_I1N, NODE_I1P, -i1);
67  // entries of source 2
68  cy.set (NODE_I2P, NODE_I2P, +i2); cy.set (NODE_I2N, NODE_I2N, +i2);
69  cy.set (NODE_I2P, NODE_I2N, -i2); cy.set (NODE_I2N, NODE_I2P, -i2);
70  // correlation entries
71  cy.set (NODE_I1P, NODE_I2P, +ci); cy.set (NODE_I1N, NODE_I2N, +ci);
72  cy.set (NODE_I1P, NODE_I2N, -ci); cy.set (NODE_I1N, NODE_I2P, -ci);
73  cy.set (NODE_I2P, NODE_I1P, +ci); cy.set (NODE_I2N, NODE_I1N, +ci);
74  cy.set (NODE_I2P, NODE_I1N, -ci); cy.set (NODE_I2N, NODE_I1P, -ci);
75  return cy;
76 }
77 
78 void iinoise::calcNoiseAC (nr_double_t frequency) {
79  setMatrixN (calcMatrixCy (frequency));
80 }
81 
82 // properties
83 PROP_REQ [] = {
84  { "i1", PROP_REAL, { 1e-6, PROP_NO_STR }, PROP_POS_RANGE },
85  { "i2", PROP_REAL, { 1e-6, PROP_NO_STR }, PROP_POS_RANGE },
86  { "C", PROP_REAL, { 0.5, PROP_NO_STR }, PROP_RNGII (-1, 1) },
87  PROP_NO_PROP };
88 PROP_OPT [] = {
89  { "a", PROP_REAL, { 0, PROP_NO_STR }, PROP_POS_RANGE },
90  { "c", PROP_REAL, { 1, PROP_NO_STR }, PROP_POS_RANGE },
91  { "e", PROP_REAL, { 0, PROP_NO_STR }, PROP_POS_RANGE },
92  PROP_NO_PROP };
93 struct define_t iinoise::cirdef =