Skip to content

Commit

Permalink
fix small error in function determineNodeBaseVoltages of PFSolver
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Moraga <martin.moraga@eonerc.rwth-aachen.de>

resolve rebase conflicts

Signed-off-by: Martin Moraga <martin.moraga@eonerc.rwth-aachen.de>
  • Loading branch information
martinmoraga committed May 21, 2024
1 parent 4800a0d commit 1fcfa43
Show file tree
Hide file tree
Showing 23 changed files with 182 additions and 216 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class NetworkInjection : public CompositePowerComp<Complex>,

// #### Powerflow section ####
/// Base voltage [V]
Real mBaseVoltage;
const Attribute<Real>::Ptr mBaseVoltage;

public:
const Attribute<Complex>::Ptr mVoltageRef;
Expand Down Expand Up @@ -127,4 +127,4 @@ class NetworkInjection : public CompositePowerComp<Complex>,
};
} // namespace Ph1
} // namespace SP
} // namespace CPS
} // namespace CPS
4 changes: 2 additions & 2 deletions dpsim-models/src/DP/DP_Ph1_PiLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
using namespace CPS;

DP::Ph1::PiLine::PiLine(String uid, String name, Logger::Level logLevel)
: Base::Ph1::PiLine(mAttributes),
CompositePowerComp<Complex>(uid, name, true, true, logLevel) {
: Base::Ph1::PiLine(mAttributes), CompositePowerComp<Complex>(
uid, name, true, true, logLevel) {
setVirtualNodeNumber(1);
setTerminalNumber(2);

Expand Down
4 changes: 2 additions & 2 deletions dpsim-models/src/DP/DP_Ph1_RxLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
using namespace CPS;

DP::Ph1::RxLine::RxLine(String uid, String name, Logger::Level logLevel)
: Base::Ph1::PiLine(mAttributes),
CompositePowerComp<Complex>(uid, name, true, true, logLevel) {
: Base::Ph1::PiLine(mAttributes), CompositePowerComp<Complex>(
uid, name, true, true, logLevel) {
setVirtualNodeNumber(1);
setTerminalNumber(2);

Expand Down
5 changes: 3 additions & 2 deletions dpsim-models/src/DP/DP_Ph1_SynchronGeneratorTrStab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ using namespace CPS;

DP::Ph1::SynchronGeneratorTrStab::SynchronGeneratorTrStab(
String uid, String name, Logger::Level logLevel)
: Base::SynchronGenerator(mAttributes),
CompositePowerComp<Complex>(uid, name, true, true, logLevel),
: Base::SynchronGenerator(mAttributes), CompositePowerComp<Complex>(
uid, name, true, true,
logLevel),
mEp(mAttributes->create<Complex>("Ep")),
mEp_abs(mAttributes->create<Real>("Ep_mag")),
mEp_phase(mAttributes->create<Real>("Ep_phase")),
Expand Down
5 changes: 3 additions & 2 deletions dpsim-models/src/DP/DP_Ph1_Transformer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ using namespace CPS;
DP::Ph1::Transformer::Transformer(String uid, String name,
Logger::Level logLevel,
Bool withResistiveLosses)
: Base::Ph1::Transformer(mAttributes),
CompositePowerComp<Complex>(uid, name, true, true, logLevel) {
: Base::Ph1::Transformer(mAttributes), CompositePowerComp<Complex>(
uid, name, true, true,
logLevel) {
if (withResistiveLosses)
setVirtualNodeNumber(3);
else
Expand Down
5 changes: 3 additions & 2 deletions dpsim-models/src/DP/DP_Ph1_VoltageSourceNorton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ using namespace CPS;

DP::Ph1::VoltageSourceNorton::VoltageSourceNorton(String uid, String name,
Logger::Level logLevel)
: Base::Ph1::VoltageSource(mAttributes),
MNASimPowerComp<Complex>(uid, name, true, true, logLevel),
: Base::Ph1::VoltageSource(mAttributes), MNASimPowerComp<Complex>(
uid, name, true, true,
logLevel),
mResistance(mAttributes->create<Real>("R")) {
setTerminalNumber(2);
**mIntfVoltage = MatrixComp::Zero(1, 1);
Expand Down
4 changes: 2 additions & 2 deletions dpsim-models/src/EMT/EMT_Ph3_PiLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
using namespace CPS;

EMT::Ph3::PiLine::PiLine(String uid, String name, Logger::Level logLevel)
: Base::Ph3::PiLine(mAttributes),
CompositePowerComp<Real>(uid, name, true, true, logLevel) {
: Base::Ph3::PiLine(mAttributes), CompositePowerComp<Real>(uid, name, true,
true, logLevel) {
mPhaseType = PhaseType::ABC;
setVirtualNodeNumber(1);
setTerminalNumber(2);
Expand Down
4 changes: 2 additions & 2 deletions dpsim-models/src/EMT/EMT_Ph3_RxLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ using namespace CPS;
// !!! with initialization from phase-to-phase RMS variables

EMT::Ph3::RxLine::RxLine(String uid, String name, Logger::Level logLevel)
: Base::Ph3::PiLine(mAttributes),
CompositePowerComp<Real>(uid, name, true, true, logLevel) {
: Base::Ph3::PiLine(mAttributes), CompositePowerComp<Real>(uid, name, true,
true, logLevel) {
mPhaseType = PhaseType::ABC;
setVirtualNodeNumber(1);
setTerminalNumber(2);
Expand Down
5 changes: 3 additions & 2 deletions dpsim-models/src/EMT/EMT_Ph3_SynchronGeneratorTrStab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ Matrix EMT::Ph3::SynchronGeneratorTrStab::getParkTransformMatrixPowerInvariant(

EMT::Ph3::SynchronGeneratorTrStab::SynchronGeneratorTrStab(
String uid, String name, Logger::Level logLevel)
: Base::SynchronGenerator(mAttributes),
CompositePowerComp<Real>(uid, name, true, true, logLevel),
: Base::SynchronGenerator(mAttributes), CompositePowerComp<Real>(uid, name,
true, true,
logLevel),
mEp(mAttributes->create<Complex>("Ep")),
mEp_abs(mAttributes->create<Real>("Ep_mag")),
mEp_phase(mAttributes->create<Real>("Ep_phase")),
Expand Down
5 changes: 3 additions & 2 deletions dpsim-models/src/EMT/EMT_Ph3_Transformer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ using namespace CPS;
EMT::Ph3::Transformer::Transformer(String uid, String name,
Logger::Level logLevel,
Bool withResistiveLosses)
: Base::Ph3::Transformer(mAttributes),
CompositePowerComp<Real>(uid, name, true, true, logLevel) {
: Base::Ph3::Transformer(mAttributes), CompositePowerComp<Real>(uid, name,
true, true,
logLevel) {
mPhaseType = PhaseType::ABC;
if (withResistiveLosses)
setVirtualNodeNumber(3);
Expand Down
8 changes: 5 additions & 3 deletions dpsim-models/src/SP/SP_Ph1_Load.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ void SP::Ph1::Load::setParameters(Real activePower, Real reactivePower,
**mReactivePower = reactivePower;
**mNomVoltage = nominalVoltage;

SPDLOG_LOGGER_INFO(mSLog, "Active Power={} [W] Reactive Power={} [VAr]",
**mActivePower, **mReactivePower);
SPDLOG_LOGGER_INFO(
mSLog,
"Active Power={}[W]\nReactive Power={} [VAr]\nNominal Voltage={} [V]",
**mActivePower, **mReactivePower, **mNomVoltage);
mSLog->flush();

mParametersSet = true;
Expand Down Expand Up @@ -196,4 +198,4 @@ void SP::Ph1::Load::mnaCompUpdateCurrent(const Matrix &leftVector) {
for (auto &subc : mSubComponents) {
(**mIntfCurrent)(0, 0) += subc->intfCurrent()(0, 0);
}
}
}
9 changes: 5 additions & 4 deletions dpsim-models/src/SP/SP_Ph1_NetworkInjection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ SP::Ph1::NetworkInjection::NetworkInjection(String uid, String name,
: CompositePowerComp<Complex>(uid, name, true, true, logLevel),
mVoltageRef(mAttributes->createDynamic<Complex>("V_ref")),
mSrcFreq(mAttributes->createDynamic<Real>("f_src")),
mBaseVoltage(mAttributes->create<Real>("base_Voltage")),
mVoltageSetPoint(mAttributes->create<Real>("V_set")),
mVoltageSetPointPerUnit(mAttributes->create<Real>("V_set_pu", 1.0)),
mActivePowerInjection(mAttributes->create<Real>("p_inj")),
Expand Down Expand Up @@ -92,16 +93,16 @@ void SP::Ph1::NetworkInjection::setParameters(Complex initialPhasor,
}

void SP::Ph1::NetworkInjection::setBaseVoltage(Real baseVoltage) {
mBaseVoltage = baseVoltage;
**mBaseVoltage = baseVoltage;
}

void SP::Ph1::NetworkInjection::calculatePerUnitParameters(
Real baseApparentPower, Real baseOmega) {
SPDLOG_LOGGER_INFO(mSLog, "#### Calculate Per Unit Parameters for {}",
**mName);
SPDLOG_LOGGER_INFO(mSLog, "Base Voltage={} [V]", mBaseVoltage);
SPDLOG_LOGGER_INFO(mSLog, "Base Voltage={} [V]", **mBaseVoltage);

**mVoltageSetPointPerUnit = **mVoltageSetPoint / mBaseVoltage;
**mVoltageSetPointPerUnit = **mVoltageSetPoint / **mBaseVoltage;

SPDLOG_LOGGER_INFO(mSLog, "Voltage Set-Point ={} [pu]",
**mVoltageSetPointPerUnit);
Expand Down Expand Up @@ -229,4 +230,4 @@ void SP::Ph1::NetworkInjection::daeResidual(double ttime, const double state[],
Complex SP::Ph1::NetworkInjection::daeInitialize() {
(**mIntfVoltage)(0, 0) = (**mSubVoltageSource->mIntfVoltage)(0, 0);
return (**mSubVoltageSource->mIntfVoltage)(0, 0);
}
}
4 changes: 2 additions & 2 deletions dpsim-models/src/SP/SP_Ph1_PiLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
using namespace CPS;

SP::Ph1::PiLine::PiLine(String uid, String name, Logger::Level logLevel)
: Base::Ph1::PiLine(mAttributes),
CompositePowerComp<Complex>(uid, name, false, true, logLevel),
: Base::Ph1::PiLine(mAttributes), CompositePowerComp<Complex>(
uid, name, false, true, logLevel),
mBaseVoltage(mAttributes->create<Real>("base_Voltage")),
mCurrent(mAttributes->create<MatrixComp>("current_vector")),
mActivePowerBranch(mAttributes->create<Matrix>("p_branch_vector")),
Expand Down
8 changes: 4 additions & 4 deletions dpsim-models/src/SP/SP_Ph1_RXLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ using namespace CPS;
SP::Ph1::RXLine::RXLine(String uid, String name, Real baseVoltage,
Real resistance, Real inductance,
Logger::Level logLevel)
: Base::Ph1::PiLine(mAttributes),
CompositePowerComp<Complex>(uid, name, true, true, logLevel),
: Base::Ph1::PiLine(mAttributes), CompositePowerComp<Complex>(
uid, name, true, true, logLevel),
mBaseVoltage(mAttributes->create<Real>("base_Voltage", baseVoltage)),
mInductance(mAttributes->create<Real>("L_series")),
mActivePowerInjection(mAttributes->create<Real>("p_inj")),
Expand All @@ -37,8 +37,8 @@ SP::Ph1::RXLine::RXLine(String uid, String name, Real baseVoltage,
}

SP::Ph1::RXLine::RXLine(String uid, String name, Logger::Level logLevel)
: Base::Ph1::PiLine(mAttributes),
CompositePowerComp<Complex>(uid, name, true, true, logLevel),
: Base::Ph1::PiLine(mAttributes), CompositePowerComp<Complex>(
uid, name, true, true, logLevel),
mBaseVoltage(mAttributes->create<Real>("base_Voltage")),
mInductance(mAttributes->create<Real>("L_series")),
mActivePowerInjection(mAttributes->create<Real>("p_inj")),
Expand Down
5 changes: 3 additions & 2 deletions dpsim-models/src/SP/SP_Ph1_SynchronGeneratorTrStab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ using namespace CPS;

SP::Ph1::SynchronGeneratorTrStab::SynchronGeneratorTrStab(
String uid, String name, Logger::Level logLevel)
: Base::SynchronGenerator(mAttributes),
CompositePowerComp<Complex>(uid, name, true, true, logLevel),
: Base::SynchronGenerator(mAttributes), CompositePowerComp<Complex>(
uid, name, true, true,
logLevel),
mEp(mAttributes->create<Complex>("Ep")),
mEp_abs(mAttributes->create<Real>("Ep_mag")),
mEp_phase(mAttributes->create<Real>("Ep_phase")),
Expand Down
4 changes: 2 additions & 2 deletions dpsim-models/src/SP/SP_Ph1_Transformer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ using namespace CPS;
SP::Ph1::Transformer::Transformer(String uid, String name,
Logger::Level logLevel,
Bool withResistiveLosses)
: Base::Ph1::Transformer(mAttributes),
CompositePowerComp<Complex>(uid, name, true, true, logLevel),
: Base::Ph1::Transformer(mAttributes), CompositePowerComp<Complex>(
uid, name, true, true, logLevel),
mBaseVoltage(mAttributes->create<Real>("base_Voltage")),
mCurrent(mAttributes->create<MatrixComp>("current_vector")),
mActivePowerBranch(mAttributes->create<Matrix>("p_branch_vector")),
Expand Down
Loading

0 comments on commit 1fcfa43

Please sign in to comment.