9#include <dpsim-models/EMT/EMT_Ph3_Resistor.h>
16 mPhaseType = PhaseType::ABC;
23 auto copy = Resistor::make(name,
mLogLevel);
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;
41 Matrix mResistanceInv = Matrix::Zero(3, 3);
45 SPDLOG_LOGGER_INFO(
mSLog,
46 "\nResistance [Ohm]: {:s}"
47 "\nConductance [S]: {:s}",
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 ---",
60 Logger::phasorToString(RMS3PH_TO_PEAK1PH * initialSingleVoltage(0)),
61 Logger::phasorToString(RMS3PH_TO_PEAK1PH * initialSingleVoltage(1)));
65 Attribute<Matrix>::Ptr leftVector) {
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,
87 Attribute<Matrix>::Ptr &leftVector) {
88 attributeDependencies.push_back(leftVector);
94 Attribute<Matrix>::Ptr &leftVector) {
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) =
113 Math::realFromVectorElement(leftVector, matrixNodeIndex(0, 0));
114 (**mIntfVoltage)(1, 0) =
116 Math::realFromVectorElement(leftVector, matrixNodeIndex(0, 1));
117 (**mIntfVoltage)(2, 0) =
119 Math::realFromVectorElement(leftVector, matrixNodeIndex(0, 2));
121 SPDLOG_LOGGER_DEBUG(
mSLog,
"\nVoltage: {:s}",
127 Matrix resistanceInv = Matrix::Zero(3, 3);
130 SPDLOG_LOGGER_DEBUG(
mSLog,
"\nCurrent: {:s}",
const CPS::Attribute< Matrix >::Ptr mResistance
Resistance [ohm].
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.
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()
Logger::Level mLogLevel
Component logger control for internal variables.
Logger::Log mSLog
Component logger.