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
irect.cpp
Go to the documentation of this file.
1
/*
2
* irect.cpp - rectangular pulse current source class implementation
3
*
4
* Copyright (C) 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: irect.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 "
irect.h
"
31
32
irect::irect () :
circuit
(2) {
33
type =
CIR_IRECT
;
34
setISource (
true
);
35
}
36
37
void
irect::initSP
(
void
) {
38
allocMatrixS
();
39
setS
(
NODE_1
,
NODE_1
, 1.0);
40
setS
(
NODE_1
,
NODE_2
, 0.0);
41
setS
(
NODE_2
,
NODE_1
, 0.0);
42
setS
(
NODE_2
,
NODE_2
, 1.0);
43
}
44
45
void
irect::initDC
(
void
) {
46
nr_double_t th =
getPropertyDouble
(
"TH"
);
47
nr_double_t tl =
getPropertyDouble
(
"TL"
);
48
nr_double_t tr =
getPropertyDouble
(
"Tr"
);
49
nr_double_t tf =
getPropertyDouble
(
"Tf"
);
50
if
(tr > th) tr = th;
51
if
(tf > tl) tf = tl;
52
nr_double_t a = (th + (tf - tr) / 2) / (th + tl);
53
nr_double_t
i
=
getPropertyDouble
(
"I"
) * a;
54
allocMatrixMNA
();
55
setI
(
NODE_1
, +i);
setI
(
NODE_2
, -i);
56
}
57
58
void
irect::initAC
(
void
) {
59
allocMatrixMNA
();
60
clearI
();
61
}
62
63
void
irect::initTR
(
void
) {
64
initDC
();
65
}
66
67
void
irect::calcTR
(nr_double_t
t
) {
68
nr_double_t
i
=
getPropertyDouble
(
"I"
);
69
nr_double_t th =
getPropertyDouble
(
"TH"
);
70
nr_double_t tl =
getPropertyDouble
(
"TL"
);
71
nr_double_t tr =
getPropertyDouble
(
"Tr"
);
72
nr_double_t tf =
getPropertyDouble
(
"Tf"
);
73
nr_double_t td =
getPropertyDouble
(
"Td"
);
74
nr_double_t it = 0;
75
nr_double_t
s
=
getNet
()->
getSrcFactor
();
76
77
if
(tr > th) tr = th;
78
if
(tf > tl) tf = tl;
79
80
if
(t > td) {
// after delay
81
t = t - td;
82
t = t - (th + tl) *
floor
(t / (th + tl));
83
if
(t < tr) {
// rising edge
84
it = + i / tr *
t
;
85
}
86
else
if
(t < th) {
// high pulse
87
it =
i
;
88
}
89
else
if
(t < th + tf) {
// falling edge
90
it = - i / tf * (t - (th + tf));
91
}
92
}
93
setI
(
NODE_1
, +it * s);
setI
(
NODE_2
, -it * s);
94
}
95
96
// properties
97
PROP_REQ
[] = {
98
{
"I"
,
PROP_REAL
, { 1
e
-3,
PROP_NO_STR
},
PROP_NO_RANGE
},
99
{
"TH"
,
PROP_REAL
, { 1
e
-3,
PROP_NO_STR
},
PROP_POS_RANGE
},
100
{
"TL"
,
PROP_REAL
, { 1
e
-3,
PROP_NO_STR
},
PROP_POS_RANGE
},
101
PROP_NO_PROP
};
102
PROP_OPT
[] = {
103
{
"Tr"
,
PROP_REAL
, { 1
e
-9,
PROP_NO_STR
},
PROP_POS_RANGE
},
104
{
"Tf"
,
PROP_REAL
, { 1
e
-9,
PROP_NO_STR
},
PROP_POS_RANGE
},
105
{
"Td"
,
PROP_REAL
, { 0,
PROP_NO_STR
},
PROP_NO_RANGE
},
106
PROP_NO_PROP
};
107
struct
define_t
irect
::cirdef =
108
{
"Irect"
, 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