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
amplifier.cpp
Go to the documentation of this file.
1
/*
2
* amplifier.cpp - amplifier class implementation
3
*
4
* Copyright (C) 2004, 2008, 2010 Stefan Jahn <stefan@lkcc.org>
5
* Copyright (C) 2008 Michael Margraf <Michael.Margraf@alumni.TU-Berlin.DE>
6
*
7
* This is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation; either version 2, or (at your option)
10
* any later version.
11
*
12
* This software is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
16
*
17
* You should have received a copy of the GNU General Public License
18
* along with this package; see the file COPYING. If not, write to
19
* the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
20
* Boston, MA 02110-1301, USA.
21
*
22
* $Id: amplifier.cpp 1825 2011-03-11 20:42:14Z ela $
23
*
24
*/
25
33
#if HAVE_CONFIG_H
34
# include <config.h>
35
#endif
36
37
#include "
component.h
"
38
#include "
amplifier.h
"
39
41
amplifier::amplifier () :
circuit
(2) {
42
type =
CIR_AMPLIFIER
;
43
}
44
58
void
amplifier::initSP
(
void
) {
59
nr_double_t g =
getPropertyDouble
(
"G"
);
60
nr_double_t z1 =
getPropertyDouble
(
"Z1"
);
61
nr_double_t z2 =
getPropertyDouble
(
"Z2"
);
62
63
allocMatrixS
();
64
65
setS
(
NODE_1
,
NODE_1
, (z1 -
z0
) / (z1 +
z0
));
66
setS
(
NODE_1
,
NODE_2
, 0);
67
setS
(
NODE_2
,
NODE_2
, (z2 -
z0
) / (z2 +
z0
));
68
setS
(
NODE_2
,
NODE_1
, 4 *
z0
*
sqrt
(z1 * z2) * g / (z1 +
z0
) / (z2 +
z0
));
69
}
70
71
void
amplifier::calcNoiseSP
(nr_double_t) {
72
nr_double_t g =
getPropertyDouble
(
"G"
);
73
nr_double_t z2 =
getPropertyDouble
(
"Z2"
);
74
nr_double_t NF =
getPropertyDouble
(
"NF"
);
75
setN
(
NODE_1
,
NODE_1
, 0);
76
setN
(
NODE_2
,
NODE_2
, 4 *
z0
* z2 *
sqr
(g) * (NF - 1) /
sqr
(z2 +
z0
));
77
setN
(
NODE_1
,
NODE_2
, 0);
78
setN
(
NODE_2
,
NODE_1
, 0);
79
}
80
93
void
amplifier::initDC
(
void
) {
94
nr_double_t g =
getPropertyDouble
(
"G"
);
95
nr_double_t z1 =
getPropertyDouble
(
"Z1"
);
96
nr_double_t z2 =
getPropertyDouble
(
"Z2"
);
97
98
allocMatrixMNA
();
99
100
setY
(
NODE_1
,
NODE_1
, 1 / z1);
101
setY
(
NODE_1
,
NODE_2
, 0);
102
setY
(
NODE_2
,
NODE_1
, -2 * g /
sqrt
(z1 * z2));
103
setY
(
NODE_2
,
NODE_2
, 1 / z2);
104
}
105
110
void
amplifier::initAC
(
void
) {
111
initDC
();
112
}
113
114
void
amplifier::calcNoiseAC
(nr_double_t) {
115
nr_double_t g =
getPropertyDouble
(
"G"
);
116
nr_double_t z2 =
getPropertyDouble
(
"Z2"
);
117
nr_double_t NF =
getPropertyDouble
(
"NF"
);
118
setN
(
NODE_1
,
NODE_1
, 0);
119
setN
(
NODE_2
,
NODE_2
, 4 *
sqr
(g) * (NF - 1) / z2);
120
setN
(
NODE_1
,
NODE_2
, 0);
121
setN
(
NODE_2
,
NODE_1
, 0);
122
}
123
128
void
amplifier::initTR
(
void
) {
129
initDC
();
130
}
131
132
// properties
133
PROP_REQ
[] = {
134
{
"G"
,
PROP_REAL
, { 10,
PROP_NO_STR
},
PROP_MIN_VAL
(1) },
135
PROP_NO_PROP
};
136
PROP_OPT
[] = {
137
{
"Z1"
,
PROP_REAL
, { 50,
PROP_NO_STR
},
PROP_POS_RANGE
},
138
{
"Z2"
,
PROP_REAL
, { 50,
PROP_NO_STR
},
PROP_POS_RANGE
},
139
{
"NF"
,
PROP_REAL
, { 1,
PROP_NO_STR
},
PROP_MIN_VAL
(1) },
140
PROP_NO_PROP
};
141
struct
define_t
amplifier
::cirdef =
142
{
"Amp"
, 2,
PROP_COMPONENT
,
PROP_NO_SUBSTRATE
,
PROP_LINEAR
,
PROP_DEF
};
Generated on Tue Dec 25 2012 14:30:37 for My Project by
1.8.2