Qucs-core  0.0.18
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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$
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 iinoise::iinoise () : circuit (4) {
40  type = CIR_IINOISE;
41 }
42 
43 void iinoise::initSP (void) {
44  allocMatrixS ();
45  setS (NODE_I1P, NODE_I1P, 1.0);
46  setS (NODE_I1N, NODE_I1N, 1.0);
47  setS (NODE_I2P, NODE_I2P, 1.0);
48  setS (NODE_I2N, NODE_I2N, 1.0);
49 }
50 
51 void iinoise::calcNoiseSP (nr_double_t frequency) {
52  setMatrixN (cytocs (calcMatrixCy (frequency) * z0, getMatrixS ()));
53 }
54 
55 matrix iinoise::calcMatrixCy (nr_double_t frequency) {
56  nr_double_t C = getPropertyDouble ("C");
57  nr_double_t e = getPropertyDouble ("e");
58  nr_double_t c = getPropertyDouble ("c");
59  nr_double_t a = getPropertyDouble ("a");
60  nr_double_t k = a + c * qucs::pow (frequency, e);
61  nr_double_t i1 = getPropertyDouble ("i1") / k / kB / T0;
62  nr_double_t i2 = getPropertyDouble ("i2") / k / kB / T0;
63  nr_double_t ci = C * std::sqrt (i1 * i2);
64 
65  matrix cy = matrix (4);
66  // entries of source 1
67  cy.set (NODE_I1P, NODE_I1P, +i1); cy.set (NODE_I1N, NODE_I1N, +i1);
68  cy.set (NODE_I1P, NODE_I1N, -i1); cy.set (NODE_I1N, NODE_I1P, -i1);
69  // entries of source 2
70  cy.set (NODE_I2P, NODE_I2P, +i2); cy.set (NODE_I2N, NODE_I2N, +i2);
71  cy.set (NODE_I2P, NODE_I2N, -i2); cy.set (NODE_I2N, NODE_I2P, -i2);
72  // correlation entries
73  cy.set (NODE_I1P, NODE_I2P, +ci); cy.set (NODE_I1N, NODE_I2N, +ci);
74  cy.set (NODE_I1P, NODE_I2N, -ci); cy.set (NODE_I1N, NODE_I2P, -ci);
75  cy.set (NODE_I2P, NODE_I1P, +ci); cy.set (NODE_I2N, NODE_I1N, +ci);
76  cy.set (NODE_I2P, NODE_I1N, -ci); cy.set (NODE_I2N, NODE_I1P, -ci);
77  return cy;
78 }
79 
80 void iinoise::calcNoiseAC (nr_double_t frequency) {
81  setMatrixN (calcMatrixCy (frequency));
82 }
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 =
#define PROP_POS_RANGE
Definition: netdefs.h:129
#define NODE_I1P
Definition: iinoise.cpp:32
#define T0
standard temperature
Definition: constants.h:61
#define PROP_RNGII(f, t)
Definition: netdefs.h:138
#define PROP_DEF
Definition: netdefs.h:189
nr_double_t getPropertyDouble(const char *)
Definition: object.cpp:176
nr_complex_t pow(const nr_complex_t z, const nr_double_t d)
Compute power function with real exponent.
Definition: complex.cpp:238
#define C(c)
Definition: eqndefined.cpp:73
#define PROP_REAL
Definition: netdefs.h:174
#define PROP_NO_PROP
Definition: netdefs.h:122
#define PROP_NO_STR
Definition: netdefs.h:125
void allocMatrixS(void)
Definition: circuit.cpp:251
#define PROP_LINEAR
Definition: netdefs.h:120
static const nr_double_t z0
Definition: circuit.h:320
i1
Definition: parse_citi.y:148
void initSP(void)
placehoder for S-Parameter initialisation function
Definition: iinoise.cpp:43
#define NODE_I2P
Definition: iinoise.cpp:34
nr_complex_t sqrt(const nr_complex_t z)
Compute principal value of square root.
Definition: complex.cpp:271
#define NODE_I2N
Definition: iinoise.cpp:35
#define NODE_I1N
Definition: iinoise.cpp:33
void calcNoiseAC(nr_double_t)
Definition: iinoise.cpp:80
PROP_REQ[]
Definition: iinoise.cpp:85
#define PROP_COMPONENT
Definition: netdefs.h:116
#define kB
Boltzmann constant ( )
Definition: constants.h:64
PROP_OPT[]
Definition: iinoise.cpp:90
PROP_NO_SUBSTRATE
Definition: iinoise.cpp:96
void calcNoiseSP(nr_double_t)
Definition: iinoise.cpp:51
type
Definition: parse_vcd.y:164
matrix getMatrixS(void)
Definition: circuit.cpp:654
i2
Definition: parse_citi.y:160
matrix cytocs(matrix cy, matrix s)
Admittance noise correlation matrix to S-parameter noise correlation matrix.
Definition: matrix.cpp:1404
void setMatrixN(matrix)
Definition: circuit.cpp:664
void setS(int, int, nr_complex_t)
Definition: circuit.cpp:587
qucs::matrix calcMatrixCy(nr_double_t)
Definition: iinoise.cpp:55