DPsim
DP_Ph1_RXLoadSwitch.h
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 
11 #include <dpsim-models/DP/DP_Ph1_RXLoad.h>
12 #include <dpsim-models/DP/DP_Ph1_Switch.h>
13 
14 namespace CPS {
15 namespace DP {
16 namespace Ph1 {
18 class RXLoadSwitch : public CompositePowerComp<Complex>,
19  public MNASwitchInterface,
20  public SharedFactory<RXLoadSwitch> {
21 protected:
23  std::shared_ptr<DP::Ph1::RXLoad> mSubRXLoad;
25  std::shared_ptr<DP::Ph1::Switch> mSubSwitch;
27  Real mSwitchTimeOffset = 1.0;
29  std::vector<const Matrix *> mRightVectorStamps;
30 
31 public:
33  RXLoadSwitch(String uid, String name,
34  Logger::Level logLevel = Logger::Level::off);
36  RXLoadSwitch(String name, Logger::Level logLevel = Logger::Level::off);
37 
38  // #### General ####
40  void initializeFromNodesAndTerminals(Real frequency) override;
42  void setParameters(Real activePower, Real reactivePower, Real nomVolt,
43  Real openResistance, Real closedResistance,
44  Bool closed = false);
46  void setSwitchParameters(Real openResistance, Real closedResistance,
47  Bool closed = false);
49  void updateSwitchState(Real time);
50 
51  // #### MNA section ####
53  void mnaParentPreStep(Real time, Int timeStepCount) override;
55  void mnaParentPostStep(Real time, Int timeStepCount,
56  Attribute<Matrix>::Ptr &leftVector) override;
59  AttributeBase::List &prevStepDependencies,
60  AttributeBase::List &attributeDependencies,
61  AttributeBase::List &modifiedAttributes) override;
63  void
64  mnaParentAddPostStepDependencies(AttributeBase::List &prevStepDependencies,
65  AttributeBase::List &attributeDependencies,
66  AttributeBase::List &modifiedAttributes,
67  Attribute<Matrix>::Ptr &leftVector) override;
68 
69  // #### MNA section for switch ####
71  Bool mnaIsClosed() override;
73  void mnaCompApplySwitchSystemMatrixStamp(Bool closed,
74  SparseMatrixRow &systemMatrix,
75  Int freqIdx) override;
76 };
77 } // namespace Ph1
78 } // namespace DP
79 } // namespace CPS
Base class for composite power components.
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.
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.
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.
String uid()
Returns unique id.
MNA interface to be used by switching devices.