9 #include <dpsim-models/SP/SP_Ph1_Shunt.h>
15 mConductance(mAttributes->create<Real>(
"G")),
16 mSusceptance(mAttributes->create<Real>(
"B")),
17 mConductancePerUnit(mAttributes->create<Real>(
"Gpu")),
18 mSusceptancePerUnit(mAttributes->create<Real>(
"Bpu")) {
20 SPDLOG_LOGGER_INFO(
mSLog,
"Create {} of type {}", this->
type(), name);
25 **mConductance = conductance;
26 **mSusceptance = susceptance;
27 SPDLOG_LOGGER_INFO(mSLog,
"Conductance={} [S] Susceptance={} [Ohm] ",
28 conductance, susceptance);
29 mParametersSet =
true;
34 mBaseVoltage = baseVoltage;
39 SPDLOG_LOGGER_INFO(mSLog,
"#### Calculate Per Unit Parameters for {}",
41 SPDLOG_LOGGER_INFO(mSLog,
"Base Power={} [VA] Base Omega={} [1/s]",
42 baseApparentPower, baseOmega);
44 auto baseImpedance = (mBaseVoltage * mBaseVoltage) / baseApparentPower;
45 auto baseAdmittance = 1.0 / baseImpedance;
46 SPDLOG_LOGGER_INFO(mSLog,
"Base Voltage={} [V] Base Admittance={} [S]",
47 mBaseVoltage, baseAdmittance);
49 **mConductancePerUnit = **mConductance / baseAdmittance;
50 **mSusceptancePerUnit = **mSusceptance / baseAdmittance;
51 SPDLOG_LOGGER_INFO(mSLog,
"Susceptance={} [pu] Conductance={} [pu]",
52 **mSusceptancePerUnit, **mConductancePerUnit);
56 int bus1 = this->matrixNodeIndex(0);
57 Complex Y_element = Complex(**mConductancePerUnit, **mSusceptancePerUnit);
59 if (std::isinf(Y_element.real()) || std::isinf(Y_element.imag())) {
60 std::cout <<
"Y:" << Y_element << std::endl;
62 ss <<
"Shunt>>" << this->name()
63 <<
": infinite or nan values at node: " << bus1;
64 throw std::invalid_argument(ss.str());
68 Y.coeffRef(bus1, bus1) += Y_element;
69 SPDLOG_LOGGER_INFO(mSLog,
"#### Y matrix stamping: {}", Y_element);
String type()
Get component type (cross-platform)
void setBaseVoltage(Real baseVoltage)
Set base voltage.
void pfApplyAdmittanceMatrixStamp(SparseMatrixCompRow &Y)
Stamps admittance matrix.
Shunt(String uid, String name, Logger::Level logLevel=Logger::Level::off)
Defines UID, name, component parameters and logging level.
void calculatePerUnitParameters(Real baseApparentPower, Real baseOmega)
Initializes component from power flow data.
void setParameters(Real conductance, Real susceptance)
Set shunt specific parameters.
Base class for all components that are transmitting power.
Logger::Log mSLog
Component logger.