DPsim
Loading...
Searching...
No Matches
DP_Ph1_varResSwitch.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/Base/Base_Ph1_Switch.h>
12#include <dpsim-models/MNASimPowerComp.h>
13#include <dpsim-models/Solver/MNAInterface.h>
14#include <dpsim-models/Solver/MNASwitchInterface.h>
15#include <dpsim-models/Solver/MNAVariableCompInterface.h>
16
17namespace CPS {
18namespace DP {
19namespace Ph1 {
24
27class varResSwitch : public MNASimPowerComp<Complex>,
28 public Base::Ph1::Switch,
30 public MNASwitchInterface,
31 public SharedFactory<varResSwitch> {
32
33protected:
34 Real mDeltaResClosed = 0;
35 Real mDeltaResOpen = 1.5;
36 Real mPrevRes; // previous resistance value to multiply with rate of change
37 // because we change the base value mClosedResistance & mOpenResistance to recompute the system Matrix
38 // we need to save the initialisation values to use them as target values in the transition
39 Real mInitClosedRes;
40 Real mInitOpenRes;
41
42public:
43 void setInitParameters(Real timestep);
44
46 varResSwitch(String uid, String name,
47 Logger::Level logLevel = Logger::Level::off);
49 varResSwitch(String name, Logger::Level logLevel = Logger::Level::off)
50 : varResSwitch(name, name, logLevel) {}
51
52 // varResSwitch(String name, Real openRes, Real closedRes ,
53 // Logger::Level logLevel = Logger::Level::off);
54
55 SimPowerComp<Complex>::Ptr clone(String name);
56
57 // #### General ####
59 void initializeFromNodesAndTerminals(Real frequency);
60
61 // #### MNA section ####
63 void mnaCompInitialize(Real omega, Real timeStep,
64 Attribute<Matrix>::Ptr leftVector);
65 //void mnaCompInitializeHarm(Real omega, Real timeStep, std::vector<Attribute<Matrix>::Ptr> leftVectors);
67 void mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix);
69 void mnaCompApplyRightSideVectorStamp(Matrix &rightVector);
71 void mnaCompUpdateVoltage(const Matrix &leftVector);
73 void mnaCompUpdateCurrent(const Matrix &leftVector);
75 // void mnaCompPreStep(Real time, Int timeStepCount);
77 void mnaCompPostStep(Real time, Int timeStepCount,
78 Attribute<Matrix>::Ptr &leftVector);
82 void
83 mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies,
84 AttributeBase::List &attributeDependencies,
85 AttributeBase::List &modifiedAttributes,
86 Attribute<Matrix>::Ptr &leftVector);
87
88 // #### MNA section for switch ####
90 Bool mnaIsClosed();
93 SparseMatrixRow &systemMatrix,
94 Int freqIdx);
95
96 // #### MNA section for variable component ####
98};
99} // namespace Ph1
100} // namespace DP
101} // namespace CPS
Dynamic Phasor Three-Phase Switch.
SimPowerComp< Complex >::Ptr clone(String name)
Returns a modified copy of the component with the given suffix added to the name and without.
Bool hasParameterChanged()
Returns true if one of the element paramters has changed.
void mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute< Matrix >::Ptr &leftVector)
void initializeFromNodesAndTerminals(Real frequency)
Initializes states from power flow data.
void mnaCompApplySwitchSystemMatrixStamp(Bool closed, SparseMatrixRow &systemMatrix, Int freqIdx)
Stamps system matrix considering the defined switch position.
void mnaCompUpdateCurrent(const Matrix &leftVector)
Update interface current from MNA system results.
void mnaCompUpdateVoltage(const Matrix &leftVector)
Update interface voltage from MNA system results.
varResSwitch(String name, Logger::Level logLevel=Logger::Level::off)
Defines name and log level.
void mnaCompApplyRightSideVectorStamp(Matrix &rightVector)
Stamps right side (source) vector.
void mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix)
Stamps system matrix.
varResSwitch(String uid, String name, Logger::Level logLevel=Logger::Level::off)
Defines UID, name and log level.
void mnaCompInitialize(Real omega, Real timeStep, Attribute< Matrix >::Ptr leftVector)
Initializes MNA specific variables.
Bool mnaIsClosed()
Check if switch is closed.
void mnaCompPostStep(Real time, Int timeStepCount, Attribute< Matrix >::Ptr &leftVector)
MNA pre step operations.
String uid()
Returns unique id.
MNASimPowerComp(String uid, String name, Bool hasPreStep, Bool hasPostStep, Logger::Level logLevel)
MNA interface to be used by switching devices.
MNA interface to be used by elements that require recomputing of the system matrix.