9 #include <dpsim-models/EMT/EMT_Ph3_SeriesResistor.h>
17 Logger::Level logLevel)
21 mPhaseType = PhaseType::ABC;
26 auto copy = SeriesResistor::make(name, mLogLevel);
27 copy->setParameters(**mResistance);
33 Complex phasorA = initialSingleVoltage(1) - initialSingleVoltage(0);
34 (**mIntfVoltage)(0, 0) = phasorA.real();
35 Complex alpha(cos(2. / 3. * PI), sin(2. / 3. * PI));
36 (**mIntfVoltage)(1, 0) = Complex(phasorA * pow(alpha, 2)).real();
37 (**mIntfVoltage)(2, 0) = Complex(phasorA * alpha).real();
39 **mIntfCurrent = **mIntfVoltage / **mResistance;
41 SPDLOG_LOGGER_INFO(mSLog,
42 "\n--- Initialization from powerflow ---"
43 "\nVoltage across amplitude and phase: \n{}"
44 "\nCurrent amplitude and phase: \n{}"
45 "\nTerminal 0 voltage amplitude and phase: \n{}"
46 "\nTerminal 1 voltage amplitude and phase: \n{}"
47 "\n--- Initialization from powerflow finished ---",
48 Logger::phasorMatrixToString(**mIntfVoltage),
49 Logger::phasorMatrixToString(**mIntfCurrent),
50 Logger::phasorMatrixToString(initialVoltage(0)),
51 Logger::phasorMatrixToString(initialVoltage(1)));
56 updateMatrixNodeIndices();
57 **mRightVector = Matrix::Zero(0, 0);
61 SparseMatrixRow &systemMatrix) {
62 Real conductance = 1. / **mResistance;
65 if (terminalNotGrounded(0))
66 Math::addToMatrixElement(systemMatrix, matrixNodeIndices(0),
67 matrixNodeIndices(0), conductance);
68 if (terminalNotGrounded(1))
69 Math::addToMatrixElement(systemMatrix, matrixNodeIndices(1),
70 matrixNodeIndices(1), conductance);
72 if (terminalNotGrounded(0) && terminalNotGrounded(1)) {
73 Math::addToMatrixElement(systemMatrix, matrixNodeIndices(0),
74 matrixNodeIndices(1), -conductance);
75 Math::addToMatrixElement(systemMatrix, matrixNodeIndices(1),
76 matrixNodeIndices(0), -conductance);
79 if (terminalNotGrounded(0))
80 SPDLOG_LOGGER_INFO(mSLog,
"Add {} to {}, {}", conductance,
81 matrixNodeIndex(0, 0), matrixNodeIndex(0, 0));
82 if (terminalNotGrounded(1))
83 SPDLOG_LOGGER_INFO(mSLog,
"Add {} to {}, {}", conductance,
84 matrixNodeIndex(1, 0), matrixNodeIndex(1, 0));
85 if (terminalNotGrounded(0) && terminalNotGrounded(1)) {
86 SPDLOG_LOGGER_INFO(mSLog,
"Add {} to {}, {}", -conductance,
87 matrixNodeIndex(0, 0), matrixNodeIndex(1, 0));
88 SPDLOG_LOGGER_INFO(mSLog,
"Add {} to {}, {}", -conductance,
89 matrixNodeIndex(1, 0), matrixNodeIndex(0, 0));
94 AttributeBase::List &prevStepDependencies,
95 AttributeBase::List &attributeDependencies,
96 AttributeBase::List &modifiedAttributes,
99 attributeDependencies.push_back(leftVector);
100 modifiedAttributes.push_back(mIntfVoltage);
101 modifiedAttributes.push_back(mIntfCurrent);
104 void EMT::Ph3::SeriesResistor::mnaCompPostStep(
106 mnaCompUpdateVoltage(**leftVector);
107 mnaCompUpdateCurrent(**leftVector);
112 **mIntfVoltage = Matrix::Zero(3, 1);
113 if (terminalNotGrounded(1)) {
114 (**mIntfVoltage)(0, 0) =
115 Math::realFromVectorElement(leftVector, matrixNodeIndex(1, 0));
116 (**mIntfVoltage)(1, 0) =
117 Math::realFromVectorElement(leftVector, matrixNodeIndex(1, 1));
118 (**mIntfVoltage)(2, 0) =
119 Math::realFromVectorElement(leftVector, matrixNodeIndex(1, 2));
121 if (terminalNotGrounded(0)) {
122 (**mIntfVoltage)(0, 0) =
123 (**mIntfVoltage)(0, 0) -
124 Math::realFromVectorElement(leftVector, matrixNodeIndex(0, 0));
125 (**mIntfVoltage)(1, 0) =
126 (**mIntfVoltage)(1, 0) -
127 Math::realFromVectorElement(leftVector, matrixNodeIndex(0, 1));
128 (**mIntfVoltage)(2, 0) =
129 (**mIntfVoltage)(2, 0) -
130 Math::realFromVectorElement(leftVector, matrixNodeIndex(0, 2));
133 SPDLOG_LOGGER_DEBUG(mSLog,
"Voltage A: {}", (**mIntfVoltage)(0, 0));
137 **mIntfCurrent = **mIntfVoltage / **mResistance;
139 SPDLOG_LOGGER_DEBUG(mSLog,
"Current A: {} < {}", (**mIntfCurrent)(0, 0));
void mnaCompUpdateCurrent(const Matrix &leftVector) override
Update interface voltage from MNA system results.
void mnaCompInitialize(Real omega, Real timeStep, Attribute< Matrix >::Ptr leftVector) override
Initializes MNA specific variables.
void mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute< Matrix >::Ptr &leftVector) override
Add MNA post step dependencies.
SimPowerComp< Real >::Ptr clone(String name) override
Return new instance with the same parameters.
SeriesResistor(String uid, String name, Logger::Level logLevel=Logger::Level::off)
Defines UID, name and log level.
void mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix) override
Stamps system matrix.
void initializeFromNodesAndTerminals(Real frequency) override
Initializes states from power flow data.
void mnaCompUpdateVoltage(const Matrix &leftVector) override
Update interface voltage from MNA system results.
Base class for all MNA components that are transmitting power.
Base class for all components that are transmitting power.