DPsim
Loading...
Searching...
No Matches
DP_Ph1_SVC.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_SVC.h>
12#include <dpsim-models/DP/DP_Ph1_Capacitor.h>
13#include <dpsim-models/DP/DP_Ph1_Inductor.h>
14#include <dpsim-models/DP/DP_Ph1_Switch.h>
15#include <dpsim-models/Solver/MNAInterface.h>
16#include <dpsim-models/Solver/MNAVariableCompInterface.h>
17
18namespace CPS {
19namespace DP {
20namespace Ph1 {
29class SVC : public MNASimPowerComp<Complex>,
30 public Base::Ph1::SVC,
32 public SharedFactory<SVC> {
33protected:
37 std::shared_ptr<DP::Ph1::Inductor> mSubInductor;
38 std::shared_ptr<DP::Ph1::Switch> mSubInductorProtectionSwitch;
40 std::shared_ptr<DP::Ph1::Capacitor> mSubCapacitor;
41 std::shared_ptr<DP::Ph1::Switch> mSubCapacitorProtectionSwitch;
42
43 Bool mValueChange = false;
44 Bool mInductiveMode = false;
45
46 // has state changed? (allow this only once)
47 // could be redundant with internal status of switch element (mnaIsClosed)
48 Real mSwitchStateChange = false;
49 Real mSwitchROpen = 1e9;
50 Real mSwitchRClosed = 1e-9;
51 Real mCounter = 0;
52
53 Real mBSetCounter = 0;
54
55 // values of PT1 for measurement of voltage at PCC
56 Real mTm = 0.01;
57 Real mKm = 1;
58 Real mLPrev;
59 Real mCPrev;
60
61 // variables for protection
62 Real mProtCount1 = 0;
63 Real mProtCount2 = 0;
64 Real mProtCount3 = 0;
65 Bool mDisconnect = false;
66
67public:
68 const Attribute<Real>::Ptr mVpcc;
69 const Attribute<Real>::Ptr mVmeasPrev;
70
72 SVC(String uid, String name, Logger::Level logLevel = Logger::Level::off);
74 SVC(String name, Logger::Level logLevel = Logger::Level::off)
75 : SVC(name, name, logLevel) {}
76
77 // #### General ####
79 void createSubComponents() override;
81 void initializeFromNodesAndTerminals(Real frequency) override;
82
83 // #### MNA section ####
85 void mnaCompInitialize(Real omega, Real timeStep,
86 Attribute<Matrix>::Ptr leftVector) override;
87 //void mnaCompInitializeHarm(Real omega, Real timeStep, std::vector<Attribute<Matrix>::Ptr> leftVectors);
89 void mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix) override;
91 void mnaCompApplyRightSideVectorStamp(Matrix &rightVector) override;
93 void mnaCompUpdateVoltage(const Matrix &leftVector) override;
95 void mnaCompUpdateCurrent(const Matrix &leftVector) override;
97 void mnaCompPreStep(Real time, Int timeStepCount) override;
99 void mnaCompPostStep(Real time, Int timeStepCount,
100 Attribute<Matrix>::Ptr &leftVector) override;
103 AttributeBase::List &prevStepDependencies,
104 AttributeBase::List &attributeDependencies,
105 AttributeBase::List &modifiedAttributes) override;
107 void
108 mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies,
109 AttributeBase::List &attributeDependencies,
110 AttributeBase::List &modifiedAttributes,
111 Attribute<Matrix>::Ptr &leftVector) override;
112
113 // #### Tearing methods ####
114 Bool ValueChanged();
115 void setSwitchState();
116
117 void updateSusceptance();
118 void mechanicalModelUpdateSusceptance(Real time);
119 // check protection function
120 void checkProtection(Real time);
121};
122} // namespace Ph1
123} // namespace DP
124} // namespace CPS
Static VAR compensator (SVC)
void mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix) override
Stamps system matrix.
void mnaCompPostStep(Real time, Int timeStepCount, Attribute< Matrix >::Ptr &leftVector) override
MNA post step operations.
void mnaCompUpdateCurrent(const Matrix &leftVector) override
Update interface current from MNA system results.
void createSubComponents() override
Constructs subcomponents; idempotent.
std::shared_ptr< DP::Ph1::Capacitor > mSubCapacitor
Internal capacitor.
Definition DP_Ph1_SVC.h:40
void mnaCompUpdateVoltage(const Matrix &leftVector) override
Update interface voltage from MNA system results.
void mnaCompInitialize(Real omega, Real timeStep, Attribute< Matrix >::Ptr leftVector) override
Initializes MNA specific variables.
void mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute< Matrix >::Ptr &leftVector) override
add MNA post step dependencies
std::shared_ptr< DP::Ph1::Inductor > mSubInductor
Definition DP_Ph1_SVC.h:37
void mnaCompApplyRightSideVectorStamp(Matrix &rightVector) override
Stamps right side (source) vector.
void initializeFromNodesAndTerminals(Real frequency) override
Initializes states from power flow data.
void mnaCompPreStep(Real time, Int timeStepCount) override
MNA pre step operations.
SVC(String name, Logger::Level logLevel=Logger::Level::off)
Defines name and log level.
Definition DP_Ph1_SVC.h:74
void mnaCompAddPreStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes) override
add MNA pre step dependencies
SVC(String uid, String name, Logger::Level logLevel=Logger::Level::off)
Defines UID, name and log level.
String uid()
Returns unique id.
MNASimPowerComp(String uid, String name, Bool hasPreStep, Bool hasPostStep, Logger::Level logLevel)
MNA interface to be used by elements that require recomputing of the system matrix.