9 #include <dpsim-models/EMT/EMT_Ph1_Inductor.h>
23 auto copy = Inductor::make(name, mLogLevel);
24 copy->setParameters(**mInductance);
30 Real omega = 2 * PI * frequency;
31 Complex impedance = {0, omega * **mInductance};
33 RMS3PH_TO_PEAK1PH * (initialSingleVoltage(1) - initialSingleVoltage(0));
34 (**mIntfVoltage)(0, 0) = voltage.real();
35 (**mIntfCurrent)(0, 0) = (voltage / impedance).real();
37 SPDLOG_LOGGER_INFO(mSLog,
38 "\n--- Initialization from powerflow ---"
39 "\nVoltage across: {:f}"
41 "\nTerminal 0 voltage: {:f}"
42 "\nTerminal 1 voltage: {:f}"
43 "\n--- Initialization from powerflow finished ---",
44 (**mIntfVoltage)(0, 0), (**mIntfCurrent)(0, 0),
45 (RMS3PH_TO_PEAK1PH * initialSingleVoltage(0)).real(),
46 (RMS3PH_TO_PEAK1PH * initialSingleVoltage(1)).real());
51 updateMatrixNodeIndices();
53 mEquivCond = timeStep / (2.0 * **mInductance);
55 mEquivCurrent = mEquivCond * (**mIntfVoltage)(0, 0) + (**mIntfCurrent)(0, 0);
59 SparseMatrixRow &systemMatrix) {
60 MNAStampUtils::stampConductance(mEquivCond, systemMatrix, matrixNodeIndex(0),
61 matrixNodeIndex(1), terminalNotGrounded(0),
62 terminalNotGrounded(1), mSLog);
67 mEquivCurrent = mEquivCond * (**mIntfVoltage)(0, 0) + (**mIntfCurrent)(0, 0);
68 if (terminalNotGrounded(0))
69 Math::setVectorElement(rightVector, matrixNodeIndex(0), mEquivCurrent);
70 if (terminalNotGrounded(1))
71 Math::setVectorElement(rightVector, matrixNodeIndex(1), -mEquivCurrent);
75 AttributeBase::List &prevStepDependencies,
76 AttributeBase::List &attributeDependencies,
77 AttributeBase::List &modifiedAttributes) {
79 modifiedAttributes.push_back(mRightVector);
80 prevStepDependencies.push_back(mIntfCurrent);
81 prevStepDependencies.push_back(mIntfVoltage);
84 void EMT::Ph1::Inductor::mnaCompPreStep(Real time, Int timeStepCount) {
85 mnaCompApplyRightSideVectorStamp(**mRightVector);
89 AttributeBase::List &prevStepDependencies,
90 AttributeBase::List &attributeDependencies,
91 AttributeBase::List &modifiedAttributes,
93 attributeDependencies.push_back(leftVector);
94 modifiedAttributes.push_back(mIntfVoltage);
95 modifiedAttributes.push_back(mIntfCurrent);
98 void EMT::Ph1::Inductor::mnaCompPostStep(Real time, Int timeStepCount,
100 mnaCompUpdateVoltage(**leftVector);
101 mnaCompUpdateCurrent(**leftVector);
106 (**mIntfVoltage)(0, 0) = 0;
107 if (terminalNotGrounded(1))
108 (**mIntfVoltage)(0, 0) =
109 Math::realFromVectorElement(leftVector, matrixNodeIndex(1));
110 if (terminalNotGrounded(0))
111 (**mIntfVoltage)(0, 0) =
112 (**mIntfVoltage)(0, 0) -
113 Math::realFromVectorElement(leftVector, matrixNodeIndex(0));
117 (**mIntfCurrent)(0, 0) = mEquivCond * (**mIntfVoltage)(0, 0) + mEquivCurrent;
void mnaCompUpdateVoltage(const Matrix &leftVector) override
Update interface voltage from MNA system result.
void mnaCompInitialize(Real omega, Real timeStep, Attribute< Matrix >::Ptr leftVector) override
Initializes internal variables of the component.
Inductor(String uid, String name, Logger::Level logLevel=Logger::Level::off)
Defines UID, name, component parameters and logging level.
SimPowerComp< Real >::Ptr clone(String name) override
Returns a modified copy of the component with the given suffix added to the name and without.
void mnaCompAddPreStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes) override
Add MNA pre step dependencies.
void mnaCompApplyRightSideVectorStamp(Matrix &rightVector) override
Stamps right side (source) vector.
void mnaCompUpdateCurrent(const Matrix &leftVector) override
Update interface current from MNA system result.
void mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix) override
Stamps system matrix.
void mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute< Matrix >::Ptr &leftVector) override
Add MNA post step dependencies.
void initializeFromNodesAndTerminals(Real frequency) override
Initializes component from power flow data.
Real mEquivCurrent
DC equivalent current source [A].
Base class for all MNA components that are transmitting power.
Base class for all components that are transmitting power.
const Attribute< MatrixVar< Real > >::Ptr mIntfCurrent
Current through component.
const Attribute< MatrixVar< Real > >::Ptr mIntfVoltage
Voltage between terminals.