31 Real omega = 2 *
PI * frequency;
48 (**mIntfVoltage)(1, 0) =
Complex(voltMag * cos(voltPhase - 2. / 3. *
M_PI),
49 voltMag * sin(voltPhase - 2. / 3. *
M_PI));
50 (**mIntfVoltage)(2, 0) =
Complex(voltMag * cos(voltPhase + 2. / 3. *
M_PI),
51 voltMag * sin(voltPhase + 2. / 3. *
M_PI));
56 SPDLOG_LOGGER_INFO(
mSLog,
"--- Initialize according to power flow ---");
60 Matrix a = timeStep / 2. * (**mInductance).inverse();
61 Real b = timeStep * omega / 2.;
63 Matrix equivCondReal = a / (1. + b * b);
64 Matrix equivCondImag = -a * b / (
Real(1.) + b * b);
67 Complex(equivCondReal(0, 1), equivCondImag(0, 1)),
68 Complex(equivCondReal(0, 2), equivCondImag(0, 2)),
69 Complex(equivCondReal(1, 0), equivCondImag(1, 0)),
70 Complex(equivCondReal(1, 1), equivCondImag(1, 1)),
71 Complex(equivCondReal(1, 2), equivCondImag(1, 2)),
72 Complex(equivCondReal(2, 0), equivCondImag(2, 0)),
73 Complex(equivCondReal(2, 1), equivCondImag(2, 1)),
74 Complex(equivCondReal(2, 2), equivCondImag(2, 2));
76 Real preCurrFracReal = (1. - b * b) / (1. + b * b);
77 Real preCurrFracImag = (-2. * b) / (1. + b * b);
89 SPDLOG_LOGGER_INFO(
mSLog,
"Initial voltage {}",
142 attributeDependencies.push_back(leftVector);
157 (**mIntfVoltage)(0, 0) =
159 (**mIntfVoltage)(1, 0) =
161 (**mIntfVoltage)(2, 0) =
165 (**mIntfVoltage)(0, 0) =
168 (**mIntfVoltage)(1, 0) =
171 (**mIntfVoltage)(2, 0) =
209 (**mIntfVoltage) = voltage;
AttributePointer< Attribute< T > > Ptr
const CPS::Attribute< Matrix >::Ptr mInductance
Inductance [H].
void mnaCompInitialize(Real omega, Real timeStep, Attribute< Matrix >::Ptr leftVector) override
Initializes internal variables of the component.
void mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix) override
Stamps system matrix.
void initializeFromNodesAndTerminals(Real frequency) override
Initializes component from power flow data.
Complex mPrevCurrFac
Coefficient in front of previous current value.
void mnaTearPostStep(MatrixComp voltage, MatrixComp current) override
MatrixComp mEquivCurrent
DC equivalent current source [A].
void mnaCompAddPreStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes) override
Add MNA pre step dependencies.
void mnaCompUpdateVoltage(const Matrix &leftVector) override
Update interface voltage from MNA system result.
Inductor(String uid, String name, Logger::Level logLevel=Logger::Level::off)
Defines UID, name, component parameters and logging level.
void mnaCompUpdateCurrent(const Matrix &leftVector) override
Update interface current from MNA system result.
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
Add MNA post step dependencies.
void mnaCompApplyRightSideVectorStamp(Matrix &rightVector) override
Stamps right side (source) vector.
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
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)
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).