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
isolator.cpp
Go to the documentation of this file.
1
/*
2
* isolator.cpp - isolator class implementation
3
*
4
* Copyright (C) 2003, 2004, 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: isolator.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 "
isolator.h
"
31
32
isolator::isolator () :
circuit
(2) {
33
type =
CIR_ISOLATOR
;
34
}
35
36
void
isolator::initSP
(
void
) {
37
nr_double_t z1 =
getPropertyDouble
(
"Z1"
);
38
nr_double_t z2 =
getPropertyDouble
(
"Z2"
);
39
nr_double_t s1 = (z1 -
z0
) / (z1 +
z0
);
40
nr_double_t s2 = (z2 -
z0
) / (z2 +
z0
);
41
allocMatrixS
();
42
setS
(
NODE_1
,
NODE_1
, s1);
43
setS
(
NODE_2
,
NODE_2
, s2);
44
setS
(
NODE_1
,
NODE_2
, 0);
45
setS
(
NODE_2
,
NODE_1
,
sqrt
(1 - s1 * s1) *
sqrt
(1 - s2 * s2));
46
}
47
48
void
isolator::calcNoiseSP
(nr_double_t) {
49
nr_double_t
T
=
getPropertyDouble
(
"Temp"
);
50
nr_double_t z1 =
getPropertyDouble
(
"Z1"
);
51
nr_double_t z2 =
getPropertyDouble
(
"Z2"
);
52
nr_double_t r = (
z0
- z1) / (
z0
+ z2);
53
nr_double_t f = 4 *
z0
/
sqr
(z1 +
z0
) *
kelvin
(T) /
T0
;
54
setN
(
NODE_1
,
NODE_1
, f * z1);
55
setN
(
NODE_1
,
NODE_2
, f *
sqrt
(z1 * z2) * r);
56
setN
(
NODE_2
,
NODE_1
, f *
sqrt
(z1 * z2) * r);
57
setN
(
NODE_2
,
NODE_2
, f * z2 * r * r);
58
}
59
60
void
isolator::calcNoiseAC
(nr_double_t) {
61
nr_double_t
T
=
getPropertyDouble
(
"Temp"
);
62
nr_double_t z1 =
getPropertyDouble
(
"Z1"
);
63
nr_double_t z2 =
getPropertyDouble
(
"Z2"
);
64
nr_double_t f = 4 *
kelvin
(T) /
T0
;
65
setN
(
NODE_1
,
NODE_1
, +f / z1);
66
setN
(
NODE_1
,
NODE_2
, 0);
67
setN
(
NODE_2
,
NODE_1
, -f * 2 /
sqrt
(z1 * z2));
68
setN
(
NODE_2
,
NODE_2
, +f / z2);
69
}
70
71
void
isolator::initDC
(
void
) {
72
nr_double_t z1 =
getPropertyDouble
(
"Z1"
);
73
nr_double_t z2 =
getPropertyDouble
(
"Z2"
);
74
#if AUGMENTED
75
nr_double_t z21 = 2 *
sqrt
(z1 * z2);
76
setVoltageSources
(2);
77
allocMatrixMNA
();
78
setB
(
NODE_1
,
VSRC_1
, +1.0);
setB
(
NODE_1
,
VSRC_2
, +0.0);
79
setB
(
NODE_2
,
VSRC_1
, +0.0);
setB
(
NODE_2
,
VSRC_2
, +1.0);
80
setC
(
VSRC_1
,
NODE_1
, -1.0);
setC
(
VSRC_1
,
NODE_2
, +0.0);
81
setC
(
VSRC_2
,
NODE_1
, +0.0);
setC
(
VSRC_2
,
NODE_2
, -1.0);
82
setD
(
VSRC_1
,
VSRC_1
, +z1);
setD
(
VSRC_2
,
VSRC_2
, +z2);
83
setD
(
VSRC_1
,
VSRC_2
, +0.0);
setD
(
VSRC_2
,
VSRC_1
, +z21);
84
setE
(
VSRC_1
, +0.0);
setE
(
VSRC_2
, +0.0);
85
#else
86
setVoltageSources
(0);
87
allocMatrixMNA
();
88
setY
(
NODE_1
,
NODE_1
, 1 / z1);
89
setY
(
NODE_1
,
NODE_2
, 0);
90
setY
(
NODE_2
,
NODE_1
, -2 /
sqrt
(z1 * z2));
91
setY
(
NODE_2
,
NODE_2
, 1 / z2);
92
#endif
93
}
94
95
void
isolator::initAC
(
void
) {
96
initDC
();
97
}
98
99
void
isolator::initTR
(
void
) {
100
initDC
();
101
}
102
103
// properties
104
PROP_REQ
[] = {
105
PROP_NO_PROP
};
106
PROP_OPT
[] = {
107
{
"Temp"
,
PROP_REAL
, { 26.85,
PROP_NO_STR
},
PROP_MIN_VAL
(
K
) },
108
{
"Z1"
,
PROP_REAL
, { 50,
PROP_NO_STR
},
PROP_POS_RANGE
},
109
{
"Z2"
,
PROP_REAL
, { 50,
PROP_NO_STR
},
PROP_POS_RANGE
},
110
PROP_NO_PROP
};
111
struct
define_t
isolator
::cirdef =
112
{
"Isolator"
, 2,
PROP_COMPONENT
,
PROP_NO_SUBSTRATE
,
PROP_LINEAR
,
PROP_DEF
};
Generated on Tue Dec 25 2012 14:30:39 for My Project by
1.8.2