41 Matrix mResistanceInv = Matrix::Zero(3, 3);
45 SPDLOG_LOGGER_INFO(
mSLog,
46 "\nResistance [Ohm]: {:s}"
47 "\nConductance [S]: {:s}",
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 ---",
73 conductance = (**mResistance).inverse();
79 SPDLOG_LOGGER_INFO(
mSLog,
"\nConductance matrix: {:s}",
88 attributeDependencies.push_back(leftVector);
103 (**mIntfVoltage)(0, 0) =
105 (**mIntfVoltage)(1, 0) =
107 (**mIntfVoltage)(2, 0) =
111 (**mIntfVoltage)(0, 0) =
114 (**mIntfVoltage)(1, 0) =
117 (**mIntfVoltage)(2, 0) =
121 SPDLOG_LOGGER_DEBUG(
mSLog,
"\nVoltage: {:s}",
127 Matrix resistanceInv = Matrix::Zero(3, 3);
130 SPDLOG_LOGGER_DEBUG(
mSLog,
"\nCurrent: {:s}",
138 conductance.real() = (**mResistance).inverse();
141 1. / conductance(0, 0).real());
143 1. / conductance(1, 1).real());
145 1. / conductance(2, 2).real());
AttributePointer< Attribute< T > > Ptr
const CPS::Attribute< Matrix >::Ptr mResistance
Resistance [ohm].
void initializeFromNodesAndTerminals(Real frequency) override
Initializes component from power flow data.
void mnaCompPostStep(Real time, Int timeStepCount, Attribute< Matrix >::Ptr &leftVector) override
MNA pre and post step operations.
void mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute< Matrix >::Ptr &leftVector) override
add MNA pre and post step dependencies
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 mnaTearApplyMatrixStamp(SparseMatrixRow &tearMatrix) override
void mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix) override
Stamps system matrix.
void mnaCompInitialize(Real omega, Real timeStep, Attribute< Matrix >::Ptr leftSideVector) override
Initializes internal variables of the component.
Resistor(String uid, String name, Logger::Level logLevel=Logger::Level::off)
Defines UID, name, component parameters and logging level.
void mnaCompUpdateVoltage(const Matrix &leftVector) override
Update interface voltage from MNA system result.
void mnaCompUpdateCurrent(const Matrix &leftVector) override
Update interface current from MNA system result.
String uid()
Returns unique id.
AttributeList::Ptr mAttributes
Attribute List.
spdlog::level::level_enum Level
static String matrixToString(const Matrix &mat)
static String phasorToString(const Complex &num)
MNASimPowerComp(String uid, String name, Bool hasPreStep, Bool hasPostStep, Logger::Level logLevel)
Attribute< Matrix >::Ptr mRightVector
static void stampConductanceMatrix(const Matrix &conductanceMat, SparseMatrixRow &mat, UInt node1Index, UInt node2Index, Bool isTerminal1NotGrounded, Bool isTerminal2NotGrounded, const Logger::Log &mSLog)
static Real realFromVectorElement(const Matrix &mat, Matrix::Index row)
static void addToMatrixElement(SparseMatrixRow &mat, Matrix::Index row, Matrix::Index column, Complex value, Int maxFreq=1, Int freqIdx=0)
static void invertMatrix(const Matrix &mat, Matrix &matInv)
UInt matrixNodeIndex(UInt nodeIndex)
const Attribute< MatrixVar< Real > >::Ptr mIntfCurrent
const Attribute< MatrixVar< Real > >::Ptr mIntfVoltage
std::shared_ptr< SimPowerComp< VarType > > Ptr
Bool terminalNotGrounded(UInt index)
Complex initialSingleVoltage(UInt index)
void updateMatrixNodeIndices()
void setTerminalNumber(UInt num)
Logger::Level mLogLevel
Component logger control for internal variables.
Logger::Log mSLog
Component logger.
static std::shared_ptr< Resistor > make(Args &&...args)
#define RMS3PH_TO_PEAK1PH
Eigen::Matrix< Real, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor > Matrix
Dense matrix for real numbers.
Eigen::Matrix< Real, rows, cols, Eigen::ColMajor > MatrixFixedSize
Dense matrix for real numbers with fixed dimension.
Eigen::Matrix< Complex, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor > MatrixComp
Dense matrix for complex numbers.
Eigen::Matrix< Complex, rows, cols, Eigen::ColMajor > MatrixFixedSizeComp
Dense matrix for complex numbers with fixed dimension.
Eigen::SparseMatrix< Real, Eigen::RowMajor > SparseMatrixRow
Sparse matrix for real numbers (row major).