DPsim
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 
18 namespace CPS {
19 namespace DP {
20 namespace Ph1 {
29 class SVC : public MNASimPowerComp<Complex>,
30  public Base::Ph1::SVC,
32  public SharedFactory<SVC> {
33 protected:
36  std::shared_ptr<DP::Ph1::Inductor> mSubInductor;
37  std::shared_ptr<DP::Ph1::Switch> mSubInductorProtectionSwitch;
39  std::shared_ptr<DP::Ph1::Capacitor> mSubCapacitor;
40  std::shared_ptr<DP::Ph1::Switch> mSubCapacitorProtectionSwitch;
41 
42  Bool mValueChange = false;
43  Bool mInductiveMode = false;
44 
45  // has state changed? (allow this only once)
46  // could be redundant with internal status of switch element (mnaIsClosed)
47  Real mSwitchStateChange = false;
48  Real mSwitchROpen = 1e9;
49  Real mSwitchRClosed = 1e-9;
50  Real mCounter = 0;
51 
52  Real mBSetCounter = 0;
53 
54  // values of PT1 for measurement of voltage at PCC
55  Real mTm = 0.01;
56  Real mKm = 1;
57  Real mLPrev;
58  Real mCPrev;
59 
60  // variables for protection
61  Real mProtCount1 = 0;
62  Real mProtCount2 = 0;
63  Real mProtCount3 = 0;
64  Bool mDisconnect = false;
65 
66 public:
67  const Attribute<Real>::Ptr mVpcc;
68  const Attribute<Real>::Ptr mVmeasPrev;
69 
71  SVC(String uid, String name, Logger::Level logLevel = Logger::Level::off);
73  SVC(String name, Logger::Level logLevel = Logger::Level::off)
74  : SVC(name, name, logLevel) {}
75 
76  // #### General ####
78  void initializeFromNodesAndTerminals(Real frequency);
79 
80  // #### MNA section ####
82  void mnaCompInitialize(Real omega, Real timeStep,
83  Attribute<Matrix>::Ptr leftVector);
84  //void mnaCompInitializeHarm(Real omega, Real timeStep, std::vector<Attribute<Matrix>::Ptr> leftVectors);
86  void mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix);
88  void mnaCompApplyRightSideVectorStamp(Matrix &rightVector);
90  void mnaCompUpdateVoltage(const Matrix &leftVector);
92  void mnaCompUpdateCurrent(const Matrix &leftVector);
94  void mnaCompPreStep(Real time, Int timeStepCount);
96  void mnaCompPostStep(Real time, Int timeStepCount,
97  Attribute<Matrix>::Ptr &leftVector);
99  void mnaCompAddPreStepDependencies(AttributeBase::List &prevStepDependencies,
100  AttributeBase::List &attributeDependencies,
101  AttributeBase::List &modifiedAttributes);
103  void
104  mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies,
105  AttributeBase::List &attributeDependencies,
106  AttributeBase::List &modifiedAttributes,
107  Attribute<Matrix>::Ptr &leftVector);
108 
109  // #### Tearing methods ####
110  Bool ValueChanged();
111  void setSwitchState();
112 
113  void updateSusceptance();
114  void mechanicalModelUpdateSusceptance(Real time);
115  // check protection function
116  void checkProtection(Real time);
117 };
118 } // namespace Ph1
119 } // namespace DP
120 } // namespace CPS
Static VAR compensator (SVC)
Definition: Base_Ph1_SVC.h:18
void mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix)
Stamps system matrix.
Definition: DP_Ph1_SVC.cpp:142
void mnaCompUpdateVoltage(const Matrix &leftVector)
Update interface voltage from MNA system results.
Definition: DP_Ph1_SVC.cpp:232
std::shared_ptr< DP::Ph1::Capacitor > mSubCapacitor
Internal capacitor.
Definition: DP_Ph1_SVC.h:39
void mnaCompUpdateCurrent(const Matrix &leftVector)
Update interface current from MNA system results.
Definition: DP_Ph1_SVC.cpp:240
void mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute< Matrix >::Ptr &leftVector)
add MNA post step dependencies
Definition: DP_Ph1_SVC.cpp:193
std::shared_ptr< DP::Ph1::Inductor > mSubInductor
Definition: DP_Ph1_SVC.h:36
void mnaCompAddPreStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes)
add MNA pre step dependencies
Definition: DP_Ph1_SVC.cpp:157
void mnaCompApplyRightSideVectorStamp(Matrix &rightVector)
Stamps right side (source) vector.
Definition: DP_Ph1_SVC.cpp:150
void initializeFromNodesAndTerminals(Real frequency)
Initializes states from power flow data.
Definition: DP_Ph1_SVC.cpp:29
void mnaCompPreStep(Real time, Int timeStepCount)
MNA pre step operations.
Definition: DP_Ph1_SVC.cpp:175
void mnaCompPostStep(Real time, Int timeStepCount, Attribute< Matrix >::Ptr &leftVector)
MNA post step operations.
Definition: DP_Ph1_SVC.cpp:218
SVC(String name, Logger::Level logLevel=Logger::Level::off)
Defines name and log level.
Definition: DP_Ph1_SVC.h:73
SVC(String uid, String name, Logger::Level logLevel=Logger::Level::off)
Defines UID, name and log level.
Definition: DP_Ph1_SVC.cpp:13
void mnaCompInitialize(Real omega, Real timeStep, Attribute< Matrix >::Ptr leftVector)
Initializes MNA specific variables.
Definition: DP_Ph1_SVC.cpp:117
String uid()
Returns unique id.
Base class for all MNA components that are transmitting power.
MNA interface to be used by elements that require recomputing of the system matrix.