9#include <dpsim-models/EMT/EMT_Ph3_SeriesResistor.h>
17 Logger::Level logLevel)
21 mPhaseType = PhaseType::ABC;
26 auto copy = SeriesResistor::make(name,
mLogLevel);
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();
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 ---",
50 Logger::phasorMatrixToString(initialVoltage(0)),
51 Logger::phasorMatrixToString(initialVoltage(1)));
55 Real omega, Real timeStep, Attribute<Matrix>::Ptr leftVector) {
61 SparseMatrixRow &systemMatrix) {
65 if (terminalNotGrounded(0))
68 if (terminalNotGrounded(1))
72 if (terminalNotGrounded(0) && terminalNotGrounded(1)) {
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,
97 Attribute<Matrix>::Ptr &leftVector) {
99 attributeDependencies.push_back(leftVector);
104void EMT::Ph3::SeriesResistor::mnaCompPostStep(
105 Real time, Int timeStepCount, Attribute<Matrix>::Ptr &leftVector) {
106 mnaCompUpdateVoltage(**leftVector);
107 mnaCompUpdateCurrent(**leftVector);
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) =
124 Math::realFromVectorElement(leftVector, matrixNodeIndex(0, 0));
125 (**mIntfVoltage)(1, 0) =
127 Math::realFromVectorElement(leftVector, matrixNodeIndex(0, 1));
128 (**mIntfVoltage)(2, 0) =
130 Math::realFromVectorElement(leftVector, matrixNodeIndex(0, 2));
const CPS::Attribute< Real >::Ptr mResistance
Resistance [ohm].
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.
String uid()
Returns unique id.
AttributeList::Ptr mAttributes
Attribute List.
MNASimPowerComp(String uid, String name, Bool hasPreStep, Bool hasPostStep, Logger::Level logLevel)
Attribute< Matrix >::Ptr mRightVector
const Attribute< MatrixVar< Real > >::Ptr mIntfCurrent
const Attribute< MatrixVar< Real > >::Ptr mIntfVoltage
void updateMatrixNodeIndices()
std::vector< UInt > matrixNodeIndices(UInt index)
Logger::Level mLogLevel
Component logger control for internal variables.
Logger::Log mSLog
Component logger.