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
vcvs.cpp
Go to the documentation of this file.
1
/*
2
* vcvs.cpp - vcvs class implementation
3
*
4
* Copyright (C) 2003, 2004, 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: vcvs.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 "
vcvs.h
"
31
32
vcvs::vcvs () :
circuit
(4) {
33
type =
CIR_VCVS
;
34
setVoltageSources (1);
35
}
36
37
void
vcvs::calcSP
(nr_double_t frequency) {
38
39
nr_double_t g =
getPropertyDouble
(
"G"
);
40
nr_double_t
t
=
getPropertyDouble
(
"T"
);
41
42
nr_complex_t
z1 =
polar
(g,
M_PI
- 2.0 *
M_PI
* frequency * t);
43
nr_complex_t
z2 =
polar
(g, - 2.0 *
M_PI
* frequency * t);
44
45
setS
(
NODE_1
,
NODE_1
, 1.0);
setS
(
NODE_1
,
NODE_2
, 0.0);
46
setS
(
NODE_1
,
NODE_3
, 0.0);
setS
(
NODE_1
,
NODE_4
, 0.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
, 0.0);
setS
(
NODE_4
,
NODE_2
, 0.0);
52
setS
(
NODE_4
,
NODE_3
, 0.0);
setS
(
NODE_4
,
NODE_4
, 1.0);
53
}
54
55
void
vcvs::initDC
(
void
) {
56
nr_double_t g =
getPropertyDouble
(
"G"
);
57
allocMatrixMNA
();
58
setC
(
VSRC_1
,
NODE_1
, +g);
setC
(
VSRC_1
,
NODE_2
, -1.0);
59
setC
(
VSRC_1
,
NODE_3
, +1.0);
setC
(
VSRC_1
,
NODE_4
, -g);
60
setB
(
NODE_1
,
VSRC_1
, +0);
setB
(
NODE_2
,
VSRC_1
, -1.0);
61
setB
(
NODE_3
,
VSRC_1
, +1.0);
setB
(
NODE_4
,
VSRC_1
, +0);
62
setD
(
VSRC_1
,
VSRC_1
, 0.0);
63
setE
(
VSRC_1
, 0.0);
64
}
65
66
void
vcvs::initAC
(
void
) {
67
initDC
();
68
}
69
70
void
vcvs::calcAC
(nr_double_t frequency) {
71
nr_double_t
t
=
getPropertyDouble
(
"T"
);
72
nr_complex_t
g =
polar
(
getPropertyDouble
(
"G"
),
73
- 2.0 *
M_PI
* frequency * t);
74
setC
(
VSRC_1
,
NODE_1
, +g);
setC
(
VSRC_1
,
NODE_4
, -g);
75
}
76
77
void
vcvs::initTR
(
void
) {
78
nr_double_t
t
=
getPropertyDouble
(
"T"
);
79
initDC
();
80
deleteHistory
();
81
if
(t > 0.0) {
82
setHistory
(
true
);
83
initHistory
(t);
84
setC
(
VSRC_1
,
NODE_1
, 0.0);
setC
(
VSRC_1
,
NODE_4
, 0.0);
85
}
86
}
87
88
void
vcvs::calcTR
(nr_double_t
t
) {
89
nr_double_t
T
=
getPropertyDouble
(
"T"
);
90
if
(T > 0.0) {
91
T = t -
T
;
92
nr_double_t g =
getPropertyDouble
(
"G"
);
93
nr_double_t v =
getV
(
NODE_4
, T) -
getV
(
NODE_1
, T);
94
setE
(
VSRC_1
, g * v);
95
}
96
}
97
98
// properties
99
PROP_REQ
[] = {
100
{
"G"
,
PROP_REAL
, { 1,
PROP_NO_STR
},
PROP_NO_RANGE
},
PROP_NO_PROP
};
101
PROP_OPT
[] = {
102
{
"T"
,
PROP_REAL
, { 0,
PROP_NO_STR
},
PROP_POS_RANGE
},
PROP_NO_PROP
};
103
struct
define_t
vcvs
::cirdef =
104
{
"VCVS"
, 4,
PROP_COMPONENT
,
PROP_NO_SUBSTRATE
,
PROP_LINEAR
,
PROP_DEF
};
Generated on Tue Dec 25 2012 14:30:42 for My Project by
1.8.2