Skip to content

Commit

Permalink
change naming of reactive power attribute
Browse files Browse the repository at this point in the history
Signed-off-by: Ghassen Nakti <ghassen.nakti@eonerc.rwth-aachen.de>
  • Loading branch information
gnakti committed Nov 5, 2024
1 parent c0d62a0 commit 40464f5
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ namespace Ph1 {
const Attribute<Real>::Ptr mIrcq;

const Attribute<Real>::Ptr mElecActivePower;
const Attribute<Real>::Ptr mElecPassivePower;
const Attribute<Real>::Ptr mElecReactivePower;

// Control outputs
/// Voltage as control output after transformation interface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ namespace Ph3 {
const Attribute<Real>::Ptr mIrcq;

const Attribute<Real>::Ptr mElecActivePower;
const Attribute<Real>::Ptr mElecPassivePower;
const Attribute<Real>::Ptr mElecReactivePower;

// Control outputs
/// Voltage as control output after transformation interface
Expand Down
22 changes: 10 additions & 12 deletions dpsim-models/src/DP/DP_Ph1_VSIVoltageControlDQ.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ DP::Ph1::VSIVoltageControlDQ::VSIVoltageControlDQ(String uid, String name, Logge
mIrcd(mAttributes->create<Real>("Irc_d", 0)),
mIrcq(mAttributes->create<Real>("Irc_q", 0)),
mElecActivePower(mAttributes->create<Real>("P_elec", 0)),
mElecPassivePower(mAttributes->create<Real>("Q_elec", 0)),
mElecReactivePower(mAttributes->create<Real>("Q_elec", 0)),
mVsref(mAttributes->create<MatrixComp>("Vsref", MatrixComp::Zero(1,1))),
mVs(mAttributes->createDynamic<MatrixComp>("Vs")),
mDroopOutput(mAttributes->createDynamic<Real>("droop_output")),
Expand Down Expand Up @@ -94,21 +94,21 @@ DP::Ph1::VSIVoltageControlDQ::VSIVoltageControlDQ(String uid, String name, Logge
}

//setter target voltage and power
void DP::Ph1::VSIVoltageControlDQ::setParameters(Real Omega, Real VdRef, Real VqRef, Real Pref) {
void DP::Ph1::VSIVoltageControlDQ::setParameters(Real Omega, Real VdRef, Real VqRef, Real PRef) {
mParametersSet = true;

SPDLOG_LOGGER_INFO(mSLog,"General Parameters:");
SPDLOG_LOGGER_INFO(mSLog,"Nominal Omega={} [1/s]", Omega);
SPDLOG_LOGGER_INFO(mSLog,"VdRef={} [V] VqRef={} [V]", VdRef, VqRef);
SPDLOG_LOGGER_INFO(mSLog,"VdRef={} [V] VqRef={} [V] PRef={} [W]", VdRef, VqRef, PRef);

mVoltageControllerVSI->setParameters(VdRef, VqRef);
mVCO->setParameters(Omega);
mDroop->setParameters(Pref, Omega);
mDroop->setParameters(PRef, Omega);

**mOmegaN = Omega;
**mVdRef = VdRef;
**mVqRef = VqRef;
**mPRef= Pref;
**mPRef= PRef;

}

Expand Down Expand Up @@ -352,13 +352,13 @@ void DP::Ph1::VSIVoltageControlDQ::controlStep(Real time, Int timeStepCount) {
if(mWithConnectionTransformer)
{
// TODO: use DPDQ interface!!!
vcdq = Math::rotatingFrame2to1(mVirtualNodes[3]->singleVoltage(), (**mVCO->mOutputPrev)(0,0), 0);
ircdq = Math::rotatingFrame2to1(-1. * (**mSubResistorC->mIntfCurrent)(0, 0), (**mVCO->mOutputPrev)(0,0), 0);
vcdq = Math::rotatingFrame2to1(mVirtualNodes[3]->singleVoltage(), (**mVCO->mOutputPrev)(0,0), mThetaN);
ircdq = Math::rotatingFrame2to1(-1. * (**mSubResistorC->mIntfCurrent)(0, 0), (**mVCO->mOutputPrev)(0,0), mThetaN);
}
else{
// TODO: use DPDQ interface!!!
vcdq = Math::rotatingFrame2to1(mVirtualNodes[2]->singleVoltage(), (**mVCO->mOutputPrev)(0,0), 0);
ircdq = Math::rotatingFrame2to1(-1. * (**mSubResistorC->mIntfCurrent)(0, 0), (**mVCO->mOutputPrev)(0,0), 0);
vcdq = Math::rotatingFrame2to1(mVirtualNodes[2]->singleVoltage(), (**mVCO->mOutputPrev)(0,0), mThetaN);
ircdq = Math::rotatingFrame2to1(-1. * (**mSubResistorC->mIntfCurrent)(0, 0), (**mVCO->mOutputPrev)(0,0), mThetaN);

}

Expand All @@ -373,10 +373,8 @@ void DP::Ph1::VSIVoltageControlDQ::controlStep(Real time, Int timeStepCount) {
mVoltageControllerVSI->signalStep(time, timeStepCount);

// Transformation interface backward
// (**mVsref)(0,0) = Math::rotatingFrame2to1(Complex(mVoltageControllerVSI->attributeTyped<Matrix>("output_curr")->get()(0, 0), mVoltageControllerVSI->attributeTyped<Matrix>("output_curr")->get()(1, 0)), mThetaN, (**mVCO->mOutputPrev)(0,0));
// TODO: use DPDQ interface!!!
(**mVsref)(0,0) = Math::rotatingFrame2to1(Complex(mVoltageControllerVSI->attributeTyped<Matrix>("output_curr")->get()(0, 0), mVoltageControllerVSI->attributeTyped<Matrix>("output_curr")->get()(1, 0)), 0, (**mVCO->mOutputCurr)(0,0));

(**mVsref)(0,0) = Math::rotatingFrame2to1(Complex(mVoltageControllerVSI->attributeTyped<Matrix>("output_curr")->get()(0, 0), mVoltageControllerVSI->attributeTyped<Matrix>("output_curr")->get()(1, 0)), mThetaN, (**mVCO->mOutputPrev)(0,0));

// Update nominal system angle
mThetaN = mThetaN + mTimeStep * **mOmegaN;
Expand Down
6 changes: 3 additions & 3 deletions dpsim-models/src/EMT/EMT_Ph3_VSIVoltageControlDQ.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ EMT::Ph3::VSIVoltageControlDQ::VSIVoltageControlDQ(String uid, String name, Logg
mIrcd(mAttributes->create<Real>("Irc_d", 0)),
mIrcq(mAttributes->create<Real>("Irc_q", 0)),
mElecActivePower(mAttributes->create<Real>("P_elec", 0)),
mElecPassivePower(mAttributes->create<Real>("Q_elec", 0)),
mElecReactivePower(mAttributes->create<Real>("Q_elec", 0)),
mVsref(mAttributes->create<Matrix>("Vsref", Matrix::Zero(3,1))),
mVs(mAttributes->createDynamic<Matrix>("Vs")),
mDroopOutput(mAttributes->createDynamic<Real>("droop_output")),
Expand Down Expand Up @@ -217,7 +217,7 @@ void EMT::Ph3::VSIVoltageControlDQ::initializeFromNodesAndTerminals(Real frequen
**mIntfVoltage = intfVoltageComplex.real();
**mIntfCurrent = intfCurrentComplex.real();
**mElecActivePower = ( 3./2. * intfVoltageComplex(0,0) * std::conj( - intfCurrentComplex(0,0)) ).real();
**mElecPassivePower = ( 3./2. * intfVoltageComplex(0,0) * std::conj( - intfCurrentComplex(0,0)) ).imag();
**mElecReactivePower = ( 3./2. * intfVoltageComplex(0,0) * std::conj( - intfCurrentComplex(0,0)) ).imag();

// Initialize controlled source
mSubCtrledVoltageSource->setParameters(mVirtualNodes[0]->initialVoltage(), 0.0);
Expand Down Expand Up @@ -415,7 +415,7 @@ void EMT::Ph3::VSIVoltageControlDQ::controlStep(Real time, Int timeStepCount) {

//calculation of system power
**mElecActivePower = - 1. * (intfVoltageDQ(0, 0)*intfCurrentDQ(0, 0) + intfVoltageDQ(1, 0)*intfCurrentDQ(1, 0));
**mElecPassivePower = - 1. * (intfVoltageDQ(1, 0)*intfCurrentDQ(0, 0) - intfVoltageDQ(0, 0)*intfCurrentDQ(1, 0));
**mElecReactivePower = - 1. * (intfVoltageDQ(1, 0)*intfCurrentDQ(0, 0) - intfVoltageDQ(0, 0)*intfCurrentDQ(1, 0));

//vector of voltages
**mVcd = vcdq(0, 0);
Expand Down

0 comments on commit 40464f5

Please sign in to comment.