9#include <dpsim-models/SP/SP_Ph1_Capacitor.h>
22 auto copy = Capacitor::make(name,
mLogLevel);
29 Real omega = 2 * PI * frequency;
33 (**mIntfVoltage)(0, 0) = initialSingleVoltage(1) - initialSingleVoltage(0);
36 SPDLOG_LOGGER_INFO(
mSLog,
37 "\nCapacitance [F]: {:s}"
38 "\nImpedance [Ohm]: {:s}"
39 "\nAdmittance [S]: {:s}",
43 SPDLOG_LOGGER_INFO(
mSLog,
44 "\n--- Initialization from powerflow ---"
45 "\nVoltage across: {:s}"
47 "\nTerminal 0 voltage: {:s}"
48 "\nTerminal 1 voltage: {:s}"
49 "\n--- Initialization from powerflow finished ---",
52 Logger::phasorToString(initialSingleVoltage(0)),
53 Logger::phasorToString(initialSingleVoltage(1)));
59 Attribute<Matrix>::Ptr leftVector) {
61 SPDLOG_LOGGER_INFO(
mSLog,
62 "\n--- MNA initialization ---"
63 "\nInitial voltage {:s}"
64 "\nInitial current {:s}"
65 "\n--- MNA initialization finished ---",
71 SparseMatrixRow &systemMatrix) {
72 MNAStampUtils::stampAdmittance(
mSusceptance, systemMatrix, matrixNodeIndex(0),
73 matrixNodeIndex(1), terminalNotGrounded(0),
74 terminalNotGrounded(1),
mSLog);
78 AttributeBase::List &prevStepDependencies,
79 AttributeBase::List &attributeDependencies,
80 AttributeBase::List &modifiedAttributes,
81 Attribute<Matrix>::Ptr &leftVector) {
82 attributeDependencies.push_back(leftVector);
88 Attribute<Matrix>::Ptr &leftVector) {
96 if (terminalNotGrounded(1)) {
97 (**mIntfVoltage)(0, 0) =
98 Math::complexFromVectorElement(leftVector, matrixNodeIndex(1));
100 if (terminalNotGrounded(0)) {
101 (**mIntfVoltage)(0, 0) =
103 Math::complexFromVectorElement(leftVector, matrixNodeIndex(0));
118 SPDLOG_LOGGER_INFO(
mSLog,
"#### Calculate Per Unit Parameters for {}",
121 SPDLOG_LOGGER_INFO(
mSLog,
"Base Power={} [VA]", baseApparentPower);
128 SPDLOG_LOGGER_INFO(
mSLog,
"Base Voltage={} [V] Base Impedance={} [Ohm]",
133 SPDLOG_LOGGER_INFO(
mSLog,
"Impedance={} [pu] Admittance={} [pu]",
139 int bus1 = this->matrixNodeIndex(0);
144 std::stringstream ss;
145 ss <<
"Capacitor >>" << this->name()
146 <<
": infinite or nan values at node: " << bus1;
147 throw std::invalid_argument(ss.str());
const CPS::Attribute< Real >::Ptr mCapacitance
Capacitance [F].
const Attribute< String >::Ptr mName
Human readable name.
String uid()
Returns unique id.
AttributeList::Ptr mAttributes
Attribute List.
void mnaUpdateCurrent(const Matrix &leftVector) final
void mnaUpdateVoltage(const Matrix &leftVector) final
MNASimPowerComp(String uid, String name, Bool hasPreStep, Bool hasPostStep, Logger::Level logLevel)
Complex mImpedance
Impedance [Ohm].
void mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute< Matrix >::Ptr &leftVector) override
Add MNA post step dependencies.
void mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix) override
Stamps system matrix.
void mnaCompUpdateVoltage(const Matrix &leftVector) override
Update interface voltage from MNA system result.
void setBaseVoltage(Real baseVoltage)
Set base voltage.
Real mBaseApparentPower
base apparent power[VA]
void mnaCompUpdateCurrent(const Matrix &leftVector) override
Update interface current from MNA system result.
SimPowerComp< Complex >::Ptr clone(String name) override
Returns a modified copy of the component with the given suffix added to the name and without.
Capacitor(String uid, String name, Logger::Level logLevel=Logger::Level::off)
Defines UID, name and logging level.
void calculatePerUnitParameters(Real baseApparentPower)
Initializes component from power flow data.
Complex mSusceptance
Susceptance [S].
Complex mAdmittance
Admittance [S].
Complex mImpedancePerUnit
Impedance [pu].
Real mBaseAdmittance
base admittance [S]
void initializeFromNodesAndTerminals(Real frequency) override
Initializes component from power flow data.
void mnaCompPostStep(Real time, Int timeStepCount, Attribute< Matrix >::Ptr &leftVector) override
MNA post step operations.
Complex mAdmittancePerUnit
Admittance [pu].
Real mBaseImpedance
base impedance [ohm]
void mnaCompInitialize(Real omega, Real timeStep, Attribute< Matrix >::Ptr leftVector) override
Initializes internal variables of the component.
Real mBaseVoltage
base voltage [V]
void pfApplyAdmittanceMatrixStamp(SparseMatrixCompRow &Y) override
Stamps admittance matrix.
Real mBaseCurrent
base current [A]
const Attribute< MatrixVar< Complex > >::Ptr mIntfCurrent
const Attribute< MatrixVar< Complex > >::Ptr mIntfVoltage
void updateMatrixNodeIndices()
Logger::Level mLogLevel
Component logger control for internal variables.
Logger::Log mSLog
Component logger.