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
ccvs.cpp
Go to the documentation of this file.
1
/*
2
* ccvs.cpp - ccvs class implementation
3
*
4
* Copyright (C) 2003, 2004, 2005, 2006, 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: ccvs.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 "
ccvs.h
"
31
32
ccvs::ccvs () :
circuit
(4) {
33
type =
CIR_CCVS
;
34
setVoltageSources (2);
35
}
36
37
void
ccvs::calcSP
(nr_double_t frequency) {
38
39
nr_double_t g =
getPropertyDouble
(
"G"
) /
z0
;
40
nr_double_t
t
=
getPropertyDouble
(
"T"
);
41
42
nr_complex_t
z1 =
polar
(g / 2.0,
M_PI
- 2.0 *
M_PI
* frequency * t);
43
nr_complex_t
z2 =
polar
(g / 2.0, - 2.0 *
M_PI
* frequency * t);
44
45
setS
(
NODE_1
,
NODE_1
, 0.0);
setS
(
NODE_1
,
NODE_2
, 0.0);
46
setS
(
NODE_1
,
NODE_3
, 0.0);
setS
(
NODE_1
,
NODE_4
, 1.0);
47
setS
(
NODE_2
,
NODE_1
, z2);
setS
(
NODE_2
,
NODE_2
, 0.0);
48
setS
(
NODE_2
,
NODE_3
, 1.0);
setS
(
NODE_2
,
NODE_4
, z1);
49
setS
(
NODE_3
,
NODE_1
, z1);
setS
(
NODE_3
,
NODE_2
, 1.0);
50
setS
(
NODE_3
,
NODE_3
, 0.0);
setS
(
NODE_3
,
NODE_4
, z2);
51
setS
(
NODE_4
,
NODE_1
, 1.0);
setS
(
NODE_4
,
NODE_2
, 0.0);
52
setS
(
NODE_4
,
NODE_3
, 0.0);
setS
(
NODE_4
,
NODE_4
, 0.0);
53
}
54
55
void
ccvs::initDC
(
void
) {
56
allocMatrixMNA
();
57
setB
(
NODE_1
,
VSRC_1
, +1.0);
setB
(
NODE_2
,
VSRC_1
, +0.0);
58
setB
(
NODE_3
,
VSRC_1
, +0.0);
setB
(
NODE_4
,
VSRC_1
, -1.0);
59
setB
(
NODE_1
,
VSRC_2
, +0.0);
setB
(
NODE_2
,
VSRC_2
, -1.0);
60
setB
(
NODE_3
,
VSRC_2
, +1.0);
setB
(
NODE_4
,
VSRC_2
, +0.0);
61
setC
(
VSRC_1
,
NODE_1
, +0.0);
setC
(
VSRC_1
,
NODE_2
, +1.0);
62
setC
(
VSRC_1
,
NODE_3
, -1.0);
setC
(
VSRC_1
,
NODE_4
, +0.0);
63
setC
(
VSRC_2
,
NODE_1
, +1.0);
setC
(
VSRC_2
,
NODE_2
, +0.0);
64
setC
(
VSRC_2
,
NODE_3
, +0.0);
setC
(
VSRC_2
,
NODE_4
, -1.0);
65
setD
(
VSRC_1
,
VSRC_1
, -
getPropertyDouble
(
"G"
));
66
setD
(
VSRC_2
,
VSRC_2
, 0.0);
67
setD
(
VSRC_1
,
VSRC_2
, 0.0);
setD
(
VSRC_2
,
VSRC_1
, 0.0);
68
setE
(
VSRC_1
, 0.0);
69
setE
(
VSRC_2
, 0.0);
70
}
71
72
void
ccvs::initAC
(
void
) {
73
initDC
();
74
}
75
76
void
ccvs::calcAC
(nr_double_t frequency) {
77
nr_double_t
t
=
getPropertyDouble
(
"T"
);
78
nr_complex_t
g =
polar
(
getPropertyDouble
(
"G"
),
79
- 2.0 *
M_PI
* frequency * t);
80
setD
(
VSRC_1
,
VSRC_1
, -g);
81
}
82
83
void
ccvs::initTR
(
void
) {
84
nr_double_t
t
=
getPropertyDouble
(
"T"
);
85
initDC
();
86
deleteHistory
();
87
if
(t > 0.0) {
88
setHistory
(
true
);
89
initHistory
(t);
90
setC
(
VSRC_2
,
NODE_1
, +0.0);
setC
(
VSRC_2
,
NODE_2
, +1.0);
91
setC
(
VSRC_2
,
NODE_3
, -1.0);
setC
(
VSRC_2
,
NODE_4
, +0.0);
92
setC
(
VSRC_1
,
NODE_1
, +1.0);
setC
(
VSRC_1
,
NODE_2
, +0.0);
93
setC
(
VSRC_1
,
NODE_3
, +0.0);
setC
(
VSRC_1
,
NODE_4
, -1.0);
94
setD
(
VSRC_1
,
VSRC_1
, 0.0);
95
}
96
}
97
98
void
ccvs::calcTR
(nr_double_t
t
) {
99
nr_double_t
T
=
getPropertyDouble
(
"T"
);
100
if
(T > 0.0) {
101
T = t -
T
;
102
nr_double_t g =
getPropertyDouble
(
"G"
);
103
nr_double_t
i
=
getJ
(
VSRC_1
, T);
104
setE
(
VSRC_2
, g * i);
105
}
106
}
107
108
// properties
109
PROP_REQ
[] = {
110
{
"G"
,
PROP_REAL
, { 1,
PROP_NO_STR
},
PROP_NO_RANGE
},
PROP_NO_PROP
};
111
PROP_OPT
[] = {
112
{
"T"
,
PROP_REAL
, { 0,
PROP_NO_STR
},
PROP_POS_RANGE
},
PROP_NO_PROP
};
113
struct
define_t
ccvs
::cirdef =
114
{
"CCVS"
, 4,
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