Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ACS
Public
Power System Simulation and Optimization
DPsim
DPsim
Commits
433613de
Commit
433613de
authored
Sep 22, 2020
by
Jan Dinkelbach
Browse files
move rotating frame transformation to MathUtils
parent
841b286d
Changes
4
Hide whitespace changes
Inline
Side-by-side
models/Include/cps/DP/DP_Ph1_AvVoltageSourceInverterDQ.h
View file @
433613de
...
...
@@ -132,8 +132,6 @@ namespace Ph1 {
void
mnaAddPostStepDependencies
(
AttributeBase
::
List
&
prevStepDependencies
,
AttributeBase
::
List
&
attributeDependencies
,
AttributeBase
::
List
&
modifiedAttributes
,
Attribute
<
Matrix
>::
Ptr
&
leftVector
);
// #### Control section ####
/// convert between two rotating frames
Complex
rotatingFrame2to1
(
Complex
f
,
Real
theta1
,
Real
theta2
);
/// Control pre step operations
void
controlPreStep
(
Real
time
,
Int
timeStepCount
);
/// Perform step of controller
...
...
models/Include/cps/MathUtils.h
View file @
433613de
...
...
@@ -183,5 +183,7 @@ namespace CPS {
static
Real
StateSpaceEuler
(
Real
states
,
Real
A
,
Real
B
,
Real
C
,
Real
dt
,
Real
u
);
static
void
FFT
(
std
::
vector
<
Complex
>&
samples
);
static
Complex
rotatingFrame2to1
(
Complex
f2
,
Real
theta1
,
Real
theta2
);
};
}
models/Source/DP/DP_Ph1_AvVoltageSourceInverterDQ.cpp
View file @
433613de
...
...
@@ -147,14 +147,6 @@ void DP::Ph1::AvVoltageSourceInverterDQ::initialize(Matrix frequencies) {
SimPowerComp
<
Complex
>::
initialize
(
frequencies
);
}
Complex
DP
::
Ph1
::
AvVoltageSourceInverterDQ
::
rotatingFrame2to1
(
Complex
f2
,
Real
theta1
,
Real
theta2
)
{
Real
delta
=
theta2
-
theta1
;
Real
f1_real
=
f2
.
real
()
*
cos
(
delta
)
-
f2
.
imag
()
*
sin
(
delta
);
Real
f1_imag
=
f2
.
real
()
*
sin
(
delta
)
+
f2
.
imag
()
*
cos
(
delta
);
return
Complex
(
f1_real
,
f1_imag
);
}
void
DP
::
Ph1
::
AvVoltageSourceInverterDQ
::
initializeFromPowerflow
(
Real
frequency
)
{
checkForUnconnectedTerminals
();
...
...
@@ -211,8 +203,8 @@ void DP::Ph1::AvVoltageSourceInverterDQ::initializeFromPowerflow(Real frequency)
// Initialize control subcomponents
// current and voltage inputs to PLL and power controller
Complex
vcdq
,
ircdq
;
vcdq
=
rotatingFrame2to1
(
mVirtualNodes
[
3
]
->
initialSingleVoltage
(),
std
::
arg
(
mVirtualNodes
[
3
]
->
initialSingleVoltage
()),
0
);
ircdq
=
rotatingFrame2to1
(
-
1.
*
mSubResistorC
->
attribute
<
MatrixComp
>
(
"i_intf"
)
->
get
()(
0
,
0
),
std
::
arg
(
mVirtualNodes
[
3
]
->
initialSingleVoltage
()),
0
);
vcdq
=
Math
::
rotatingFrame2to1
(
mVirtualNodes
[
3
]
->
initialSingleVoltage
(),
std
::
arg
(
mVirtualNodes
[
3
]
->
initialSingleVoltage
()),
0
);
ircdq
=
Math
::
rotatingFrame2to1
(
-
1.
*
mSubResistorC
->
attribute
<
MatrixComp
>
(
"i_intf"
)
->
get
()(
0
,
0
),
std
::
arg
(
mVirtualNodes
[
3
]
->
initialSingleVoltage
()),
0
);
mVcd
=
vcdq
.
real
();
mVcq
=
vcdq
.
imag
();
mIrcd
=
ircdq
.
real
();
...
...
@@ -305,8 +297,8 @@ void DP::Ph1::AvVoltageSourceInverterDQ::addControlStepDependencies(AttributeBas
void
DP
::
Ph1
::
AvVoltageSourceInverterDQ
::
controlStep
(
Real
time
,
Int
timeStepCount
)
{
// Transformation interface forward
Complex
vcdq
,
ircdq
;
vcdq
=
rotatingFrame2to1
(
mVirtualNodes
[
3
]
->
singleVoltage
(),
mPLL
->
attribute
<
Matrix
>
(
"output_prev"
)
->
get
()(
0
,
0
),
mThetaN
);
ircdq
=
rotatingFrame2to1
(
-
1.
*
mSubResistorC
->
attribute
<
MatrixComp
>
(
"i_intf"
)
->
get
()(
0
,
0
),
mPLL
->
attribute
<
Matrix
>
(
"output_prev"
)
->
get
()(
0
,
0
),
mThetaN
);
vcdq
=
Math
::
rotatingFrame2to1
(
mVirtualNodes
[
3
]
->
singleVoltage
(),
mPLL
->
attribute
<
Matrix
>
(
"output_prev"
)
->
get
()(
0
,
0
),
mThetaN
);
ircdq
=
Math
::
rotatingFrame2to1
(
-
1.
*
mSubResistorC
->
attribute
<
MatrixComp
>
(
"i_intf"
)
->
get
()(
0
,
0
),
mPLL
->
attribute
<
Matrix
>
(
"output_prev"
)
->
get
()(
0
,
0
),
mThetaN
);
mVcd
=
vcdq
.
real
();
mVcq
=
vcdq
.
imag
();
mIrcd
=
ircdq
.
real
();
...
...
@@ -317,7 +309,7 @@ void DP::Ph1::AvVoltageSourceInverterDQ::controlStep(Real time, Int timeStepCoun
mPowerControllerVSI
->
signalStep
(
time
,
timeStepCount
);
// Transformation interface backward
mVsref
(
0
,
0
)
=
rotatingFrame2to1
(
Complex
(
mPowerControllerVSI
->
attribute
<
Matrix
>
(
"output_curr"
)
->
get
()(
0
,
0
),
mPowerControllerVSI
->
attribute
<
Matrix
>
(
"output_curr"
)
->
get
()(
1
,
0
)),
mThetaN
,
mPLL
->
attribute
<
Matrix
>
(
"output_prev"
)
->
get
()(
0
,
0
));
mVsref
(
0
,
0
)
=
Math
::
rotatingFrame2to1
(
Complex
(
mPowerControllerVSI
->
attribute
<
Matrix
>
(
"output_curr"
)
->
get
()(
0
,
0
),
mPowerControllerVSI
->
attribute
<
Matrix
>
(
"output_curr"
)
->
get
()(
1
,
0
)),
mThetaN
,
mPLL
->
attribute
<
Matrix
>
(
"output_prev"
)
->
get
()(
0
,
0
));
// Update nominal system angle
mThetaN
=
mThetaN
+
mTimeStep
*
mOmegaN
;
...
...
models/Source/MathUtils.cpp
View file @
433613de
...
...
@@ -144,6 +144,11 @@ void Math::FFT(std::vector<Complex>& samples) {
samples
[
b
]
=
t
;
}
}
}
Complex
Math
::
rotatingFrame2to1
(
Complex
f2
,
Real
theta1
,
Real
theta2
)
{
Real
delta
=
theta2
-
theta1
;
Real
f1_real
=
f2
.
real
()
*
cos
(
delta
)
-
f2
.
imag
()
*
sin
(
delta
);
Real
f1_imag
=
f2
.
real
()
*
sin
(
delta
)
+
f2
.
imag
()
*
cos
(
delta
);
return
Complex
(
f1_real
,
f1_imag
);
}
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment