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
trafo.cpp
Go to the documentation of this file.
1
/*
2
* trafo.cpp - 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: trafo.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 "
trafo.h
"
31
32
trafo::trafo () :
circuit
(4) {
33
type
=
CIR_TRAFO
;
34
}
35
36
void
trafo::initSP
(
void
) {
37
nr_double_t
t
=
getPropertyDouble
(
"T"
);
38
nr_double_t d = t * t + 1.0;
39
nr_double_t z1 = t * t / d;
40
nr_double_t z2 = t / d;
41
nr_double_t z3 = 1 / d;
42
allocMatrixS
();
43
setS
(
NODE_1
,
NODE_1
, z1);
setS
(
NODE_1
,
NODE_2
, z2);
44
setS
(
NODE_1
,
NODE_3
, -z2);
setS
(
NODE_1
,
NODE_4
, z3);
45
setS
(
NODE_2
,
NODE_1
, z2);
setS
(
NODE_2
,
NODE_2
, z3);
46
setS
(
NODE_2
,
NODE_3
, z1);
setS
(
NODE_2
,
NODE_4
, -z2);
47
setS
(
NODE_3
,
NODE_1
, -z2);
setS
(
NODE_3
,
NODE_2
, z1);
48
setS
(
NODE_3
,
NODE_3
, z3);
setS
(
NODE_3
,
NODE_4
, z2);
49
setS
(
NODE_4
,
NODE_1
, z3);
setS
(
NODE_4
,
NODE_2
, -z2);
50
setS
(
NODE_4
,
NODE_3
, z2);
setS
(
NODE_4
,
NODE_4
, z1);
51
}
52
53
void
trafo::initDC
(
void
) {
54
setVoltageSources
(2);
55
allocMatrixMNA
();
56
voltageSource
(
VSRC_1
,
NODE_1
,
NODE_4
);
57
voltageSource
(
VSRC_2
,
NODE_2
,
NODE_3
);
58
}
59
60
void
trafo::initAC
(
void
) {
61
nr_double_t
t
=
getPropertyDouble
(
"T"
);
62
setVoltageSources
(1);
63
allocMatrixMNA
();
64
setB
(
NODE_1
,
VSRC_1
, -1);
setB
(
NODE_2
,
VSRC_1
, +t);
65
setB
(
NODE_3
,
VSRC_1
, -t);
setB
(
NODE_4
,
VSRC_1
, +1);
66
setC
(
VSRC_1
,
NODE_1
, +1);
setC
(
VSRC_1
,
NODE_2
, -t);
67
setC
(
VSRC_1
,
NODE_3
, +t);
setC
(
VSRC_1
,
NODE_4
, -1);
68
setD
(
VSRC_1
,
VSRC_1
, +0);
69
setE
(
VSRC_1
, 0);
70
}
71
72
void
trafo::initTR
(
void
) {
73
initDC
();
74
}
75
76
// properties
77
PROP_REQ
[] = {
78
{
"T"
,
PROP_REAL
, { 1,
PROP_NO_STR
},
PROP_POS_RANGE
},
PROP_NO_PROP
};
79
PROP_OPT
[] = {
80
PROP_NO_PROP
};
81
struct
define_t
trafo
::cirdef =
82
{
"Tr"
, 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