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
strafo.cpp
Go to the documentation of this file.
1
/*
2
* strafo.cpp - symmetrical trafo class implementation
3
*
4
* Copyright (C) 2003, 2004, 2005, 2008, 2011 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: strafo.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 "
strafo.h
"
31
32
strafo::strafo () :
circuit
(6) {
33
type =
CIR_STRAFO
;
34
}
35
36
void
strafo::initSP
(
void
) {
37
38
nr_double_t t1 =
getPropertyDouble
(
"T1"
);
39
nr_double_t t2 =
getPropertyDouble
(
"T2"
);
40
41
nr_double_t d = t1 * t1 + t2 * t2 + 1.0;
42
nr_double_t z1 = t1 * t1 / d;
43
nr_double_t z2 = t2 * t2 / d;
44
nr_double_t z3 = 1.0 / d;
45
nr_double_t z4 = t1 / d;
46
nr_double_t z5 = t2 / d;
47
nr_double_t z6 = t1 * t2 / d;
48
49
allocMatrixS
();
50
51
setS
(
NODE_1
,
NODE_1
, z1);
setS
(
NODE_1
,
NODE_2
, z4);
52
setS
(
NODE_1
,
NODE_3
, -z4);
setS
(
NODE_1
,
NODE_4
, -z6);
53
setS
(
NODE_1
,
NODE_5
, z6);
setS
(
NODE_1
,
NODE_6
, 1 - z1);
54
setS
(
NODE_2
,
NODE_1
, z4);
setS
(
NODE_2
,
NODE_2
, z3);
55
setS
(
NODE_2
,
NODE_3
, 1 - z3);
setS
(
NODE_2
,
NODE_4
, -z5);
56
setS
(
NODE_2
,
NODE_5
, z5);
setS
(
NODE_2
,
NODE_6
, -z4);
57
setS
(
NODE_3
,
NODE_1
, -z4);
setS
(
NODE_3
,
NODE_2
, 1 - z3);
58
setS
(
NODE_3
,
NODE_3
, z3);
setS
(
NODE_3
,
NODE_4
, z5);
59
setS
(
NODE_3
,
NODE_5
, -z5);
setS
(
NODE_3
,
NODE_6
, z4);
60
setS
(
NODE_4
,
NODE_1
, -z6);
setS
(
NODE_4
,
NODE_2
, -z5);
61
setS
(
NODE_4
,
NODE_3
, z5);
setS
(
NODE_4
,
NODE_4
, z2);
62
setS
(
NODE_4
,
NODE_5
, 1 - z2);
setS
(
NODE_4
,
NODE_6
, z6);
63
setS
(
NODE_5
,
NODE_1
, z6);
setS
(
NODE_5
,
NODE_2
, z5);
64
setS
(
NODE_5
,
NODE_3
, -z5);
setS
(
NODE_5
,
NODE_4
, 1 - z2);
65
setS
(
NODE_5
,
NODE_5
, z2);
setS
(
NODE_5
,
NODE_6
, -z6);
66
setS
(
NODE_6
,
NODE_1
, 1 - z1);
setS
(
NODE_6
,
NODE_2
, -z4);
67
setS
(
NODE_6
,
NODE_3
, z4);
setS
(
NODE_6
,
NODE_4
, z6);
68
setS
(
NODE_6
,
NODE_5
, -z6);
setS
(
NODE_6
,
NODE_6
, z1);
69
}
70
71
void
strafo::initDC
(
void
) {
72
setVoltageSources
(3);
73
allocMatrixMNA
();
74
voltageSource
(
VSRC_1
,
NODE_1
,
NODE_6
);
75
voltageSource
(
VSRC_2
,
NODE_5
,
NODE_4
);
76
voltageSource
(
VSRC_3
,
NODE_2
,
NODE_3
);
77
}
78
79
void
strafo::initAC
(
void
) {
80
nr_double_t t1 =
getPropertyDouble
(
"T1"
);
81
nr_double_t t2 =
getPropertyDouble
(
"T2"
);
82
83
setVoltageSources
(2);
84
allocMatrixMNA
();
85
86
setB
(
NODE_1
,
VSRC_1
, -1.0);
setB
(
NODE_2
,
VSRC_1
, + t1);
87
setB
(
NODE_3
,
VSRC_1
, - t1);
setB
(
NODE_4
,
VSRC_1
, +0.0);
88
setB
(
NODE_5
,
VSRC_1
, +0.0);
setB
(
NODE_6
,
VSRC_1
, +1.0);
89
setB
(
NODE_1
,
VSRC_2
, +0.0);
setB
(
NODE_2
,
VSRC_2
, + t2);
90
setB
(
NODE_3
,
VSRC_2
, - t2);
setB
(
NODE_4
,
VSRC_2
, +1.0);
91
setB
(
NODE_5
,
VSRC_2
, -1.0);
setB
(
NODE_6
,
VSRC_2
, +0.0);
92
93
setC
(
VSRC_1
,
NODE_1
, +1.0);
setC
(
VSRC_1
,
NODE_2
, - t1);
94
setC
(
VSRC_1
,
NODE_3
, + t1);
setC
(
VSRC_1
,
NODE_4
, +0.0);
95
setC
(
VSRC_1
,
NODE_5
, +0.0);
setC
(
VSRC_1
,
NODE_6
, -1.0);
96
setC
(
VSRC_2
,
NODE_1
, +0.0);
setC
(
VSRC_2
,
NODE_2
, - t2);
97
setC
(
VSRC_2
,
NODE_3
, + t2);
setC
(
VSRC_2
,
NODE_4
, -1.0);
98
setC
(
VSRC_2
,
NODE_5
, +1.0);
setC
(
VSRC_2
,
NODE_6
, +0.0);
99
100
setD
(
VSRC_1
,
VSRC_1
, 0);
setD
(
VSRC_2
,
VSRC_2
, 0);
101
setD
(
VSRC_1
,
VSRC_2
, 0);
setD
(
VSRC_2
,
VSRC_1
, 0);
102
setE
(
VSRC_1
, 0.0);
103
setE
(
VSRC_2
, 0.0);
104
}
105
106
void
strafo::initTR
(
void
) {
107
initDC
();
108
}
109
110
// properties
111
PROP_REQ
[] = {
112
{
"T1"
,
PROP_REAL
, { 1,
PROP_NO_STR
},
PROP_POS_RANGE
},
113
{
"T2"
,
PROP_REAL
, { 1,
PROP_NO_STR
},
PROP_POS_RANGE
},
114
PROP_NO_PROP
};
115
PROP_OPT
[] = {
116
PROP_NO_PROP
};
117
struct
define_t
strafo
::cirdef =
118
{
"sTr"
, 6,
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