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
vexp.cpp
Go to the documentation of this file.
1
/*
2
* vexp.cpp - exponential voltage source class implementation
3
*
4
* Copyright (C) 2007, 2008 Stefan Jahn <stefan@lkcc.org>
5
* Copyright (C) 2007 Gunther Kraut <gn.kraut@t-online.de>
6
*
7
* This is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation; either version 2, or (at your option)
10
* any later version.
11
*
12
* This software is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
16
*
17
* You should have received a copy of the GNU General Public License
18
* along with this package; see the file COPYING. If not, write to
19
* the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
20
* Boston, MA 02110-1301, USA.
21
*
22
* $Id: vexp.cpp 1825 2011-03-11 20:42:14Z ela $
23
*
24
*/
25
26
#if HAVE_CONFIG_H
27
# include <config.h>
28
#endif
29
30
#include "
component.h
"
31
#include "
vexp.h
"
32
33
vexp::vexp () :
circuit
(2) {
34
type =
CIR_VEXP
;
35
setVSource (
true
);
36
setVoltageSources (1);
37
}
38
39
void
vexp::initSP
(
void
) {
40
allocMatrixS
();
41
setS
(
NODE_1
,
NODE_1
, 0.0);
42
setS
(
NODE_1
,
NODE_2
, 1.0);
43
setS
(
NODE_2
,
NODE_1
, 1.0);
44
setS
(
NODE_2
,
NODE_2
, 0.0);
45
}
46
47
void
vexp::initDC
(
void
) {
48
allocMatrixMNA
();
49
voltageSource
(
VSRC_1
,
NODE_1
,
NODE_2
);
50
setE
(
VSRC_1
,
getPropertyDouble
(
"U1"
));
51
}
52
53
void
vexp::initAC
(
void
) {
54
initDC
();
55
setE
(
VSRC_1
, 0);
56
}
57
58
void
vexp::initTR
(
void
) {
59
initDC
();
60
}
61
62
void
vexp::calcTR
(nr_double_t
t
) {
63
nr_double_t u1 =
getPropertyDouble
(
"U1"
);
64
nr_double_t u2 =
getPropertyDouble
(
"U2"
);
65
nr_double_t t1 =
getPropertyDouble
(
"T1"
);
66
nr_double_t t2 =
getPropertyDouble
(
"T2"
);
67
nr_double_t tr =
getPropertyDouble
(
"Tr"
);
68
nr_double_t tf =
getPropertyDouble
(
"Tf"
);
69
nr_double_t ut = 0;
70
nr_double_t
s
=
getNet
()->
getSrcFactor
();
71
72
if
(t <= t1) {
// before pulse
73
ut = u1;
74
}
75
else
if
(t > t1 && t <= t2) {
// rising edge
76
ut = u1 + (u2 - u1) * (1 -
exp
(-(t - t1) / tr));
77
}
78
else
{
// falling edge
79
ut += u1;
80
ut += (u2 - u1) * (1 -
exp
(-(t - t1) / tr));
81
ut -= (u2 - u1) * (1 -
exp
(-(t - t2) / tf));
82
}
83
setE
(
VSRC_1
, ut * s);
84
}
85
86
// properties
87
PROP_REQ
[] = {
88
{
"U1"
,
PROP_REAL
, { 0,
PROP_NO_STR
},
PROP_NO_RANGE
},
89
{
"U2"
,
PROP_REAL
, { 1,
PROP_NO_STR
},
PROP_NO_RANGE
},
90
{
"T1"
,
PROP_REAL
, { 0,
PROP_NO_STR
},
PROP_POS_RANGE
},
91
{
"T2"
,
PROP_REAL
, { 1
e
-3,
PROP_NO_STR
},
PROP_POS_RANGE
},
92
PROP_NO_PROP
};
93
PROP_OPT
[] = {
94
{
"Tr"
,
PROP_REAL
, { 1
e
-9,
PROP_NO_STR
},
PROP_POS_RANGE
},
95
{
"Tf"
,
PROP_REAL
, { 1
e
-9,
PROP_NO_STR
},
PROP_POS_RANGE
},
96
PROP_NO_PROP
};
97
struct
define_t
vexp
::cirdef =
98
{
"Vexp"
, 2,
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