31 const Real omega = 2.0 *
PI * frequency;
35 for (
UInt row = 0; row < 3; ++row) {
36 for (
UInt col = 0; col < 3; ++col) {
67 "\n--- Initialization from powerflow ---"
68 "\nDP convention: phase-peak complex envelopes"
73 "\nTerminal 0 PF voltage converted to phase peak: {:s}"
74 "\nTerminal 1 PF voltage converted to phase peak: {:s}"
75 "\n--- Initialization from powerflow finished ---",
83 Matrix a = timeStep / 2.0 * (**mInductance).inverse();
85 const Real b = timeStep * omega / 2.0;
87 Matrix equivCondReal = a / (1.0 + b * b);
89 Matrix equivCondImag = -a * b / (1.0 + b * b);
93 for (
UInt row = 0; row < 3; ++row) {
94 for (
UInt col = 0; col < 3; ++col) {
96 Complex(equivCondReal(row, col), equivCondImag(row, col));
100 const Real preCurrFracReal = (1.0 - b * b) / (1.0 + b * b);
102 const Real preCurrFracImag = (-2.0 * b) / (1.0 + b * b);
116 SPDLOG_LOGGER_INFO(
mSLog,
"Initial phase-A DP voltage envelope: {} < {} rad",
120 SPDLOG_LOGGER_INFO(
mSLog,
"Initial phase-A DP current envelope: {} < {} rad",
177 attributeDependencies.push_back(leftVector);
192 (**mIntfVoltage)(0, 0) =
195 (**mIntfVoltage)(1, 0) =
198 (**mIntfVoltage)(2, 0) =
203 (**mIntfVoltage)(0, 0) -=
206 (**mIntfVoltage)(1, 0) -=
209 (**mIntfVoltage)(2, 0) -=
AttributePointer< Attribute< T > > Ptr
const CPS::Attribute< Matrix >::Ptr mInductance
Inductance [H].
void mnaCompInitialize(Real omega, Real timeStep, Attribute< Matrix >::Ptr leftVector) override
void mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix) override
void initializeFromNodesAndTerminals(Real frequency) override
Initialize DP phase-peak envelopes from line-line RMS PF node voltages.
Complex mPrevCurrFac
Coefficient multiplying the previous current value.
void mnaTearPostStep(MatrixComp voltage, MatrixComp current) override
MatrixComp mEquivCurrent
Equivalent current source [A].
void mnaCompAddPreStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes) override
void mnaCompUpdateVoltage(const Matrix &leftVector) override
Inductor(String uid, String name, Logger::Level logLevel=Logger::Level::off)
void mnaCompUpdateCurrent(const Matrix &leftVector) override
void mnaTearApplyMatrixStamp(SparseMatrixRow &tearMatrix) override
MatrixComp mEquivCond
Equivalent conductance [S].
void initVars(Real omega, Real timeStep)
void mnaTearInitialize(Real omega, Real timestep) override
SimPowerComp< Complex >::Ptr clone(String name) override
Returns a modified copy of the component with the given suffix added to the name and without.
void mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute< Matrix >::Ptr &leftVector) override
void mnaCompApplyRightSideVectorStamp(Matrix &rightVector) override
void mnaCompPreStep(Real time, Int timeStepCount) override
void mnaTearApplyVoltageStamp(Matrix &voltageVector) override
void mnaCompPostStep(Real time, Int timeStepCount, Attribute< Matrix >::Ptr &leftVector) override
String uid()
Returns unique id.
AttributeList::Ptr mAttributes
Attribute List.
spdlog::level::level_enum Level
static String matrixCompToString(const MatrixComp &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 stampAdmittanceMatrix(const MatrixComp &admittanceMat, SparseMatrixRow &mat, UInt node1Index, UInt node2Index, Bool isTerminal1NotGrounded, Bool isTerminal2NotGrounded, const Logger::Log &mSLog, Int maxFreq=1, Int freqIdx=0)
static Complex complexFromVectorElement(const Matrix &mat, Matrix::Index row, Int maxFreq=1, Int freqIdx=0)
static void setVectorElement(Matrix &mat, Matrix::Index row, Complex value, Int maxFreq=1, Int freqIdx=0, Matrix::Index colOffset=0)
static void addToVectorElement(Matrix &mat, Matrix::Index row, Complex value, Int maxFreq=1, Int freqIdx=0)
static Real phase(Complex value)
static Real abs(Complex value)
static void addToMatrixElement(SparseMatrixRow &mat, Matrix::Index row, Matrix::Index column, Complex value, Int maxFreq=1, Int freqIdx=0)
UInt matrixNodeIndex(UInt nodeIndex)
const Attribute< MatrixVar< Complex > >::Ptr mIntfCurrent
const Attribute< MatrixVar< Complex > >::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< Inductor > make(Args &&...args)
#define RMS3PH_TO_PEAK1PH
Eigen::Matrix< Real, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor > Matrix
Dense matrix for real numbers.
std::complex< Real > Complex
Eigen::Matrix< Complex, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor > MatrixComp
Dense matrix for complex numbers.
Eigen::SparseMatrix< Real, Eigen::RowMajor > SparseMatrixRow
Sparse matrix for real numbers (row major).