DPsim
Loading...
Searching...
No Matches
DP_Ph1_RXLoadSwitch.h
Go to the documentation of this file.
1/* Copyright 2017-2021 Institute for Automation of Complex Power Systems,
2 * EONERC, RWTH Aachen University
3 *
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
7 *********************************************************************************/
8
9#pragma once
10
13
14namespace CPS {
15namespace DP {
16namespace Ph1 {
18class RXLoadSwitch : public CompositePowerComp<Complex>,
19 public MNASwitchInterface,
21 public SharedFactory<RXLoadSwitch> {
22protected:
45 std::shared_ptr<DP::Ph1::RXLoad> mSubRXLoad;
47 std::shared_ptr<DP::Ph1::Switch> mSubSwitch;
51 std::vector<const Matrix *> mRightVectorStamps;
52
53public:
56 Logger::Level logLevel = Logger::Level::off);
57 RXLoadSwitch(String uid, String name, Bool useSubcomponents,
58 Logger::Level logLevel = Logger::Level::off);
60 RXLoadSwitch(String name, Logger::Level logLevel = Logger::Level::off);
61 RXLoadSwitch(String name, Bool useSubcomponents,
62 Logger::Level logLevel = Logger::Level::off)
63 : RXLoadSwitch(name, name, useSubcomponents, logLevel) {}
64
65 // #### General ####
67 void initializeParentFromNodesAndTerminals(Real frequency) override;
68 void mnaParentInitialize(Real omega, Real timeStep,
69 Attribute<Matrix>::Ptr leftVector) override;
70 void mnaParentApplyRightSideVectorStamp(Matrix &rightVector) override;
72 void setParameters(Real activePower, Real reactivePower, Real nomVolt,
73 Real openResistance, Real closedResistance,
74 Bool closed = false);
76 void setSwitchParameters(Real openResistance, Real closedResistance,
77 Bool closed = false);
79 void updateSwitchState(Real time);
80
81 // #### MNA section ####
83 void mnaParentPreStep(Real time, Int timeStepCount) override;
85 void mnaParentPostStep(Real time, Int timeStepCount,
86 Attribute<Matrix>::Ptr &leftVector) override;
89 AttributeBase::List &prevStepDependencies,
90 AttributeBase::List &attributeDependencies,
91 AttributeBase::List &modifiedAttributes) override;
93 void
95 AttributeBase::List &attributeDependencies,
96 AttributeBase::List &modifiedAttributes,
97 Attribute<Matrix>::Ptr &leftVector) override;
98
99 // #### MNA section for switch ####
101 Bool mnaIsClosed() override;
104 SparseMatrixRow &systemMatrix,
105 Int freqIdx) override;
106
107 // #### MNA section for variable component ####
108 Bool hasParameterChanged() override;
109};
110} // namespace Ph1
111} // namespace DP
112} // namespace CPS
std::vector< Ptr > List
Definition Attribute.h:123
AttributePointer< Attribute< T > > Ptr
Definition Attribute.h:249
CompositePowerComp(String uid, String name, Bool hasPreStep, Bool hasPostStep, Logger::Level logLevel)
void mnaParentInitialize(Real omega, Real timeStep, Attribute< Matrix >::Ptr leftVector) override
RXLoadSwitch(String name, Bool useSubcomponents, Logger::Level logLevel=Logger::Level::off)
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 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.
std::vector< const Matrix * > mRightVectorStamps
Right side vectors of subcomponents.
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.
String uid()
Returns unique id.
spdlog::level::level_enum Level
Definition Logger.h:33
MNA interface to be used by switching devices.
MNA interface to be used by elements that require recomputing of the system matrix.
Eigen::Matrix< Real, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor > Matrix
Dense matrix for real numbers.
Definition Definitions.h:79
std::string String
Definition Definitions.h:63
double Real
Definition Definitions.h:60
int Int
Definition Definitions.h:59
Eigen::Matrix< Complex, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor > MatrixComp
Dense matrix for complex numbers.
Definition Definitions.h:82
bool Bool
Definition Definitions.h:62
Eigen::SparseMatrix< Real, Eigen::RowMajor > SparseMatrixRow
Sparse matrix for real numbers (row major).
Definition Definitions.h:72