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
df041580
Commit
df041580
authored
Oct 30, 2020
by
Jan Dinkelbach
Committed by
Markus Mirz
Nov 21, 2020
Browse files
remove reference member variables from emt3ph voltage source
parent
4340142e
Changes
2
Hide whitespace changes
Inline
Side-by-side
models/Include/cps/EMT/EMT_Ph3_VoltageSource.h
View file @
df041580
...
@@ -26,13 +26,8 @@ namespace CPS {
...
@@ -26,13 +26,8 @@ namespace CPS {
public
SimPowerComp
<
Real
>
,
public
SimPowerComp
<
Real
>
,
public
SharedFactory
<
VoltageSource
>
{
public
SharedFactory
<
VoltageSource
>
{
protected:
protected:
// Updates voltage according to reference phasor and frequency
void
updateVoltage
(
Real
time
);
void
updateVoltage
(
Real
time
);
void
updateVoltage
(
Matrix
vabc
);
/// Magnitude of the sinusoidal voltage (peak-value, phase-to-ground)
Attribute
<
MatrixComp
>::
Ptr
mVoltageRef
;
/// Frequency of the sinusoidal voltage
Attribute
<
Real
>::
Ptr
mSrcFreq
;
public:
public:
/// Defines UID, name and logging level
/// Defines UID, name and logging level
VoltageSource
(
String
uid
,
String
name
,
Logger
::
Level
logLevel
=
Logger
::
Level
::
off
);
VoltageSource
(
String
uid
,
String
name
,
Logger
::
Level
logLevel
=
Logger
::
Level
::
off
);
...
@@ -40,12 +35,12 @@ namespace CPS {
...
@@ -40,12 +35,12 @@ namespace CPS {
VoltageSource
(
String
name
,
Logger
::
Level
logLevel
=
Logger
::
Level
::
off
)
VoltageSource
(
String
name
,
Logger
::
Level
logLevel
=
Logger
::
Level
::
off
)
:
VoltageSource
(
name
,
name
,
logLevel
)
{
}
:
VoltageSource
(
name
,
name
,
logLevel
)
{
}
void
setParameters
(
MatrixComp
voltageRef
,
Real
srcFreq
=
-
1
);
SimPowerComp
<
Real
>::
Ptr
clone
(
String
name
);
SimPowerComp
<
Real
>::
Ptr
clone
(
String
name
);
// #### General ####
// #### General ####
/// Initializes component from power flow data
/// Initializes component from power flow data
void
initializeFromNodesAndTerminals
(
Real
frequency
);
void
initializeFromNodesAndTerminals
(
Real
frequency
);
/// Setter for reference voltage
void
setParameters
(
MatrixComp
voltageRef
,
Real
srcFreq
=
-
1
);
// #### MNA section ####
// #### MNA section ####
/// Initializes internal variables of the component
/// Initializes internal variables of the component
...
...
models/Source/EMT/EMT_Ph3_VoltageSource.cpp
View file @
df041580
...
@@ -20,7 +20,7 @@ EMT::Ph3::VoltageSource::VoltageSource(String uid, String name, Logger::Level lo
...
@@ -20,7 +20,7 @@ EMT::Ph3::VoltageSource::VoltageSource(String uid, String name, Logger::Level lo
mIntfVoltage
=
Matrix
::
Zero
(
3
,
1
);
mIntfVoltage
=
Matrix
::
Zero
(
3
,
1
);
mIntfCurrent
=
Matrix
::
Zero
(
3
,
1
);
mIntfCurrent
=
Matrix
::
Zero
(
3
,
1
);
addAttribute
<
MatrixComp
>
(
"V_ref"
,
Flags
::
read
|
Flags
::
write
);
addAttribute
<
MatrixComp
>
(
"V_ref"
,
Flags
::
read
|
Flags
::
write
);
// rms-value, phase-to-phase
addAttribute
<
Real
>
(
"f_src"
,
Flags
::
read
|
Flags
::
write
);
addAttribute
<
Real
>
(
"f_src"
,
Flags
::
read
|
Flags
::
write
);
}
}
...
@@ -32,29 +32,28 @@ void EMT::Ph3::VoltageSource::setParameters(MatrixComp voltageRef, Real srcFreq)
...
@@ -32,29 +32,28 @@ void EMT::Ph3::VoltageSource::setParameters(MatrixComp voltageRef, Real srcFreq)
"
\n
Frequency [Hz]: {:s}"
,
"
\n
Frequency [Hz]: {:s}"
,
Logger
::
matrixCompToString
(
voltageRef
),
Logger
::
matrixCompToString
(
voltageRef
),
Logger
::
realToString
(
srcFreq
));
Logger
::
realToString
(
srcFreq
));
mParametersSet
=
true
;
mParametersSet
=
true
;
}
}
void
EMT
::
Ph3
::
VoltageSource
::
initializeFromNodesAndTerminals
(
Real
frequency
)
{
void
EMT
::
Ph3
::
VoltageSource
::
initializeFromNodesAndTerminals
(
Real
frequency
)
{
mVoltageRef
=
attribute
<
MatrixComp
>
(
"V_ref"
);
mSrcFreq
=
attribute
<
Real
>
(
"f_src"
);
mSLog
->
info
(
"
\n
--- Initialization from node voltages ---"
);
mSLog
->
info
(
"
\n
--- Initialization from node voltages ---"
);
// TODO: this approach currently does not work, if voltage ref set from outside without using setParameters,
// TODO: this approach currently overwrites voltage reference set from outside, when not using setParameters
// since mParametersSet remains false then
if
(
!
mParametersSet
)
{
if
(
!
mParametersSet
)
{
mVoltageRef
->
set
(
CIM
::
Reader
::
singlePhaseVariableToThreePhase
(
initialSingleVoltage
(
1
)
-
initialSingleVoltage
(
0
)));
attribute
<
MatrixComp
>
(
"V_ref"
)
->
set
(
CIM
::
Reader
::
singlePhaseVariableToThreePhase
(
initialSingleVoltage
(
1
)
-
initialSingleVoltage
(
0
)));
mSrcFreq
->
set
(
frequency
);
attribute
<
Real
>
(
"f_src"
)
->
set
(
frequency
);
mSLog
->
info
(
"
\n
Reference voltage: {:s}"
mSLog
->
info
(
"
\n
Reference voltage: {:s}"
"
\n
Terminal 0 voltage: {:s}"
"
\n
Terminal 0 voltage: {:s}"
"
\n
Terminal 1 voltage: {:s}"
,
"
\n
Terminal 1 voltage: {:s}"
,
Logger
::
matrixCompToString
(
mVoltageRef
->
get
()),
Logger
::
matrixCompToString
(
attribute
<
MatrixComp
>
(
"V_ref"
)
->
get
()),
Logger
::
phasorToString
(
initialSingleVoltage
(
0
)));
Logger
::
phasorToString
(
initialSingleVoltage
(
0
)),
Logger
::
phasorToString
(
initialSingleVoltage
(
1
)));
}
else
{
}
else
{
mSLog
->
info
(
"
\n
Initialization from node voltages omitted (parameter already set)."
mSLog
->
info
(
"
\n
Initialization from node voltages omitted (parameter already set)."
"
\n
Reference voltage: {:s}"
,
"
\n
Reference voltage: {:s}"
,
Logger
::
matrixCompToString
(
mVoltageRef
->
get
()));
Logger
::
matrixCompToString
(
attribute
<
MatrixComp
>
(
"V_ref"
)
->
get
()));
}
}
mSLog
->
info
(
"
\n
--- Initialization from node voltages ---"
);
mSLog
->
info
(
"
\n
--- Initialization from node voltages ---"
);
mSLog
->
flush
();
mSLog
->
flush
();
...
@@ -119,16 +118,16 @@ void EMT::Ph3::VoltageSource::mnaApplyRightSideVectorStamp(Matrix& rightVector)
...
@@ -119,16 +118,16 @@ void EMT::Ph3::VoltageSource::mnaApplyRightSideVectorStamp(Matrix& rightVector)
}
}
void
EMT
::
Ph3
::
VoltageSource
::
updateVoltage
(
Real
time
)
{
void
EMT
::
Ph3
::
VoltageSource
::
updateVoltage
(
Real
time
)
{
if
(
mSrcFreq
->
get
()
<
0
)
{
if
(
attribute
<
Real
>
(
"f_src"
)
->
get
()
<
0
)
{
mIntfVoltage
=
RMS3PH_TO_PEAK1PH
*
mVoltageRef
->
get
().
real
();
mIntfVoltage
=
RMS3PH_TO_PEAK1PH
*
attribute
<
MatrixComp
>
(
"V_ref"
)
->
get
().
real
();
}
}
else
{
else
{
mIntfVoltage
(
0
,
0
)
=
mIntfVoltage
(
0
,
0
)
=
RMS3PH_TO_PEAK1PH
*
Math
::
abs
(
mVoltageRef
->
get
()(
0
,
0
))
*
cos
(
time
*
2.
*
PI
*
mSrcFreq
->
get
()
+
Math
::
phase
(
mVoltageRef
->
get
())(
0
,
0
));
RMS3PH_TO_PEAK1PH
*
Math
::
abs
(
attribute
<
MatrixComp
>
(
"V_ref"
)
->
get
()(
0
,
0
))
*
cos
(
time
*
2.
*
PI
*
attribute
<
Real
>
(
"f_src"
)
->
get
()
+
Math
::
phase
(
attribute
<
MatrixComp
>
(
"V_ref"
)
->
get
())(
0
,
0
));
mIntfVoltage
(
1
,
0
)
=
mIntfVoltage
(
1
,
0
)
=
RMS3PH_TO_PEAK1PH
*
Math
::
abs
(
mVoltageRef
->
get
()(
1
,
0
))
*
cos
(
time
*
2.
*
PI
*
mSrcFreq
->
get
()
+
Math
::
phase
(
mVoltageRef
->
get
())(
1
,
0
));
RMS3PH_TO_PEAK1PH
*
Math
::
abs
(
attribute
<
MatrixComp
>
(
"V_ref"
)
->
get
()(
1
,
0
))
*
cos
(
time
*
2.
*
PI
*
attribute
<
Real
>
(
"f_src"
)
->
get
()
+
Math
::
phase
(
attribute
<
MatrixComp
>
(
"V_ref"
)
->
get
())(
1
,
0
));
mIntfVoltage
(
2
,
0
)
=
mIntfVoltage
(
2
,
0
)
=
RMS3PH_TO_PEAK1PH
*
Math
::
abs
(
mVoltageRef
->
get
()(
2
,
0
))
*
cos
(
time
*
2.
*
PI
*
mSrcFreq
->
get
()
+
Math
::
phase
(
mVoltageRef
->
get
())(
2
,
0
));
RMS3PH_TO_PEAK1PH
*
Math
::
abs
(
attribute
<
MatrixComp
>
(
"V_ref"
)
->
get
()(
2
,
0
))
*
cos
(
time
*
2.
*
PI
*
attribute
<
Real
>
(
"f_src"
)
->
get
()
+
Math
::
phase
(
attribute
<
MatrixComp
>
(
"V_ref"
)
->
get
())(
2
,
0
));
}
}
mSLog
->
debug
(
mSLog
->
debug
(
...
@@ -137,10 +136,6 @@ void EMT::Ph3::VoltageSource::updateVoltage(Real time) {
...
@@ -137,10 +136,6 @@ void EMT::Ph3::VoltageSource::updateVoltage(Real time) {
);
);
}
}
void
EMT
::
Ph3
::
VoltageSource
::
updateVoltage
(
Matrix
vabc
)
{
mIntfVoltage
=
vabc
;
}
void
EMT
::
Ph3
::
VoltageSource
::
mnaAddPreStepDependencies
(
AttributeBase
::
List
&
prevStepDependencies
,
AttributeBase
::
List
&
attributeDependencies
,
AttributeBase
::
List
&
modifiedAttributes
)
{
void
EMT
::
Ph3
::
VoltageSource
::
mnaAddPreStepDependencies
(
AttributeBase
::
List
&
prevStepDependencies
,
AttributeBase
::
List
&
attributeDependencies
,
AttributeBase
::
List
&
modifiedAttributes
)
{
attributeDependencies
.
push_back
(
attribute
(
"V_ref"
));
attributeDependencies
.
push_back
(
attribute
(
"V_ref"
));
modifiedAttributes
.
push_back
(
attribute
(
"right_vector"
));
modifiedAttributes
.
push_back
(
attribute
(
"right_vector"
));
...
...
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