20 mUseSubcomponents(useSubcomponents),
24 SPDLOG_LOGGER_INFO(
mSLog,
"Create {} of type {}", this->
type(), name);
31 SPDLOG_LOGGER_INFO(
mSLog,
"Conductance={} [S] Susceptance={} [Ohm] ",
32 conductance, susceptance);
40 Real omega = 2. *
PI * frequency;
43 (**mIntfCurrent)(0, 0) = (**
mIntfVoltage)(0, 0) * admittance;
51 mSubResistor->initializeFromNodesAndTerminals(frequency);
58 if (mUseSubcomponents) {
72 SPDLOG_LOGGER_INFO(
mSLog,
73 "\n--- Initialization from powerflow ---"
74 "\nVoltage across: {:s}"
76 "\nTerminal voltage: {:s}"
77 "\n--- Initialization from powerflow finished ---",
85 mDirectEquivCond = MatrixComp::Zero(
mNumFreqs, 1);
86 mDirectPrevVoltCoeff = MatrixComp::Zero(
mNumFreqs, 1);
87 mDirectCapCurrent = MatrixComp::Zero(
mNumFreqs, 1);
88 mDirectHistory = MatrixComp::Zero(
mNumFreqs, 1);
89 if (mUseSubcomponents || mDirectCapacitance <= 0.)
93 const Real capacitiveConductance = 2. * mDirectCapacitance / timeStep;
94 const Real harmonicSusceptance =
96 mDirectEquivCond(freq, 0) =
97 Complex(capacitiveConductance, harmonicSusceptance);
98 mDirectPrevVoltCoeff(freq, 0) =
99 Complex(capacitiveConductance, -harmonicSusceptance);
101 mDirectCapCurrent(freq, 0) =
103 (**mIntfVoltage)(0, 0);
109 if (mUseSubcomponents)
121 if (mUseSubcomponents || mDirectCapacitance <= 0.)
125 -mDirectCapCurrent(freq, 0) -
126 mDirectPrevVoltCoeff(freq, 0) * (**mIntfVoltage)(0, freq);
127 mDirectHistory(freq, 0) = history;
138 if (!mUseSubcomponents) {
154 attributeDependencies.push_back(leftVector);
172 if (!mUseSubcomponents) {
174 const Complex voltage = (**mIntfVoltage)(0, freq);
176 mDirectCapacitance > 0.
177 ? mDirectEquivCond(freq, 0) * voltage + mDirectHistory(freq, 0)
179 mDirectCapCurrent(freq, 0) = capCurrent;
180 (**mIntfCurrent)(0, freq) =
186 (**mIntfCurrent)(0, 0) = 0;
188 (**mIntfCurrent)(0, 0) +=
mSubResistor->intfCurrent()(0, 0);
190 (**mIntfCurrent)(0, 0) +=
mSubCapacitor->intfCurrent()(0, 0);
AttributePointer< Attribute< T > > Ptr
void addMNASubComponent(typename SimPowerComp< Complex >::Ptr subc, MNA_SUBCOMP_TASK_ORDER preStepOrder, MNA_SUBCOMP_TASK_ORDER postStepOrder, Bool contributeToRightVector)
void mnaCompApplyRightSideVectorStamp(Matrix &rightVector) override
CompositePowerComp(String uid, String name, Bool hasPreStep, Bool hasPostStep, Logger::Level logLevel)
void initializeParentFromNodesAndTerminals(Real frequency) override
Initializes component from power flow data.
void mnaCompUpdateCurrent(const Matrix &leftVector) final
Updates internal current variable of the component.
const Attribute< Real >::Ptr mConductance
Conductance [S].
void mnaParentPreStep(Real time, Int timeStepCount) final
MNA pre step operations.
void mnaParentApplySystemMatrixStamp(SparseMatrixRow &systemMatrix) override
const Attribute< Real >::Ptr mSusceptance
Susceptance [S].
void mnaCompUpdateVoltage(const Matrix &leftVector) final
Updates internal voltage variable of the component.
void mnaParentApplyRightSideVectorStamp(Matrix &rightVector) override
std::shared_ptr< Resistor > mSubResistor
Resistor between terminal and ground.
void setParameters(Real conductance, Real susceptance)
Set shunt specific parameters.
Shunt(String uid, String name, Logger::Level logLevel=Logger::Level::off)
Defines UID, name, component parameters and logging level.
std::shared_ptr< Capacitor > mSubCapacitor
Capacitor between terminal and ground.
void mnaParentInitialize(Real omega, Real timeStep, Attribute< Matrix >::Ptr leftVector) override
void mnaParentPostStep(Real time, Int timeStepCount, Attribute< Matrix >::Ptr &leftVector) final
MNA post-step operations.
void mnaParentAddPreStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes) final
Add MNA pre step dependencies.
void mnaParentAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute< Matrix >::Ptr &leftVector) final
add MNA post-step dependencies
const Attribute< String >::Ptr mName
Human readable name.
String uid()
Returns unique id.
String type()
Get component type (cross-platform)
AttributeList::Ptr mAttributes
Attribute List.
spdlog::level::level_enum Level
static String phasorToString(const Complex &num)
void mnaUpdateCurrent(const Matrix &leftVector) final
void mnaUpdateVoltage(const Matrix &leftVector) final
Attribute< Matrix >::Ptr mRightVector
static void stampAdmittance(Complex admittance, 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)
UInt matrixNodeIndex(UInt nodeIndex)
const Attribute< MatrixVar< Complex > >::Ptr mIntfCurrent
SimTerminal< Complex >::List mTerminals
const Attribute< MatrixVar< Complex > >::Ptr mIntfVoltage
Bool terminalNotGrounded(UInt index)
Complex initialSingleVoltage(UInt index)
void setTerminalNumber(UInt num)
Logger::Level mLogLevel
Component logger control for internal variables.
bool mParametersSet
Flag indicating that parameters are set via setParameters() function.
Logger::Log mSLog
Component logger.
Eigen::Matrix< Real, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor > Matrix
Dense matrix for real numbers.
std::complex< Real > Complex
Eigen::SparseMatrix< Real, Eigen::RowMajor > SparseMatrixRow
Sparse matrix for real numbers (row major).