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);
41 if (!mParametersSet) {
43 mSubRXLoad->setParameters(mTerminals[0]->singleActivePower(),
44 mTerminals[0]->singleReactivePower(),
45 std::abs(mTerminals[0]->initialSingleVoltage()));
48 mSubRXLoad->connect({virtualNode(0)});
49 mSubRXLoad->initialize(mFrequencies);
50 mSubRXLoad->initializeFromNodesAndTerminals(frequency);
52 mSubSwitch->connect({node(0)});
53 mSubSwitch->initialize(mFrequencies);
54 mSubSwitch->initializeFromNodesAndTerminals(frequency);
56 **mIntfVoltage = **mSubRXLoad->mIntfVoltage;
57 **mIntfCurrent = **mSubRXLoad->mIntfCurrent;
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 ---",
65 Logger::phasorToString((**mIntfVoltage)(0, 0)),
66 Logger::phasorToString((**mIntfCurrent)(0, 0)),
67 Logger::phasorToString(initialSingleVoltage(0)));
71 Real nomVolt, Real openResistance,
72 Real closedResistance, Bool closed) {
73 mParametersSet =
true;
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) {
95 prevStepDependencies.push_back(mIntfCurrent);
96 prevStepDependencies.push_back(mIntfVoltage);
97 modifiedAttributes.push_back(mRightVector);
101 updateSwitchState(time);
102 mnaCompApplyRightSideVectorStamp(**mRightVector);
106 AttributeBase::List &prevStepDependencies,
107 AttributeBase::List &attributeDependencies,
108 AttributeBase::List &modifiedAttributes,
110 attributeDependencies.push_back(leftVector);
111 modifiedAttributes.push_back(mIntfVoltage);
112 modifiedAttributes.push_back(mIntfCurrent);
117 **mIntfVoltage = **mSubRXLoad->mIntfVoltage;
118 **mIntfCurrent = **mSubRXLoad->mIntfCurrent;
123 if (time > mSwitchTimeOffset && mSubSwitch->isClosed()) {
124 Real VRef = Math::abs(**mSubRXLoad->mNomVoltage);
125 Real V = Math::abs((**mIntfVoltage)(0, 0));
127 Real deltaV = Math::abs((V - VRef) / VRef);
131 SPDLOG_LOGGER_INFO(mSLog,
"Opened Switch at {}", (
float)time);
Base class for composite power components.
void addMNASubComponent(typename SimPowerComp< Complex >::Ptr subc, MNA_SUBCOMP_TASK_ORDER preStepOrder, MNA_SUBCOMP_TASK_ORDER postStepOrder, Bool contributeToRightVector)
Add a new subcomponent implementing MNA methods.
Constant impedance load model consisting of RLC elements.
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.
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.
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.
const Attribute< MatrixVar< Complex > >::Ptr mIntfCurrent
Current through component.
const Attribute< MatrixVar< Complex > >::Ptr mIntfVoltage
Voltage between terminals.
Logger::Level mLogLevel
Component logger control for internal variables.