Skip to content

Commit

Permalink
add attributes mConductancePerUnit and mSusceptancePerUnit to SP_Shunt
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Moraga <[email protected]>
  • Loading branch information
martinmoraga committed Aug 3, 2023
1 parent ad63eed commit 34fb96a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
9 changes: 4 additions & 5 deletions dpsim-models/include/dpsim-models/SP/SP_Ph1_Shunt.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,14 @@ namespace SP {namespace Ph1 {
const Attribute<Real>::Ptr mConductance;
/// Susceptance [S]
const Attribute<Real>::Ptr mSusceptance;
/// Conductance [S]
const Attribute<Real>::Ptr mConductancePerUnit;
/// Susceptance [S]
const Attribute<Real>::Ptr mSusceptancePerUnit;
private:
/// Base voltage [V]
Real mBaseVoltage;

/// Conductance [pu]
Real mConductancePerUnit;
/// Susceptance [pu]
Real mSusceptancePerUnit;

public:
/// Defines UID, name, component parameters and logging level
Shunt(String uid, String name, Logger::Level logLevel = Logger::Level::off);
Expand Down
12 changes: 7 additions & 5 deletions dpsim-models/src/SP/SP_Ph1_Shunt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ using namespace CPS;
SP::Ph1::Shunt::Shunt(String uid, String name, Logger::Level logLevel)
: SimPowerComp<Complex>(uid, name, logLevel),
mConductance(mAttributes->create<Real>("G")),
mSusceptance(mAttributes->create<Real>("B")) {
mSusceptance(mAttributes->create<Real>("B")),
mConductancePerUnit(mAttributes->create<Real>("Gpu")),
mSusceptancePerUnit(mAttributes->create<Real>("Bpu")) {

SPDLOG_LOGGER_INFO(mSLog, "Create {} of type {}", this->type(), name);
setTerminalNumber(1);
Expand Down Expand Up @@ -42,15 +44,15 @@ void SP::Ph1::Shunt::calculatePerUnitParameters(Real baseApparentPower, Real bas
auto baseAdmittance = 1.0 / baseImpedance;
SPDLOG_LOGGER_INFO(mSLog, "Base Voltage={} [V] Base Admittance={} [S]", mBaseVoltage, baseAdmittance);

mConductancePerUnit = **mConductance / baseAdmittance;
mSusceptancePerUnit = **mSusceptance / baseAdmittance;
SPDLOG_LOGGER_INFO(mSLog, "Susceptance={} [pu] Conductance={} [pu]", mSusceptancePerUnit, mConductancePerUnit);
**mConductancePerUnit = **mConductance / baseAdmittance;
**mSusceptancePerUnit = **mSusceptance / baseAdmittance;
SPDLOG_LOGGER_INFO(mSLog, "Susceptance={} [pu] Conductance={} [pu]", **mSusceptancePerUnit, **mConductancePerUnit);
};


void SP::Ph1::Shunt::pfApplyAdmittanceMatrixStamp(SparseMatrixCompRow & Y) {
int bus1 = this->matrixNodeIndex(0);
Complex Y_element = Complex(mConductancePerUnit, mSusceptancePerUnit);
Complex Y_element = Complex(**mConductancePerUnit, **mSusceptancePerUnit);

if (std::isinf(Y_element.real()) || std::isinf(Y_element.imag())) {
std::cout << "Y:" << Y_element << std::endl;
Expand Down

0 comments on commit 34fb96a

Please sign in to comment.