DPsim
Loading...
Searching...
No Matches
SP_Ph1_Shunt.cpp
Go to the documentation of this file.
1/* Copyright 2017-2021 Institute for Automation of Complex Power Systems,
2 * EONERC, RWTH Aachen University
3 *
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
7 *********************************************************************************/
8
11
12using namespace CPS;
13
15 : SimPowerComp<Complex>(uid, name, logLevel),
16 mConductance(mAttributes->create<Real>("G")),
17 mSusceptance(mAttributes->create<Real>("B")),
18 mConductancePerUnit(mAttributes->create<Real>("Gpu")),
19 mSusceptancePerUnit(mAttributes->create<Real>("Bpu")) {
20
21 SPDLOG_LOGGER_INFO(mSLog, "Create {} of type {}", this->type(), name);
23}
24
25void SP::Ph1::Shunt::setParameters(Real conductance, Real susceptance) {
26 **mConductance = conductance;
27 **mSusceptance = susceptance;
28 SPDLOG_LOGGER_INFO(mSLog, "Conductance={} [S] Susceptance={} [Ohm] ",
29 conductance, susceptance);
30 mParametersSet = true;
31}
32
33// #### Powerflow section ####
34Real SP::Ph1::Shunt::getBaseVoltage() const { return mBaseVoltage; }
35
37 mBaseVoltage = baseVoltage;
38}
39
41 Real baseOmega) {
42 SPDLOG_LOGGER_INFO(mSLog, "#### Calculate Per Unit Parameters for {}",
43 **mName);
44 SPDLOG_LOGGER_INFO(mSLog, "Base Power={} [VA] Base Omega={} [1/s]",
45 baseApparentPower, baseOmega);
46
47 auto baseImpedance = (mBaseVoltage * mBaseVoltage) / baseApparentPower;
48 auto baseAdmittance = 1.0 / baseImpedance;
49 SPDLOG_LOGGER_INFO(mSLog, "Base Voltage={} [V] Base Admittance={} [S]",
50 mBaseVoltage, baseAdmittance);
51
52 **mConductancePerUnit = **mConductance / baseAdmittance;
53 **mSusceptancePerUnit = **mSusceptance / baseAdmittance;
54 SPDLOG_LOGGER_INFO(mSLog, "Susceptance={} [pu] Conductance={} [pu]",
56};
57
59 int bus1 = this->matrixNodeIndex(0);
61
62 if (!Math::isFinite(Y_element)) {
63 SPDLOG_LOGGER_ERROR(mSLog,
64 "Shunt {}: non-finite per-unit admittance {} at "
65 "node {}",
66 this->name(), Logger::complexToString(Y_element), bus1);
68 }
69
70 //set the circuit matrix values
71 Y.coeffRef(bus1, bus1) += Y_element;
72 SPDLOG_LOGGER_INFO(mSLog, "#### Y matrix stamping: {}", Y_element);
73}
const Attribute< String >::Ptr mName
Human readable name.
String uid()
Returns unique id.
String type()
Get component type (cross-platform)
AttributeList::Ptr mAttributes
Attribute List.
spdlog::level::level_enum Level
Definition Logger.h:33
static String complexToString(const Complex &num)
Definition Logger.cpp:63
static bool isFinite(Real value)
Definition MathUtils.cpp:63
const Attribute< Real >::Ptr mConductance
Conductance [S].
const Attribute< Real >::Ptr mSusceptance
Susceptance [S].
void setBaseVoltage(Real baseVoltage)
Set base voltage.
Real getBaseVoltage() const
Get 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.
const Attribute< Real >::Ptr mSusceptancePerUnit
Susceptance [pu].
const Attribute< Real >::Ptr mConductancePerUnit
Conductance [pu].
void calculatePerUnitParameters(Real baseApparentPower, Real baseOmega)
Initializes component from power flow data.
void setParameters(Real conductance, Real susceptance)
Set shunt specific parameters.
UInt matrixNodeIndex(UInt nodeIndex)
SimPowerComp(String uid, String name, Logger::Level logLevel=Logger::Level::off)
bool mParametersSet
Flag indicating that parameters are set via setParameters() function.
Logger::Log mSLog
Component logger.
std::string String
Definition Definitions.h:65
Eigen::SparseMatrix< Complex, Eigen::RowMajor > SparseMatrixCompRow
Sparse matrix for complex numbers (row major).
Definition Definitions.h:78
double Real
Definition Definitions.h:62
std::complex< Real > Complex
Definition Definitions.h:63