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
iexp.cpp
Go to the documentation of this file.
1
/*
2
* iexp.cpp - exponential current 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: iexp.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 "
iexp.h
"
32
33
iexp::iexp () :
circuit
(2) {
34
type =
CIR_IEXP
;
35
setISource (
true
);
36
}
37
38
void
iexp::initSP
(
void
) {
39
allocMatrixS
();
40
setS
(
NODE_1
,
NODE_1
, 1.0);
41
setS
(
NODE_1
,
NODE_2
, 0.0);
42
setS
(
NODE_2
,
NODE_1
, 0.0);
43
setS
(
NODE_2
,
NODE_2
, 1.0);
44
}
45
46
void
iexp::initDC
(
void
) {
47
nr_double_t
i
=
getPropertyDouble
(
"I1"
);
48
allocMatrixMNA
();
49
setI
(
NODE_1
, +i);
setI
(
NODE_2
, -i);
50
}
51
52
void
iexp::initAC
(
void
) {
53
allocMatrixMNA
();
54
clearI
();
55
}
56
57
void
iexp::initTR
(
void
) {
58
initDC
();
59
}
60
61
void
iexp::calcTR
(nr_double_t
t
) {
62
nr_double_t i1 =
getPropertyDouble
(
"I1"
);
63
nr_double_t i2 =
getPropertyDouble
(
"I2"
);
64
nr_double_t t1 =
getPropertyDouble
(
"T1"
);
65
nr_double_t t2 =
getPropertyDouble
(
"T2"
);
66
nr_double_t tr =
getPropertyDouble
(
"Tr"
);
67
nr_double_t tf =
getPropertyDouble
(
"Tf"
);
68
nr_double_t it = 0;
69
nr_double_t
s
=
getNet
()->
getSrcFactor
();
70
71
if
(t <= t1) {
// before pulse
72
it = i1;
73
}
74
else
if
(t > t1 && t <= t2) {
// rising edge
75
it = i1 + (i2 - i1) * (1 -
exp
(-(t - t1) / tr));
76
}
77
else
{
// falling edge
78
it += i1;
79
it += (i2 - i1) * (1 -
exp
(-(t - t1) / tr));
80
it -= (i2 - i1) * (1 -
exp
(-(t - t2) / tf));
81
}
82
setI
(
NODE_1
, +it * s);
setI
(
NODE_2
, -it * s);
83
}
84
85
// properties
86
PROP_REQ
[] = {
87
{
"I1"
,
PROP_REAL
, { 0,
PROP_NO_STR
},
PROP_NO_RANGE
},
88
{
"I2"
,
PROP_REAL
, { 1,
PROP_NO_STR
},
PROP_NO_RANGE
},
89
{
"T1"
,
PROP_REAL
, { 0,
PROP_NO_STR
},
PROP_POS_RANGE
},
90
{
"T2"
,
PROP_REAL
, { 1
e
-3,
PROP_NO_STR
},
PROP_POS_RANGE
},
91
PROP_NO_PROP
};
92
PROP_OPT
[] = {
93
{
"Tr"
,
PROP_REAL
, { 1
e
-9,
PROP_NO_STR
},
PROP_POS_RANGE
},
94
{
"Tf"
,
PROP_REAL
, { 1
e
-9,
PROP_NO_STR
},
PROP_POS_RANGE
},
95
PROP_NO_PROP
};
96
struct
define_t
iexp
::cirdef =
97
{
"Iexp"
, 2,
PROP_COMPONENT
,
PROP_NO_SUBSTRATE
,
PROP_LINEAR
,
PROP_DEF
};
Generated on Tue Dec 25 2012 14:30:39 for My Project by
1.8.2