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
phaseshifter.cpp
Go to the documentation of this file.
1
/*
2
* phaseshifter.cpp - phase shifter class implementation
3
*
4
* Copyright (C) 2004, 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: phaseshifter.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 "
phaseshifter.h
"
31
32
phaseshifter::phaseshifter () :
circuit
(2) {
33
type =
CIR_PHASESHIFTER
;
34
}
35
36
void
phaseshifter::initSP
(
void
) {
37
nr_double_t p =
rad
(
getPropertyDouble
(
"phi"
));
38
nr_double_t z =
getPropertyDouble
(
"Zref"
);
39
nr_double_t r = (
z0
- z) / (
z0
+ z);
40
nr_complex_t
d = 1.0 -
polar
(r * r, 2 * p);
41
nr_complex_t
s11 = r * (
polar
(1.0, 2 * p) - 1.0) / d;
42
nr_complex_t
s21 = (1.0 - r * r) *
polar
(1.0, p) / d;
43
allocMatrixS
();
44
setS
(
NODE_1
,
NODE_1
, s11);
45
setS
(
NODE_2
,
NODE_2
, s11);
46
setS
(
NODE_1
,
NODE_2
, s21);
47
setS
(
NODE_2
,
NODE_1
, s21);
48
}
49
50
void
phaseshifter::initDC
(
void
) {
51
setVoltageSources
(1);
52
allocMatrixMNA
();
53
clearY
();
54
voltageSource
(
VSRC_1
,
NODE_1
,
NODE_2
);
55
}
56
57
void
phaseshifter::initAC
(
void
) {
58
nr_double_t p =
rad
(
getPropertyDouble
(
"phi"
));
59
60
if
(p == 0.0) {
// no phase shift, thus a short
61
initDC
();
62
}
63
else
{
// compute Y-parameters directly
64
setVoltageSources
(0);
65
allocMatrixMNA
();
66
nr_double_t z =
getPropertyDouble
(
"Zref"
);
67
nr_double_t y11 = 1 / z /
tan
(p);
68
nr_double_t y21 = -1 / z /
sin
(p);
69
setY
(
NODE_1
,
NODE_1
,
rect
(0, y11));
setY
(
NODE_2
,
NODE_2
,
rect
(0, y11));
70
setY
(
NODE_1
,
NODE_2
,
rect
(0, y21));
setY
(
NODE_2
,
NODE_1
,
rect
(0, y21));
71
}
72
}
73
74
// properties
75
PROP_REQ
[] = {
76
{
"phi"
,
PROP_REAL
, { 1
e
-90,
PROP_NO_STR
},
PROP_NO_RANGE
},
77
PROP_NO_PROP
};
78
PROP_OPT
[] = {
79
{
"Zref"
,
PROP_REAL
, { 50,
PROP_NO_STR
},
PROP_POS_RANGE
},
80
PROP_NO_PROP
};
81
struct
define_t
phaseshifter
::cirdef =
82
{
"PShift"
, 2,
PROP_COMPONENT
,
PROP_NO_SUBSTRATE
,
PROP_LINEAR
,
PROP_DEF
};
Generated on Tue Dec 25 2012 14:30:41 for My Project by
1.8.2