9#include <dpsim-models/DP/DP_Ph1_RXLoadSwitch.h>
14 Logger::Level logLevel)
17 setVirtualNodeNumber(1);
27 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
true);
29 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
false);
45 std::abs(
mTerminals[0]->initialSingleVoltage()));
50 mSubRXLoad->initializeFromNodesAndTerminals(frequency);
54 mSubSwitch->initializeFromNodesAndTerminals(frequency);
59 SPDLOG_LOGGER_INFO(
mSLog,
60 "\n--- Initialization from powerflow ---"
61 "\nVoltage across: {:s}"
63 "\nTerminal 0 voltage: {:s}"
64 "\n--- Initialization from powerflow finished ---",
67 Logger::phasorToString(initialSingleVoltage(0)));
71 Real nomVolt, Real openResistance,
72 Real closedResistance, Bool closed) {
74 mSubRXLoad->setParameters(activePower, reactivePower, nomVolt);
75 mSubSwitch->setParameters(openResistance, closedResistance, closed);
79 Real closedResistance,
81 mSubSwitch->setParameters(openResistance, closedResistance, closed);
85 Bool closed, SparseMatrixRow &systemMatrix, Int freqIdx) {
86 mSubRXLoad->mnaApplySystemMatrixStamp(systemMatrix);
87 mSubSwitch->mnaCompApplySwitchSystemMatrixStamp(closed, systemMatrix,
92 AttributeBase::List &prevStepDependencies,
93 AttributeBase::List &attributeDependencies,
94 AttributeBase::List &modifiedAttributes) {
106 AttributeBase::List &prevStepDependencies,
107 AttributeBase::List &attributeDependencies,
108 AttributeBase::List &modifiedAttributes,
109 Attribute<Matrix>::Ptr &leftVector) {
110 attributeDependencies.push_back(leftVector);
116 Real time, Int timeStepCount, Attribute<Matrix>::Ptr &leftVector) {
124 Real VRef = Math::abs(**
mSubRXLoad->mNomVoltage);
127 Real deltaV = Math::abs((V - VRef) / VRef);
131 SPDLOG_LOGGER_INFO(
mSLog,
"Opened Switch at {}", (
float)time);
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 updateSwitchState(Real time)
built-in logic for protection switch
void setParameters(Real activePower, Real reactivePower, Real nomVolt, Real openResistance, Real closedResistance, Bool closed=false)
Sets model specific parameters.
Real mSwitchTimeOffset
internal switch is only opened after this time offset
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.
void mnaParentAddPreStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes) override
Add MNA pre step dependencies.
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.
Bool hasParameterChanged() override
Returns true if one of the element paramters has changed.
void mnaParentPreStep(Real time, Int timeStepCount) override
MNA pre step operations.
void mnaParentPostStep(Real time, Int timeStepCount, Attribute< Matrix >::Ptr &leftVector) override
MNA post step operations.
std::shared_ptr< DP::Ph1::RXLoad > mSubRXLoad
Internal RXLoad.
void initializeFromNodesAndTerminals(Real frequency) override
Initializes component from power flow data.
std::shared_ptr< DP::Ph1::Switch > mSubSwitch
Internal protection switch.
const Attribute< String >::Ptr mName
Human readable name.
String uid()
Returns unique id.
Attribute< Matrix >::Ptr mRightVector
const Attribute< MatrixVar< Complex > >::Ptr mIntfCurrent
SimTerminal< Complex >::List mTerminals
SimNode< Complex >::Ptr node(UInt index)
const Attribute< MatrixVar< Complex > >::Ptr mIntfVoltage
SimNode< Complex >::Ptr virtualNode(UInt index)
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.