19 Bool useSubcomponents,
57 const Real omega = 2. *
PI * frequency;
62 const Real reactance =
74 std::abs(voltage) > 0.
78 const Real switchResistance =
80 mVirtualNodes[0]->setInitialVoltage(voltage - switchResistance * current);
81 (**mIntfVoltage)(0, 0) = voltage;
82 (**mIntfCurrent)(0, 0) = current;
99 const Complex initialCurrent = std::abs(terminalVoltage) > 0.
100 ? std::conj(loadPower / terminalVoltage)
102 const Real initialSwitchResistance =
105 initialSwitchResistance * initialCurrent);
109 (**mIntfVoltage)(0, 0) =
virtualNode(0)->initialSingleVoltage();
110 (**mIntfCurrent)(0, 0) = initialCurrent;
112 SPDLOG_LOGGER_INFO(
mSLog,
113 "\n--- Initialization from powerflow ---"
114 "\nVoltage across: {:s}"
116 "\nTerminal 0 voltage: {:s}"
117 "\n--- Initialization from powerflow finished ---",
125 Real closedResistance,
Bool closed) {
140 mSubRXLoad->setParameters(activePower, reactivePower, nomVolt);
141 mSubSwitch->setParameters(openResistance, closedResistance, closed);
145 Real closedResistance,
156 mSubSwitch->setParameters(openResistance, closedResistance, closed);
169 const Real switchResistance =
173 (**mIntfVoltage)(0, freq) -
177 (**mIntfCurrent)(0, freq) -
181 const Real b = timeStep * harmonicOmega / 2.;
184 Complex(a / (1. + b * b), -a * b / (1. + b * b));
186 Complex((1. - b * b) / (1. + b * b), -2. * b / (1. + b * b));
203 (**mIntfVoltage)(0, freq) -
226 const Real resistance =
234 mSubRXLoad->mnaApplySystemMatrixStamp(systemMatrix);
235 mSubSwitch->mnaCompApplySwitchSystemMatrixStamp(closed, systemMatrix,
258 attributeDependencies.push_back(leftVector);
276 (**mIntfCurrent)(0, freq) =
304 SPDLOG_LOGGER_INFO(
mSLog,
"Opened Switch at {}", (
float)time);
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 mnaParentInitialize(Real omega, Real timeStep, Attribute< Matrix >::Ptr leftVector) override
MatrixComp mDirectBranchCurrent
void mnaParentApplyRightSideVectorStamp(Matrix &rightVector) override
void updateSwitchState(Real time)
built-in logic for protection switch
void initializeParentFromNodesAndTerminals(Real frequency) override
Derives values from power flow data and pushes them to subcomponents.
void setParameters(Real activePower, Real reactivePower, Real nomVolt, Real openResistance, Real closedResistance, Bool closed=false)
Sets model specific parameters.
Real mDirectOpenResistance
Real mDirectPreviousSwitchResistance
Real mSwitchTimeOffset
internal switch is only opened after this time offset
MatrixComp mDirectBranchVoltage
Real mDirectClosedResistance
Bool mDirectSwitchChanged
void mnaCompApplySwitchSystemMatrixStamp(Bool closed, SparseMatrixRow &systemMatrix, Int freqIdx) override
Stamps system matrix considering the defined switch position.
void setSwitchParameters(Real openResistance, Real closedResistance, Bool closed=false)
Sets only switch parameters so that load parameters could be calculated from powerflow.
RXLoadSwitch(String uid, String name, Logger::Level logLevel=Logger::Level::off)
Defines UID, name and logging level.
MatrixComp mDirectHistory
void mnaParentAddPreStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes) override
Add MNA pre step dependencies.
MatrixComp mDirectPreviousVoltageFactor
void mnaParentAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute< Matrix >::Ptr &leftVector) override
Add MNA post step dependencies.
Bool mnaIsClosed() override
Check if switch is closed.
MatrixComp mDirectPreviousCurrentFactor
Bool hasParameterChanged() override
Returns true if one of the element paramters has changed.
void mnaParentPreStep(Real time, Int timeStepCount) override
MNA pre step operations.
MatrixComp mDirectEquivalentConductance
Real mDirectReactivePower
void mnaParentPostStep(Real time, Int timeStepCount, Attribute< Matrix >::Ptr &leftVector) override
MNA post step operations.
Bool mDirectParametersSet
std::shared_ptr< DP::Ph1::RXLoad > mSubRXLoad
Internal RXLoad.
std::shared_ptr< DP::Ph1::Switch > mSubSwitch
Internal protection switch.
const Attribute< String >::Ptr mName
Human readable name.
String uid()
Returns unique id.
spdlog::level::level_enum Level
static String phasorToString(const Complex &num)
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)
static Real abs(Complex value)
UInt matrixNodeIndex(UInt nodeIndex)
const Attribute< MatrixVar< Complex > >::Ptr mIntfCurrent
SimTerminal< Complex >::List mTerminals
SimNode< Complex >::Ptr node(UInt index)
void setVirtualNodeNumber(UInt num)
const Attribute< MatrixVar< Complex > >::Ptr mIntfVoltage
SimNode< Complex >::Ptr virtualNode(UInt index)
SimNode< Complex >::List mVirtualNodes
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).