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
68926ca6
Commit
68926ca6
authored
Oct 27, 2020
by
Jan Dinkelbach
Committed by
Markus Mirz
Nov 21, 2020
Browse files
fix emt3ph voltage source
parent
daff7237
Changes
2
Hide whitespace changes
Inline
Side-by-side
models/Include/cps/EMT/EMT_Ph3_VoltageSource.h
View file @
68926ca6
...
...
@@ -46,7 +46,7 @@ namespace CPS {
SimPowerComp
<
Real
>::
Ptr
clone
(
String
name
);
// #### General ####
/// Initializes component from power flow data
void
initializeFromNodesAndTerminals
(
Real
frequency
)
{
}
void
initializeFromNodesAndTerminals
(
Real
frequency
)
;
// #### MNA section ####
/// Initializes internal variables of the component
...
...
models/Source/EMT/EMT_Ph3_VoltageSource.cpp
View file @
68926ca6
...
...
@@ -34,6 +34,22 @@ void EMT::Ph3::VoltageSource::setParameters(Complex voltageRef, Real srcFreq) {
mParametersSet
=
true
;
}
void
EMT
::
Ph3
::
VoltageSource
::
initializeFromPowerflow
(
Real
frequency
)
{
mVoltageRef
=
attribute
<
Complex
>
(
"V_ref"
);
mSrcFreq
=
attribute
<
Real
>
(
"f_src"
);
if
(
!
mParametersSet
)
{
mVoltageRef
->
set
(
initialSingleVoltage
(
1
)
-
initialSingleVoltage
(
0
));
mSrcFreq
->
set
(
frequency
);
}
mSLog
->
info
(
"
\n
Voltage reference phasor [V]: {:s}"
"
\n
Frequency [Hz]: {:s}"
,
Logger
::
phasorToString
(
mVoltageRef
->
get
()),
Logger
::
realToString
(
mSrcFreq
->
get
()));
mSLog
->
flush
();
}
SimPowerComp
<
Real
>::
Ptr
EMT
::
Ph3
::
VoltageSource
::
clone
(
String
name
)
{
auto
copy
=
VoltageSource
::
make
(
name
,
mLogLevel
);
copy
->
setParameters
(
attribute
<
Complex
>
(
"V_ref"
)
->
get
(),
attribute
<
Real
>
(
"f_src"
)
->
get
());
...
...
@@ -45,14 +61,26 @@ void EMT::Ph3::VoltageSource::mnaInitialize(Real omega, Real timeStep, Attribute
MNAInterface
::
mnaInitialize
(
omega
,
timeStep
);
updateMatrixNodeIndices
();
mVoltageRef
=
attribute
<
Complex
>
(
"V_ref"
);
mSrcFreq
=
attribute
<
Real
>
(
"f_src"
);
mIntfVoltage
(
0
,
0
)
=
Math
::
abs
(
mVoltageRef
->
get
())
*
cos
(
Math
::
phase
(
mVoltageRef
->
get
()));
mIntfVoltage
(
1
,
0
)
=
Math
::
abs
(
mVoltageRef
->
get
())
*
cos
(
Math
::
phase
(
mVoltageRef
->
get
())
-
2.
/
3.
*
M_PI
);
mIntfVoltage
(
2
,
0
)
=
Math
::
abs
(
mVoltageRef
->
get
())
*
cos
(
Math
::
phase
(
mVoltageRef
->
get
())
+
2.
/
3.
*
M_PI
);
mIntfVoltage
(
0
,
0
)
=
RMS3PH_TO_PEAK1PH
*
Math
::
abs
(
mVoltageRef
->
get
())
*
cos
(
Math
::
phase
(
mVoltageRef
->
get
()));
mIntfVoltage
(
1
,
0
)
=
RMS3PH_TO_PEAK1PH
*
Math
::
abs
(
mVoltageRef
->
get
())
*
cos
(
Math
::
phase
(
mVoltageRef
->
get
())
-
2.
/
3.
*
M_PI
);
mIntfVoltage
(
2
,
0
)
=
RMS3PH_TO_PEAK1PH
*
Math
::
abs
(
mVoltageRef
->
get
())
*
cos
(
Math
::
phase
(
mVoltageRef
->
get
())
+
2.
/
3.
*
M_PI
);
mMnaTasks
.
push_back
(
std
::
make_shared
<
MnaPreStep
>
(
*
this
));
mMnaTasks
.
push_back
(
std
::
make_shared
<
MnaPostStep
>
(
*
this
,
leftVector
));
mRightVector
=
Matrix
::
Zero
(
leftVector
->
get
().
rows
(),
1
);
mSLog
->
info
(
"
\n
--- MNA initialization ---"
"
\n
Initial voltage {:s}"
"
\n
Initial current {:s}"
"
\n
--- MNA initialization finished ---"
,
Logger
::
matrixToString
(
mIntfVoltage
),
Logger
::
matrixToString
(
mIntfCurrent
));
mSLog
->
flush
();
}
void
EMT
::
Ph3
::
VoltageSource
::
mnaApplySystemMatrixStamp
(
Matrix
&
systemMatrix
)
{
...
...
@@ -95,18 +123,25 @@ void EMT::Ph3::VoltageSource::mnaApplyRightSideVectorStamp(Matrix& rightVector)
}
void
EMT
::
Ph3
::
VoltageSource
::
updateVoltage
(
Real
time
)
{
Complex
voltageRef
=
mVoltageRef
->
get
();
Real
srcFreq
=
mSrcFreq
->
get
();
if
(
srcFreq
>
0
)
{
mIntfVoltage
(
0
,
0
)
=
Math
::
abs
(
voltageRef
)
*
cos
(
time
*
2.
*
PI
*
srcFreq
+
Math
::
phase
(
voltageRef
));
mIntfVoltage
(
1
,
0
)
=
Math
::
abs
(
voltageRef
)
*
cos
(
time
*
2.
*
PI
*
srcFreq
+
Math
::
phase
(
voltageRef
)
-
2.
/
3.
*
M_PI
);
mIntfVoltage
(
2
,
0
)
=
Math
::
abs
(
voltageRef
)
*
cos
(
time
*
2.
*
PI
*
srcFreq
+
Math
::
phase
(
voltageRef
)
+
2.
/
3.
*
M_PI
);
mIntfVoltage
(
0
,
0
)
=
RMS3PH_TO_PEAK1PH
*
Math
::
abs
(
voltageRef
)
*
cos
(
time
*
2.
*
PI
*
srcFreq
+
Math
::
phase
(
voltageRef
));
mIntfVoltage
(
1
,
0
)
=
RMS3PH_TO_PEAK1PH
*
Math
::
abs
(
voltageRef
)
*
cos
(
time
*
2.
*
PI
*
srcFreq
+
Math
::
phase
(
voltageRef
)
-
2.
/
3.
*
M_PI
);
mIntfVoltage
(
2
,
0
)
=
RMS3PH_TO_PEAK1PH
*
Math
::
abs
(
voltageRef
)
*
cos
(
time
*
2.
*
PI
*
srcFreq
+
Math
::
phase
(
voltageRef
)
+
2.
/
3.
*
M_PI
);
}
else
{
mIntfVoltage
(
0
,
0
)
=
voltageRef
.
real
();
mIntfVoltage
(
1
,
0
)
=
voltageRef
.
real
();
mIntfVoltage
(
2
,
0
)
=
voltageRef
.
real
();
mIntfVoltage
(
0
,
0
)
=
RMS3PH_TO_PEAK1PH
*
voltageRef
.
real
();
mIntfVoltage
(
1
,
0
)
=
RMS3PH_TO_PEAK1PH
*
voltageRef
.
real
();
mIntfVoltage
(
2
,
0
)
=
RMS3PH_TO_PEAK1PH
*
voltageRef
.
real
();
}
mSLog
->
debug
(
"
\n
Update Voltage: {:s}"
,
Logger
::
matrixToString
(
mIntfVoltage
)
);
}
void
EMT
::
Ph3
::
VoltageSource
::
updateVoltage
(
Matrix
vabc
)
{
...
...
Write
Preview
Markdown
is supported
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