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/Base/Base_Exciter.h>
12#include <dpsim-models/Base/Base_Governor.h>
13#include <dpsim-models/Base/Base_PSS.h>
14#include <dpsim-models/Base/Base_Turbine.h>
15#include <dpsim-models/MNASimPowerComp.h>
16#include <dpsim-models/Signal/TurbineGovernorType1.h>
17#include <dpsim-models/Solver/MNAInterface.h>
18
19namespace CPS {
20namespace Base {
21
22template <typename VarType>
23class ReducedOrderSynchronGenerator : public MNASimPowerComp<VarType> {
24
25public:
26 // ### State variables [p.u.]###
31 const Attribute<Matrix>::Ptr mVdq0;
36 const Attribute<Matrix>::Ptr mIdq0;
40 const Attribute<Matrix>::Ptr mVdq;
44 const Attribute<Matrix>::Ptr mIdq;
46 const Attribute<Complex>::Ptr mPower;
48 const Attribute<Real>::Ptr mElecTorque;
50 const Attribute<Real>::Ptr mMechTorque;
51 Real mMechTorque_prev;
53 const Attribute<Real>::Ptr mOmMech;
55 const Attribute<Real>::Ptr mThetaMech;
57 const Attribute<Real>::Ptr mDelta;
59 const Attribute<Real>::Ptr mEf;
62
67 virtual void setModelAsNortonSource(Bool modelAsCurrentSource);
69 void setBaseParameters(Real nomPower, Real nomVolt, Real nomFreq);
71 void setOperationalParametersPerUnit(Real nomPower, Real nomVolt,
72 Real nomFreq, Real H, Real Ld, Real Lq,
73 Real L0, Real Ld_t, Real Td0_t);
75 void setOperationalParametersPerUnit(Real nomPower, Real nomVolt,
76 Real nomFreq, Real H, Real Ld, Real Lq,
77 Real L0, Real Ld_t, Real Lq_t,
78 Real Td0_t, Real Tq0_t);
81 void setOperationalParametersPerUnit(Real nomPower, Real nomVolt,
82 Real nomFreq, Real H, Real Ld, Real Lq,
83 Real L0, Real Ld_t, Real Lq_t,
84 Real Td0_t, Real Tq0_t, Real Ld_s,
85 Real Lq_s, Real Td0_s, Real Tq0_s,
86 Real Taa = 0);
88 void setInitialValues(Complex initComplexElectricalPower,
89 Real initMechanicalPower, Complex initTerminalVoltage);
90
92 void addGovernor(Real T3, Real T4, Real T5, Real Tc, Real Ts, Real R,
93 Real Pmin, Real Pmax, Real OmRef, Real TmRef);
94 void
95 addGovernor(std::shared_ptr<Signal::TurbineGovernorType1> turbineGovernor);
97 void
98 addGovernorAndTurbine(std::shared_ptr<Base::Governor> governor,
99 std::shared_ptr<Base::GovernorParameters> govParams,
100 std::shared_ptr<Base::Turbine> turbine,
101 std::shared_ptr<Base::TurbineParameters> turbineParams);
103 void addGovernorAndTurbine(std::shared_ptr<Base::Governor> governor,
104 std::shared_ptr<Base::Turbine> turbine);
106 void addExciter(std::shared_ptr<Base::Exciter> exciter,
107 std::shared_ptr<Base::ExciterParameters> params);
109 void addExciter(std::shared_ptr<Base::Exciter> exciter);
110
111 // Deprecated method
112 void addExciter(Real Ta, Real Ka, Real Te, Real Ke, Real Tf, Real Kf,
113 Real Tr);
115 void addPSS(std::shared_ptr<Base::PSS> pss,
116 std::shared_ptr<Base::PSSParameters> parameters);
118 void addPSS(std::shared_ptr<Base::PSS> pss);
119
121 void scaleInertiaConstant(Real scalingFactor);
122
123protected:
124 using MNASimPowerComp<VarType>::mRightVector;
125 using MNASimPowerComp<VarType>::mIntfVoltage;
126
128 ReducedOrderSynchronGenerator(String uid, String name,
129 Logger::Level logLevel);
131 void calculateVBRconstants();
133 void calculateResistanceMatrixConstants();
135 virtual void initializeResistanceMatrix() = 0;
137 void initializeFromNodesAndTerminals(Real frequency) override;
139 virtual void specificInitialization() = 0;
141 virtual void stepInPerUnit() = 0;
142
143 // ### MNA Section ###
145 void mnaCompInitialize(Real omega, Real timeStep,
146 Attribute<Matrix>::Ptr leftVector) override;
149 AttributeBase::List &prevStepDependencies,
150 AttributeBase::List &attributeDependencies,
151 AttributeBase::List &modifiedAttributes) override;
152 void mnaCompPreStep(Real time, Int timeStepCount) override;
154 void
155 mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies,
156 AttributeBase::List &attributeDependencies,
157 AttributeBase::List &modifiedAttributes,
158 Attribute<Matrix>::Ptr &leftVector) override;
159 void mnaCompPostStep(Real time, Int timeStepCount,
160 Attribute<Matrix>::Ptr &leftVector) final;
161 virtual void mnaCompPostStep(const Matrix &leftVector) = 0;
163 virtual void
164 mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix) override = 0;
167 // Model flag indicating the SG order to be used
168 SGOrder mSGOrder;
169
170 // ### Base quantities (stator refered) ###
175 // Nominal frequency
176 Real mNomFreq;
196 Real mH;
197
198 // ### Operational Parameters (p.u.) ###
200 Real mLd = 0;
202 Real mLq = 0;
204 Real mL0 = 0;
206 Real mLd_t = 0;
208 Real mLq_t = 0;
210 Real mLd_s = 0;
212 Real mLq_s = 0;
214 Real mTd0_t = 0;
216 Real mTq0_t = 0;
218 Real mTd0_s = 0;
220 Real mTq0_s = 0;
222 Real mTaa = 0;
223
224 // ### VBR constants ###
226 Real mAd_t = 0;
228 Real mBd_t = 0;
230 Real mAq_t = 0;
232 Real mBq_t = 0;
234 Real mDq_t = 0;
236 Real mAd_s = 0;
238 Real mAq_s = 0;
240 Real mBd_s = 0;
242 Real mBq_s = 0;
244 Real mCd_s = 0;
246 Real mCq_s = 0;
248 Real mDq_s = 0;
250 Real mYd = 0;
252 Real mYq = 0;
253
254 // ### Constants of resistance matrix (VBR) ###
256 Real mA = 0;
258 Real mB = 0;
259
260 // ### Initial values ###
277
279 Bool mInitialValuesSet = false;
280
281 // #### Controllers ####
287 Bool mHasExciter = false;
289 Bool mHasPSS = false;
291 std::shared_ptr<Signal::TurbineGovernorType1> mTurbineGovernor;
293 std::shared_ptr<Base::Governor> mGovernor;
295 std::shared_ptr<Base::Turbine> mTurbine;
297 std::shared_ptr<Base::Exciter> mExciter;
299 std::shared_ptr<Base::PSS> mPSS;
300
302 Real mTimeStep;
303 Real mSimTime;
304 Real mVpss = 0;
305};
306} // namespace Base
307} // namespace CPS
Bool mInitialValuesSet
Flag to remember when initial values are set.
void addGovernorAndTurbine(std::shared_ptr< Base::Governor > governor, std::shared_ptr< Base::GovernorParameters > govParams, std::shared_ptr< Base::Turbine > turbine, std::shared_ptr< Base::TurbineParameters > turbineParams)
Add a modular governor + turbine pair (new API for SteamTurbineGovernor / SteamTurbine)
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.)
void addPSS(std::shared_ptr< Base::PSS > pss, std::shared_ptr< Base::PSSParameters > parameters)
Attach a PSS (initialises parameters) to this generator.
Complex mInitCurrent
initial armature voltage phase a (p.u.)
Bool mHasTurbineGovernor
Determines if TurbineGovernorType1 is 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.
Bool mHasGovernorAndTurbine
Determines if modular Governor + Turbine pair is activated.
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
std::shared_ptr< Base::Governor > mGovernor
Modular governor (SteamTurbineGovernor / HydroTurbineGovernor)
void addExciter(std::shared_ptr< Base::Exciter > exciter, std::shared_ptr< Base::ExciterParameters > params)
Add voltage regulator and exciter.
Real mInitVoltageAngle
angle of initial armature voltage
const Attribute< Real >::Ptr mOmMech
Rotor speed.
std::shared_ptr< Base::PSS > mPSS
Power system stabilizer.
std::shared_ptr< Base::Exciter > mExciter
Signal component modelling voltage regulator and exciter.
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< Complex >::Ptr mPower
Electrical power.
std::shared_ptr< Base::Turbine > mTurbine
Modular turbine (SteamTurbine / HydroTurbine)
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 (TurbineGovernorType1 legacy API)
virtual void mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix) override=0
Stamps system matrix.
Bool mHasExciter
Determines if Exciter is activated.
std::shared_ptr< Signal::TurbineGovernorType1 > mTurbineGovernor
TurbineGovernorType1 (legacy)
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.