9#include <dpsim-models/SP/SP_Ph3_Inductor.h>
16 mPhaseType = PhaseType::ABC;
23 auto copy = Inductor::make(name,
mLogLevel);
30 Real omega = 2 * PI * frequency;
31 MatrixComp reactance = MatrixComp::Zero(3, 3);
32 reactance << Complex(0, omega * (**
mInductance)(0, 0)),
44 (**mIntfVoltage)(0, 0) = initialSingleVoltage(1) - initialSingleVoltage(0);
46 Complex(cos(-2. / 3. * M_PI), sin(-2. / 3. * M_PI));
48 Complex(cos(2. / 3. * M_PI), sin(2. / 3. * M_PI));
51 SPDLOG_LOGGER_INFO(
mSLog,
"--- Initialize according to power flow ---");
55 Attribute<Matrix>::Ptr leftVector) {
60 SparseMatrixRow &systemMatrix) {
61 MNAStampUtils::stampAdmittanceMatrix(
62 mSusceptance, systemMatrix, matrixNodeIndex(0), matrixNodeIndex(1),
63 terminalNotGrounded(0), terminalNotGrounded(1),
mSLog);
67 AttributeBase::List &prevStepDependencies,
68 AttributeBase::List &attributeDependencies,
69 AttributeBase::List &modifiedAttributes,
70 Attribute<Matrix>::Ptr &leftVector) {
71 attributeDependencies.push_back(leftVector);
76void SP::Ph3::Inductor::mnaCompPostStep(Real time, Int timeStepCount,
77 Attribute<Matrix>::Ptr &leftVector) {
78 mnaCompUpdateVoltage(**leftVector);
79 mnaCompUpdateCurrent(**leftVector);
85 if (terminalNotGrounded(1)) {
86 (**mIntfVoltage)(0, 0) =
87 Math::complexFromVectorElement(leftVector, matrixNodeIndex(1, 0));
88 (**mIntfVoltage)(1, 0) =
89 Math::complexFromVectorElement(leftVector, matrixNodeIndex(1, 1));
90 (**mIntfVoltage)(2, 0) =
91 Math::complexFromVectorElement(leftVector, matrixNodeIndex(1, 2));
93 if (terminalNotGrounded(0)) {
94 (**mIntfVoltage)(0, 0) =
96 Math::complexFromVectorElement(leftVector, matrixNodeIndex(0, 0));
97 (**mIntfVoltage)(1, 0) =
99 Math::complexFromVectorElement(leftVector, matrixNodeIndex(0, 1));
100 (**mIntfVoltage)(2, 0) =
102 Math::complexFromVectorElement(leftVector, matrixNodeIndex(0, 2));
111void SP::Ph3::Inductor::mnaTearApplyMatrixStamp(SparseMatrixRow &tearMatrix) {
113 Math::addToMatrixElement(tearMatrix, mTearIdx, mTearIdx,
114 1. / mSusceptance(0, 0));
115 Math::addToMatrixElement(tearMatrix, mTearIdx, mTearIdx,
116 1. / mSusceptance(1, 0));
117 Math::addToMatrixElement(tearMatrix, mTearIdx, mTearIdx,
118 1. / mSusceptance(2, 0));
const CPS::Attribute< Matrix >::Ptr mInductance
Inductance [H].
String uid()
Returns unique id.
AttributeList::Ptr mAttributes
Attribute List.
MNASimPowerComp(String uid, String name, Bool hasPreStep, Bool hasPostStep, Logger::Level logLevel)
void initializeFromNodesAndTerminals(Real frequency) override
Initializes component from power flow data.
SimPowerComp< Complex >::Ptr clone(String name) override
Returns a modified copy of the component with the given suffix added to the name and without.
void mnaCompInitialize(Real omega, Real timeStep, Attribute< Matrix >::Ptr leftVector) override
Initializes internal variables of the component.
void mnaCompUpdateCurrent(const Matrix &leftVector) override
Update interface current from MNA system result.
MatrixComp mSusceptance
susceptance [S]
void mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute< Matrix >::Ptr &leftVector) override
Add MNA post step dependencies.
Inductor(String uid, String name, Logger::Level logLevel=Logger::Level::off)
Defines UID, name, component parameters and logging level.
void mnaCompUpdateVoltage(const Matrix &leftVector) override
Update interface voltage from MNA system result.
void mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix) override
Stamps system matrix.
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.