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);
46 std::abs(
mTerminals[0]->initialSingleVoltage()));
51 mSubRXLoad->initializeFromNodesAndTerminals(frequency);
55 mSubSwitch->initializeFromNodesAndTerminals(frequency);
60 SPDLOG_LOGGER_INFO(
mSLog,
61 "\n--- Initialization from powerflow ---"
62 "\nVoltage across: {:s}"
64 "\nTerminal 0 voltage: {:s}"
65 "\n--- Initialization from powerflow finished ---",
68 Logger::phasorToString(initialSingleVoltage(0)));
72 Real nomVolt, Real openResistance,
73 Real closedResistance, Bool closed) {
75 mSubRXLoad->setParameters(activePower, reactivePower, nomVolt);
76 mSubSwitch->setParameters(openResistance, closedResistance, closed);
80 Real closedResistance,
82 mSubSwitch->setParameters(openResistance, closedResistance, closed);
86 Bool closed, SparseMatrixRow &systemMatrix, Int freqIdx) {
87 mSubRXLoad->mnaApplySystemMatrixStamp(systemMatrix);
88 mSubSwitch->mnaCompApplySwitchSystemMatrixStamp(closed, systemMatrix,
93 AttributeBase::List &prevStepDependencies,
94 AttributeBase::List &attributeDependencies,
95 AttributeBase::List &modifiedAttributes) {
107 AttributeBase::List &prevStepDependencies,
108 AttributeBase::List &attributeDependencies,
109 AttributeBase::List &modifiedAttributes,
110 Attribute<Matrix>::Ptr &leftVector) {
111 attributeDependencies.push_back(leftVector);
117 Real time, Int timeStepCount, Attribute<Matrix>::Ptr &leftVector) {
125 Real VRef = Math::abs(**
mSubRXLoad->mNomVoltage);
128 Real deltaV = Math::abs((V - VRef) / VRef);
132 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 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 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.
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.