DPsim
Loading...
Searching...
No Matches
Base_ReducedOrderSynchronGenerator.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/MNASimPowerComp.h>
12#include <dpsim-models/Signal/Exciter.h>
13#include <dpsim-models/Signal/TurbineGovernorType1.h>
14#include <dpsim-models/Solver/MNAInterface.h>
15
16namespace CPS {
17namespace Base {
18
19template <typename VarType>
20class ReducedOrderSynchronGenerator : public MNASimPowerComp<VarType> {
21
22public:
23 // ### State variables [p.u.]###
28 const Attribute<Matrix>::Ptr mVdq0;
33 const Attribute<Matrix>::Ptr mIdq0;
37 const Attribute<Matrix>::Ptr mVdq;
41 const Attribute<Matrix>::Ptr mIdq;
43 const Attribute<Real>::Ptr mElecTorque;
45 const Attribute<Real>::Ptr mMechTorque;
46 Real mMechTorque_prev;
48 const Attribute<Real>::Ptr mOmMech;
50 const Attribute<Real>::Ptr mThetaMech;
52 const Attribute<Real>::Ptr mDelta;
54 const Attribute<Real>::Ptr mEf;
57
62 virtual void setModelAsNortonSource(Bool modelAsCurrentSource);
64 void setBaseParameters(Real nomPower, Real nomVolt, Real nomFreq);
66 void setOperationalParametersPerUnit(Real nomPower, Real nomVolt,
67 Real nomFreq, Real H, Real Ld, Real Lq,
68 Real L0, Real Ld_t, Real Td0_t);
70 void setOperationalParametersPerUnit(Real nomPower, Real nomVolt,
71 Real nomFreq, Real H, Real Ld, Real Lq,
72 Real L0, Real Ld_t, Real Lq_t,
73 Real Td0_t, Real Tq0_t);
76 void setOperationalParametersPerUnit(Real nomPower, Real nomVolt,
77 Real nomFreq, Real H, Real Ld, Real Lq,
78 Real L0, Real Ld_t, Real Lq_t,
79 Real Td0_t, Real Tq0_t, Real Ld_s,
80 Real Lq_s, Real Td0_s, Real Tq0_s,
81 Real Taa = 0);
83 void setInitialValues(Complex initComplexElectricalPower,
84 Real initMechanicalPower, Complex initTerminalVoltage);
85
87 void addGovernor(Real T3, Real T4, Real T5, Real Tc, Real Ts, Real R,
88 Real Pmin, Real Pmax, Real OmRef, Real TmRef);
89 void
90 addGovernor(std::shared_ptr<Signal::TurbineGovernorType1> turbineGovernor);
92 void addExciter(Real Ta, Real Ka, Real Te, Real Ke, Real Tf, Real Kf,
93 Real Tr);
94 void addExciter(std::shared_ptr<Signal::Exciter> exciter);
95
97 void scaleInertiaConstant(Real scalingFactor);
98
99protected:
100 using MNASimPowerComp<VarType>::mRightVector;
101 using MNASimPowerComp<VarType>::mIntfVoltage;
102
104 ReducedOrderSynchronGenerator(String uid, String name,
105 Logger::Level logLevel);
107 void calculateVBRconstants();
109 void calculateResistanceMatrixConstants();
111 virtual void initializeResistanceMatrix() = 0;
113 void initializeFromNodesAndTerminals(Real frequency) override;
115 virtual void specificInitialization() = 0;
117 virtual void stepInPerUnit() = 0;
118
119 // ### MNA Section ###
121 void mnaCompInitialize(Real omega, Real timeStep,
122 Attribute<Matrix>::Ptr leftVector) override;
125 AttributeBase::List &prevStepDependencies,
126 AttributeBase::List &attributeDependencies,
127 AttributeBase::List &modifiedAttributes) override;
128 void mnaCompPreStep(Real time, Int timeStepCount) override;
130 void
131 mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies,
132 AttributeBase::List &attributeDependencies,
133 AttributeBase::List &modifiedAttributes,
134 Attribute<Matrix>::Ptr &leftVector) override;
135 void mnaCompPostStep(Real time, Int timeStepCount,
136 Attribute<Matrix>::Ptr &leftVector) final;
137 virtual void mnaCompPostStep(const Matrix &leftVector) = 0;
139 virtual void
140 mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix) override = 0;
143 // Model flag indicating the SG order to be used
144 SGOrder mSGOrder;
145
146 // ### Base quantities (stator refered) ###
151 // Nominal frequency
152 Real mNomFreq;
172 Real mH;
173
174 // ### Operational Parameters (p.u.) ###
176 Real mLd = 0;
178 Real mLq = 0;
180 Real mL0 = 0;
182 Real mLd_t = 0;
184 Real mLq_t = 0;
186 Real mLd_s = 0;
188 Real mLq_s = 0;
190 Real mTd0_t = 0;
192 Real mTq0_t = 0;
194 Real mTd0_s = 0;
196 Real mTq0_s = 0;
198 Real mTaa = 0;
199
200 // ### VBR constants ###
202 Real mAd_t = 0;
204 Real mBd_t = 0;
206 Real mAq_t = 0;
208 Real mBq_t = 0;
210 Real mDq_t = 0;
212 Real mAd_s = 0;
214 Real mAq_s = 0;
216 Real mBd_s = 0;
218 Real mBq_s = 0;
220 Real mCd_s = 0;
222 Real mCq_s = 0;
224 Real mDq_s = 0;
226 Real mYd = 0;
228 Real mYq = 0;
229
230 // ### Constants of resistance matrix (VBR) ###
232 Real mA = 0;
234 Real mB = 0;
235
236 // ### Initial values ###
253
255 Bool mInitialValuesSet = false;
256
257 // #### Controllers ####
261 Bool mHasExciter = false;
263 std::shared_ptr<Signal::TurbineGovernorType1> mTurbineGovernor;
265 std::shared_ptr<Signal::Exciter> mExciter;
266
268 Real mTimeStep;
269 Real mSimTime;
270};
271} // namespace Base
272} // namespace CPS
void addExciter(Real Ta, Real Ka, Real Te, Real Ke, Real Tf, Real Kf, Real Tr)
Add voltage regulator and exciter.
Bool mInitialValuesSet
Flag to remember when initial values are set.
Complex mInitVoltage
initial terminal voltage phase a (p.u.)
Real mTd0_s
Subtransient time constant of d-axis.
void setBaseParameters(Real nomPower, Real nomVolt, Real nomFreq)
virtual void specificInitialization()=0
Function to initialize the specific variables of each SG model.
Real mEf_prev
induced emf by the field current under no-load conditions at time k (p.u.)
Complex mInitCurrent
initial armature voltage phase a (p.u.)
Bool mHasTurbineGovernor
Determines if Turbine and Governor are activated.
void setOperationalParametersPerUnit(Real nomPower, Real nomVolt, Real nomFreq, Real H, Real Ld, Real Lq, Real L0, Real Ld_t, Real Td0_t)
Initialization for 3 Order SynGen.
std::shared_ptr< Signal::Exciter > mExciter
Signal component modelling voltage regulator and exciter.
void mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute< Matrix >::Ptr &leftVector) override
Add MNA post step dependencies.
Bool mModelAsNortonSource
Model flag indicating whether the machine is modelled as Norton or Thevenin equivalent.
virtual ~ReducedOrderSynchronGenerator()
Destructor - does nothing.
virtual void setModelAsNortonSource(Bool modelAsCurrentSource)
const Attribute< Real >::Ptr mElecTorque
stator electrical torque
Real mInitVoltageAngle
angle of initial armature voltage
const Attribute< Real >::Ptr mOmMech
Rotor speed.
Real mTaa
d-axis additional leakage time constant
void initializeFromNodesAndTerminals(Real frequency) override
Initializes Component variables according to power flow data stored in Nodes.
Real mTq0_s
Subtransient time constant of q-axis.
void mnaCompAddPreStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes) override
Add MNA pre step dependencies.
virtual void stepInPerUnit()=0
Model specific step.
const Attribute< Real >::Ptr mDelta
Load angle (between q-axis and stator a-axis)
Real mInitCurrentAngle
angle of initial armature current
const Attribute< Real >::Ptr mMechTorque
Mechanical torque.
const Attribute< Real >::Ptr mEf
induced emf by the field current under no-load conditions at time k+1 (p.u.)
const Attribute< Real >::Ptr mThetaMech
mechanical system angle (between d-axis and stator a-axis)
void addGovernor(Real T3, Real T4, Real T5, Real Tc, Real Ts, Real R, Real Pmin, Real Pmax, Real OmRef, Real TmRef)
Add governor and turbine.
virtual void mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix) override=0
Stamps system matrix.
Bool mHasExciter
Determines if Exciter is activated.
std::shared_ptr< Signal::TurbineGovernorType1 > mTurbineGovernor
Signal component modelling governor control and steam turbine.
String uid()
Returns unique id.
Base class for all MNA components that are transmitting power.
MNASimPowerComp(String uid, String name, Bool hasPreStep, Bool hasPostStep, Logger::Level logLevel)
Basic constructor that takes UID, name and log level.
Attribute< Matrix >::Ptr mRightVector
const Attribute< MatrixVar< VarType > >::Ptr mIntfVoltage
Voltage between terminals.