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
daff7237
Commit
daff7237
authored
Oct 27, 2020
by
Jan Dinkelbach
Committed by
Markus Mirz
Nov 21, 2020
Browse files
improve dp1ph voltage source implementation
parent
41abd99b
Changes
1
Hide whitespace changes
Inline
Side-by-side
models/Source/DP/DP_Ph1_VoltageSource.cpp
View file @
daff7237
...
...
@@ -37,18 +37,18 @@ void DP::Ph1::VoltageSource::setParameters(Complex voltageRef, Real srcFreq) {
void
DP
::
Ph1
::
VoltageSource
::
initializeFromNodesAndTerminals
(
Real
frequency
)
{
mVoltageRef
=
attribute
<
Complex
>
(
"V_ref"
);
mSrcFreq
=
attribute
<
Real
>
(
"f_src"
);
if
(
mVoltageRef
->
get
()
==
Complex
(
0
,
0
))
if
(
!
mParametersSet
)
mVoltageRef
->
set
(
initialSingleVoltage
(
1
)
-
initialSingleVoltage
(
0
));
mSLog
->
info
(
"
\n
--- Initialization from node voltages ---"
"
\n
Voltage across: {:
e}<{:e
}"
"
\n
Terminal 0 voltage: {:
e}<{:e
}"
"
\n
Terminal 1 voltage: {:
e}<{:e
}"
"
\n
Voltage across: {:
s
}"
"
\n
Terminal 0 voltage: {:
s
}"
"
\n
Terminal 1 voltage: {:
s
}"
"
\n
--- Initialization from node voltages ---"
,
std
::
abs
(
mVoltageRef
->
get
()),
std
::
ar
g
(
mVoltageRef
->
get
()),
std
::
abs
(
initialSingleVoltage
(
0
)),
std
::
ar
g
(
initialSingleVoltage
(
0
)),
std
::
abs
(
initialSingleVoltage
(
1
)),
std
::
ar
g
(
initialSingleVoltage
(
1
)));
Logger
::
phasorToStrin
g
(
mVoltageRef
->
get
()),
Logger
::
phasorToStrin
g
(
initialSingleVoltage
(
0
)),
Logger
::
phasorToStrin
g
(
initialSingleVoltage
(
1
)));
}
// #### MNA functions ####
...
...
@@ -72,6 +72,14 @@ void DP::Ph1::VoltageSource::mnaInitialize(Real omega, Real timeStep, Attribute<
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
::
phasorToString
(
mIntfVoltage
(
0
,
0
)),
Logger
::
phasorToString
(
mIntfCurrent
(
0
,
0
)));
}
void
DP
::
Ph1
::
VoltageSource
::
mnaInitializeHarm
(
Real
omega
,
Real
timeStep
,
std
::
vector
<
Attribute
<
Matrix
>::
Ptr
>
leftVectors
)
{
...
...
@@ -154,6 +162,8 @@ void DP::Ph1::VoltageSource::updateVoltage(Real time) {
Math
::
abs
(
mVoltageRef
->
get
())
*
cos
(
time
*
2.
*
PI
*
mSrcFreq
->
get
()
+
Math
::
phase
(
mVoltageRef
->
get
())),
Math
::
abs
(
mVoltageRef
->
get
())
*
sin
(
time
*
2.
*
PI
*
mSrcFreq
->
get
()
+
Math
::
phase
(
mVoltageRef
->
get
())));
}
mSLog
->
debug
(
"Update Voltage {:s}"
,
Logger
::
phasorToString
(
mIntfVoltage
(
0
,
0
)));
}
void
DP
::
Ph1
::
VoltageSource
::
mnaPreStep
(
Real
time
,
Int
timeStepCount
)
{
...
...
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