My Project
0.0.16
QUCS Mapping
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
DownLoad
QUCS-src
qucs-0.0.16
qucs-core
src
components
ivnoise.cpp
Go to the documentation of this file.
1
/*
2
* ivnoise.cpp - correlated noise 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: ivnoise.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 "
ivnoise.h
"
31
32
#define NODE_I1P 0
33
#define NODE_I1N 3
34
#define NODE_V2P 1
35
#define NODE_V2N 2
36
37
ivnoise::ivnoise () :
circuit
(4) {
38
type =
CIR_IVNOISE
;
39
setVoltageSources (1);
40
}
41
42
void
ivnoise::initSP
(
void
) {
43
allocMatrixS
();
44
setS
(
NODE_I1P
,
NODE_I1P
, 1.0);
45
setS
(
NODE_I1N
,
NODE_I1N
, 1.0);
46
setS
(
NODE_V2P
,
NODE_V2N
, 1.0);
47
setS
(
NODE_V2N
,
NODE_V2P
, 1.0);
48
}
49
50
void
ivnoise::calcNoiseSP
(nr_double_t frequency) {
51
nr_double_t
C
=
getPropertyDouble
(
"C"
);
52
nr_double_t
e
=
getPropertyDouble
(
"e"
);
53
nr_double_t
c
=
getPropertyDouble
(
"c"
);
54
nr_double_t a =
getPropertyDouble
(
"a"
);
55
nr_double_t k = a + c *
pow
(frequency, e);
56
nr_double_t i1 =
getPropertyDouble
(
"i1"
) / k /
kB
/
T0
;
57
nr_double_t u2 =
getPropertyDouble
(
"v2"
) / k /
kB
/
T0
;
58
nr_double_t
ci
= C *
sqrt
(i1 * u2) / 2;
59
60
// entries of source 1
61
setN
(
NODE_I1P
,
NODE_I1P
, +i1 *
z0
);
setN
(
NODE_I1N
,
NODE_I1N
, +i1 * z0);
62
setN
(
NODE_I1P
,
NODE_I1N
, -i1 * z0);
setN
(
NODE_I1N
,
NODE_I1P
, -i1 * z0);
63
// entries of source 2
64
setN
(
NODE_V2P
,
NODE_V2P
, +u2 /4/z0);
setN
(
NODE_V2N
,
NODE_V2N
, +u2 /4/z0);
65
setN
(
NODE_V2P
,
NODE_V2N
, -u2 /4/z0);
setN
(
NODE_V2N
,
NODE_V2P
, -u2 /4/z0);
66
// correlation entries
67
setN
(
NODE_I1P
,
NODE_V2P
, +ci);
setN
(
NODE_I1N
,
NODE_V2N
, +ci);
68
setN
(
NODE_I1P
,
NODE_V2N
, -ci);
setN
(
NODE_I1N
,
NODE_V2P
, -ci);
69
setN
(
NODE_V2P
,
NODE_I1P
, +ci);
setN
(
NODE_V2N
,
NODE_I1N
, +ci);
70
setN
(
NODE_V2P
,
NODE_I1N
, -ci);
setN
(
NODE_V2N
,
NODE_I1P
, -ci);
71
}
72
73
void
ivnoise::initDC
(
void
) {
74
allocMatrixMNA
();
75
voltageSource
(
VSRC_1
,
NODE_V2P
,
NODE_V2N
);
76
}
77
78
void
ivnoise::initAC
(
void
) {
79
initDC
();
80
}
81
82
void
ivnoise::initTR
(
void
) {
83
initDC
();
84
}
85
86
void
ivnoise::calcNoiseAC
(nr_double_t frequency) {
87
nr_double_t
C
=
getPropertyDouble
(
"C"
);
88
nr_double_t
e
=
getPropertyDouble
(
"e"
);
89
nr_double_t
c
=
getPropertyDouble
(
"c"
);
90
nr_double_t a =
getPropertyDouble
(
"a"
);
91
nr_double_t k = a + c *
pow
(frequency, e);
92
nr_double_t i1 =
getPropertyDouble
(
"i1"
) / k /
kB
/
T0
;
93
nr_double_t u2 =
getPropertyDouble
(
"v2"
) / k /
kB
/
T0
;
94
nr_double_t
ci
= C *
sqrt
(i1 * u2);
95
setN
(
NODE_I1P
,
NODE_I1P
, +i1);
setN
(
NODE_I1N
,
NODE_I1N
, +i1);
96
setN
(
NODE_I1P
,
NODE_I1N
, -i1);
setN
(
NODE_I1N
,
NODE_I1P
, -i1);
97
setN
(
NODE_5
,
NODE_I1P
, ci);
98
setN
(
NODE_I1P
,
NODE_5
, ci);
99
setN
(
NODE_5
,
NODE_5
, u2);
100
}
101
102
// properties
103
PROP_REQ
[] = {
104
{
"i1"
,
PROP_REAL
, { 1
e
-6,
PROP_NO_STR
},
PROP_POS_RANGE
},
105
{
"v2"
,
PROP_REAL
, { 1
e
-6,
PROP_NO_STR
},
PROP_POS_RANGE
},
106
{
"C"
,
PROP_REAL
, { 0.5,
PROP_NO_STR
},
PROP_RNGII
(-1, 1) },
107
PROP_NO_PROP
};
108
PROP_OPT
[] = {
109
{
"a"
,
PROP_REAL
, { 0,
PROP_NO_STR
},
PROP_POS_RANGE
},
110
{
"c"
,
PROP_REAL
, { 1,
PROP_NO_STR
},
PROP_POS_RANGE
},
111
{
"e"
,
PROP_REAL
, { 0,
PROP_NO_STR
},
PROP_POS_RANGE
},
112
PROP_NO_PROP
};
113
struct
define_t
ivnoise
::cirdef =
114
{
"IVnoise"
, 4,
PROP_COMPONENT
,
PROP_NO_SUBSTRATE
,
PROP_LINEAR
,
PROP_DEF
};
Generated on Tue Dec 25 2012 14:28:06 for My Project by
1.8.2