9 #include <dpsim-models/EMT/EMT_Ph3_Resistor.h>
16 mPhaseType = PhaseType::ABC;
23 auto copy = Resistor::make(name, mLogLevel);
24 copy->setParameters(**mResistance);
31 MatrixComp vInitABC = Matrix::Zero(3, 1);
32 vInitABC(0, 0) = RMS3PH_TO_PEAK1PH * initialSingleVoltage(1) -
33 RMS3PH_TO_PEAK1PH * initialSingleVoltage(0);
34 vInitABC(1, 0) = vInitABC(0, 0) * SHIFT_TO_PHASE_B;
35 vInitABC(2, 0) = vInitABC(0, 0) * SHIFT_TO_PHASE_C;
36 **mIntfVoltage = vInitABC.real();
41 Matrix mResistanceInv = Matrix::Zero(3, 3);
42 Math::invertMatrix(**mResistance, mResistanceInv);
43 **mIntfCurrent = (mResistanceInv * vInitABC).real();
45 SPDLOG_LOGGER_INFO(mSLog,
46 "\nResistance [Ohm]: {:s}"
47 "\nConductance [S]: {:s}",
48 Logger::matrixToString(**mResistance),
49 Logger::matrixToString(mResistanceInv));
52 "\n--- Initialization from powerflow ---"
53 "\nVoltage across: {:s}"
55 "\nTerminal 0 voltage: {:s}"
56 "\nTerminal 1 voltage: {:s}"
57 "\n--- Initialization from powerflow finished ---",
58 Logger::matrixToString(**mIntfVoltage),
59 Logger::matrixToString(**mIntfCurrent),
60 Logger::phasorToString(RMS3PH_TO_PEAK1PH * initialSingleVoltage(0)),
61 Logger::phasorToString(RMS3PH_TO_PEAK1PH * initialSingleVoltage(1)));
66 updateMatrixNodeIndices();
67 **mRightVector = Matrix::Zero(0, 0);
71 SparseMatrixRow &systemMatrix) {
72 MatrixFixedSize<3, 3> conductance = Matrix::Zero(3, 3);
73 conductance = (**mResistance).inverse();
75 MNAStampUtils::stampConductanceMatrix(
76 conductance, systemMatrix, matrixNodeIndex(0), matrixNodeIndex(1),
77 terminalNotGrounded(0), terminalNotGrounded(1), mSLog);
79 SPDLOG_LOGGER_INFO(mSLog,
"\nConductance matrix: {:s}",
80 Logger::matrixToString(conductance));
84 AttributeBase::List &prevStepDependencies,
85 AttributeBase::List &attributeDependencies,
86 AttributeBase::List &modifiedAttributes,
88 attributeDependencies.push_back(leftVector);
89 modifiedAttributes.push_back(mIntfVoltage);
90 modifiedAttributes.push_back(mIntfCurrent);
95 mnaCompUpdateVoltage(**leftVector);
96 mnaCompUpdateCurrent(**leftVector);
101 **mIntfVoltage = Matrix::Zero(3, 1);
102 if (terminalNotGrounded(1)) {
103 (**mIntfVoltage)(0, 0) =
104 Math::realFromVectorElement(leftVector, matrixNodeIndex(1, 0));
105 (**mIntfVoltage)(1, 0) =
106 Math::realFromVectorElement(leftVector, matrixNodeIndex(1, 1));
107 (**mIntfVoltage)(2, 0) =
108 Math::realFromVectorElement(leftVector, matrixNodeIndex(1, 2));
110 if (terminalNotGrounded(0)) {
111 (**mIntfVoltage)(0, 0) =
112 (**mIntfVoltage)(0, 0) -
113 Math::realFromVectorElement(leftVector, matrixNodeIndex(0, 0));
114 (**mIntfVoltage)(1, 0) =
115 (**mIntfVoltage)(1, 0) -
116 Math::realFromVectorElement(leftVector, matrixNodeIndex(0, 1));
117 (**mIntfVoltage)(2, 0) =
118 (**mIntfVoltage)(2, 0) -
119 Math::realFromVectorElement(leftVector, matrixNodeIndex(0, 2));
121 SPDLOG_LOGGER_DEBUG(mSLog,
"\nVoltage: {:s}",
122 Logger::matrixToString(**mIntfVoltage));
127 Matrix resistanceInv = Matrix::Zero(3, 3);
128 Math::invertMatrix(**mResistance, resistanceInv);
129 **mIntfCurrent = resistanceInv * **mIntfVoltage;
130 SPDLOG_LOGGER_DEBUG(mSLog,
"\nCurrent: {:s}",
131 Logger::matrixToString(**mIntfCurrent));
void initializeFromNodesAndTerminals(Real frequency)
Initializes component from power flow data.
void mnaCompUpdateCurrent(const Matrix &leftVector)
Update interface current from MNA system result.
void mnaCompInitialize(Real omega, Real timeStep, Attribute< Matrix >::Ptr leftSideVector)
Initializes internal variables of the component.
void mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute< Matrix >::Ptr &leftVector)
add MNA pre and post step dependencies
void mnaCompUpdateVoltage(const Matrix &leftVector)
Update interface voltage from MNA system result.
void mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix)
Stamps system matrix.
SimPowerComp< Real >::Ptr clone(String name)
Returns a modified copy of the component with the given suffix added to the name and without.
void mnaCompPostStep(Real time, Int timeStepCount, Attribute< Matrix >::Ptr &leftVector)
MNA pre and post step operations.
Resistor(String uid, String name, Logger::Level logLevel=Logger::Level::off)
Defines UID, name, component parameters and logging level.
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.