DPsim
Loading...
Searching...
No Matches
Base_SynchronGenerator.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/AttributeList.h>
12#include <dpsim-models/Base/Base_Exciter.h>
13#include <dpsim-models/Base/Base_Governor.h>
14#include <dpsim-models/Base/Base_PSS.h>
15#include <dpsim-models/Base/Base_Turbine.h>
16#include <dpsim-models/Definitions.h>
17#include <dpsim-models/Signal/TurbineGovernor.h>
18#include <dpsim-models/Signal/TurbineGovernorType1.h>
19
20namespace CPS {
21namespace Base {
30public:
35 enum class StateType { perUnit, statorReferred, rotorReferred };
37 enum class ParameterType { perUnit, statorReferred, operational };
38
39 // Deprecated — uses legacy TurbineGovernor; prefer addGovernor(TurbineGovernorType1)
40 void addGovernor(Real Ta, Real Tb, Real Tc, Real Fa, Real Fb, Real Fc, Real K,
41 Real Tsr, Real Tsm, Real Tm_init, Real PmRef);
43 void
44 addGovernor(std::shared_ptr<Signal::TurbineGovernorType1> turbineGovernor);
45 // Deprecated scalar convenience — creates TurbineGovernorType1 internally; use object overload instead
46 void addGovernor(Real T3, Real T4, Real T5, Real Tc, Real Ts, Real R,
47 Real Tmin, Real Tmax, Real OmRef, Real TmRef);
48
50 void
51 addGovernorAndTurbine(std::shared_ptr<Base::Governor> governor,
52 std::shared_ptr<Base::GovernorParameters> govParams,
53 std::shared_ptr<Base::Turbine> turbine,
54 std::shared_ptr<Base::TurbineParameters> turbineParams);
56 void addGovernorAndTurbine(std::shared_ptr<Base::Governor> governor,
57 std::shared_ptr<Base::Turbine> turbine);
58
60 void addExciter(std::shared_ptr<Base::Exciter> exciter,
61 std::shared_ptr<Base::ExciterParameters> params);
63 void addExciter(std::shared_ptr<Base::Exciter> exciter);
64
65 // Deprecated method
66 void addExciter(Real Ta, Real Ka, Real Te, Real Ke, Real Tf, Real Kf,
67 Real Tr);
69 void addPSS(std::shared_ptr<Base::PSS> pss,
70 std::shared_ptr<Base::PSSParameters> parameters);
72 void addPSS(std::shared_ptr<Base::PSS> pss);
73
74protected:
76 NumericalMethod
77 mNumericalMethod; //not needed if sundials used; could instead determine implicit / explicit solve
83 StateType mStateType = StateType::perUnit;
85 ParameterType mParameterType;
87 Bool mInitialValuesSet = false;
88
89 // ### Machine parameters ###
91 Real mNomPower = 0;
93 Real mNomVolt = 0;
95 Real mNomFreq = 0;
97 Real mNomOmega = 0;
99 Real mNomFieldCur = 0;
103 Int mPoleNumber = 0;
104
106 Real mLmd = 0;
108 Real mLmq = 0;
110 Real mRfd = 0;
112 Real mLlfd = 0;
114 Real mLfd = 0;
116 Real mLf = 0;
118 Real mRkd = 0;
120 Real mLlkd = 0;
122 Real mLkd = 0;
124 Real mRkq1 = 0;
126 Real mLlkq1 = 0;
128 Real mLkq1 = 0;
130 Real mRkq2 = 0;
132 Real mLlkq2 = 0;
134 Real mLkq2 = 0;
135
136public:
138 const Attribute<Real>::Ptr mRs;
140 const Attribute<Real>::Ptr mLl;
142 const Attribute<Real>::Ptr mLd;
144 const Attribute<Real>::Ptr mLq;
145
146 // Operational parameters
148 const Attribute<Real>::Ptr mLd_t;
150 const Attribute<Real>::Ptr mLq_t;
152 const Attribute<Real>::Ptr mLd_s;
154 const Attribute<Real>::Ptr mLq_s;
156 const Attribute<Real>::Ptr mTd0_t;
158 const Attribute<Real>::Ptr mTq0_t;
160 const Attribute<Real>::Ptr mTd0_s;
162 const Attribute<Real>::Ptr mTq0_s;
163
164protected:
165 // #### Initial Values ####
166 Complex mInitElecPower = 0;
167 Complex mInitTermVoltage = 0;
168 Real mInitMechPower = 0;
169
170 // ### Stator base values ###
172 Real mBase_V = 0;
174 Real mBase_V_RMS = 0;
176 Real mBase_I = 0;
178 Real mBase_I_RMS = 0;
180 Real mBase_Z = 0;
182 Real mBase_OmElec = 0;
184 Real mBase_OmMech = 0;
186 Real mBase_L = 0;
188 Real mBase_T = 0;
190 Real mBase_Psi = 0;
191
193 Real mBase_ifd = 0;
195 Real mBase_vfd = 0;
197 Real mBase_Zfd = 0;
199 Real mBase_Lfd = 0;
200
201 // ### Useful Matrices ### (still needed? )
208
209 // ### State variables ###
211 Real mThetaMech = 0;
212
213public:
215 const Attribute<Real>::Ptr mDelta;
217 const Attribute<Real>::Ptr mMechTorque;
219 const Attribute<Real>::Ptr mInertia;
221 const Attribute<Real>::Ptr mOmMech;
223 const Attribute<Real>::Ptr mElecActivePower;
225 const Attribute<Real>::Ptr mElecReactivePower;
227 const Attribute<Real>::Ptr mMechPower;
229 const Attribute<Real>::Ptr mElecTorque;
230
231protected:
241 Matrix mVsr;
251 Matrix mIsr;
261 Matrix mPsisr; //equivalent to Fluxes
264
265 // #### dq-frame specific variables ####
267 Matrix mVdq0;
269 Matrix mIdq0;
277 Real mLad;
279 Real mLaq;
281 Real mDetLd;
283 Real mDetLq;
284
288 Real mRcomp;
289
292 void initPerUnitStates();
293
294 // #### Controllers ####
302 Bool mHasExciter = false;
304 Bool mHasPSS = false;
305
306 // Deprecated
307 Real mInitTerminalVoltage = 0;
308 Real mInitVoltAngle = 0;
309
311 explicit SynchronGenerator(CPS::AttributeList::Ptr attributeList)
312 : mRs(attributeList->create<Real>("Rs", 0)),
313 mLl(attributeList->create<Real>("Ll", 0)),
314 mLd(attributeList->create<Real>("Ld", 0)),
315 mLq(attributeList->create<Real>("Lq", 0)),
316 mLd_t(attributeList->create<Real>("Ld_t", 0)),
317 mLq_t(attributeList->create<Real>("Lq_t", 0)),
318 mLd_s(attributeList->create<Real>("Ld_s", 0)),
319 mLq_s(attributeList->create<Real>("Lq_s", 0)),
320 mTd0_t(attributeList->create<Real>("Td0_t", 0)),
321 mTq0_t(attributeList->create<Real>("Tq0_t", 0)),
322 mTd0_s(attributeList->create<Real>("Td0_s", 0)),
323 mTq0_s(attributeList->create<Real>("Tq0_s", 0)),
324 mDelta(attributeList->create<Real>("delta_r", 0)),
325 mMechTorque(attributeList->create<Real>("T_m", 0)),
326 mInertia(attributeList->create<Real>("inertia", 0)),
327 mOmMech(attributeList->create<Real>("w_r", 0)),
328 mElecActivePower(attributeList->create<Real>("P_elec", 0)),
329 mElecReactivePower(attributeList->create<Real>("Q_elec", 0)),
330 mMechPower(attributeList->create<Real>("P_mech", 0)),
331 mElecTorque(attributeList->create<Real>("T_e", 0)){};
332
334 void setBaseParameters(Real nomPower, Real nomVolt, Real nomFreq);
336 void setBaseParameters(Real nomPower, Real nomVolt, Real nomFreq,
337 Real nomFieldCur);
338
340 void calcStateSpaceMatrixDQ();
342 Real calcHfromJ(Real J, Real omegaNominal, Int polePairNumber);
343
344public:
347
349 void setBaseAndFundamentalPerUnitParameters(Real nomPower, Real nomVolt,
350 Real nomFreq, Real nomFieldCur,
351 Int poleNumber, Real Rs, Real Ll,
352 Real Lmd, Real Lmq, Real Rfd,
353 Real Llfd, Real Rkd, Real Llkd,
354 Real Rkq1, Real Llkq1, Real Rkq2,
355 Real Llkq2, Real inertia);
356
360 Real nomPower, Real nomVolt, Real nomFreq, Int poleNumber,
361 Real nomFieldCur, Real Rs, Real Ld, Real Lq, Real Ld_t, Real Lq_t,
362 Real Ld_s, Real Lq_s, Real Ll, Real Td0_t, Real Tq0_t, Real Td0_s,
363 Real Tq0_s, Real inertia);
364
366 void setFundamentalPerUnitParameters(Int poleNumber, Real Rs, Real Ll,
367 Real Lmd, Real Lmq, Real Rfd, Real Llfd,
368 Real Rkd, Real Llkd, Real Rkq1,
369 Real Llkq1, Real Rkq2, Real Llkq2,
370 Real inertia);
371
373 void applyFundamentalPerUnitParameters();
374
376 void setAndApplyFundamentalPerUnitParameters(Int poleNumber, Real Rs, Real Ll,
377 Real Lmd, Real Lmq, Real Rfd,
378 Real Llfd, Real Rkd, Real Llkd,
379 Real Rkq1, Real Llkq1, Real Rkq2,
380 Real Llkq2, Real inertia);
381
383 void setOperationalPerUnitParameters(Int poleNumber, Real inertia, Real Rs,
384 Real Ld, Real Lq, Real Ll, Real Ld_t,
385 Real Lq_t, Real Ld_s, Real Lq_s,
386 Real Td0_t, Real Tq0_t, Real Td0_s,
387 Real Tq0_s);
388
390 void calculateFundamentalFromOperationalParameters();
391
393 void setInitialValues(Real initActivePower, Real initReactivePower,
394 Real initTerminalVolt, Real initVoltAngle,
395 Real initMechPower);
396
398 void setNumericalMethod(NumericalMethod method) { mNumericalMethod = method; }
399
401 std::shared_ptr<Signal::TurbineGovernor> mTurbineGovernor;
403 std::shared_ptr<Signal::TurbineGovernorType1> mTurbineGovernorType1;
405 std::shared_ptr<Base::Governor> mGovernor;
407 std::shared_ptr<Base::Turbine> mTurbine;
409 std::shared_ptr<Base::Exciter> mExciter;
411 std::shared_ptr<Base::PSS> mPSS;
412};
413} // namespace Base
414} // namespace CPS
Matrix mIsr
Vector of stator and rotor currents.
StateType
State type of machine variables.
Real mNomFreq
nominal frequency fn [Hz]
Bool mHasTurbineGovernorType1
Determines if TurbineGovernorType1 is activated.
Real mTimeStep
Simulation time step.
Real mDetLd
Determinant of d-axis inductance matrix.
Real mSystemOmega
Simulation angular system speed.
const Attribute< Real >::Ptr mLq_t
Transient q-axis inductance [H].
Real mRkq1
q-axis damper resistance 1 Rkq1 [Ohm]
Real mRcomp
Compensation Resistance.
Real mLmd
d-axis mutual inductance Lmd [H]
Real mBase_I
base stator current peak
void addExciter(std::shared_ptr< Base::Exciter > exciter)
Add already constructed regulator and exciter.
Bool mHasExciter
Determines if Exciter is activated.
Real mLf
field winding inductance Lf [H]
Real mLad
Inductance to calculate magnetizing flux linkage from winding flux linkages.
const Attribute< Real >::Ptr mMechTorque
mechanical torque
Bool mCompensationOn
Determines if compensation elements are used.
const Attribute< Real >::Ptr mTq0_s
Subtransient time constant of q-axis [s].
Matrix mFluxToCurrentMat
Calculates currents from fluxes.
Real mLmq
q-axis mutual inductance Lmq [H]
std::shared_ptr< Base::Exciter > mExciter
Signal component modelling voltage regulator and exciter.
SynchronGenerator(CPS::AttributeList::Ptr attributeList)
Constructor.
Real mLkq1
q-axis damper inductance 1 Lkq1 [H]
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)
Real mBase_I_RMS
base stator current RMS
void setNumericalMethod(NumericalMethod method)
Switch to determine the integration method for the machine model.
Real mLkd
d-axis damper inductance Lkd [H]
std::shared_ptr< Base::Turbine > mTurbine
Modular turbine (SteamTurbine / HydroTurbine)
Real mLlfd
field leakage inductance Llfd [H]
Bool mInitialValuesSet
Flag to remember when initial values are set.
Matrix mFluxStateSpaceMat
Flux state space matrix excluding omega term.
void addPSS(std::shared_ptr< Base::PSS > pss, std::shared_ptr< Base::PSSParameters > parameters)
Attach a PSS (initialised separately) to this generator.
const Attribute< Real >::Ptr mTq0_t
Transient time constant of q-axis [s].
Real mLlkd
d-axis damper leakage inductance Llkd [H]
ParameterType
Machine parameters type.
const Attribute< Real >::Ptr mMechPower
mechanical Power Pm [W]
Real mNomVolt
nominal voltage Vn [V] (phase-to-phase RMS)
Matrix mVsr
Vector of stator and rotor voltages.
Matrix mPsisr
Vector of stator and rotor fluxes.
Real mBase_L
base stator inductance
const Attribute< Real >::Ptr mLq
q-axis inductance Lq [H]
Real mBase_Z
base stator impedance
const Attribute< Real >::Ptr mRs
stator resistance Rs [Ohm]
Matrix mResistanceMat
resistance matrix
Bool mHasGovernorAndTurbine
Determines if modular Governor + Turbine pair is activated.
Real mLkq2
q-axis damper inductance 2 Lkq2 [H]
std::shared_ptr< Base::PSS > mPSS
Power system stabilizer.
Real mDetLq
Determinant of q-axis inductance matrix.
const Attribute< Real >::Ptr mElecReactivePower
Reactive part of the electrical power.
const Attribute< Real >::Ptr mElecActivePower
Active part of the electrical power.
std::shared_ptr< Signal::TurbineGovernor > mTurbineGovernor
Signal component modelling governor control and steam turbine (legacy)
Matrix mOmegaFluxMat
Omega-flux matrix for state space system.
Real mLlkq1
q-axis damper leakage inductance 1 Llkq1 [H]
Matrix mIdq0
dq0 current calculated from terminal current
void addExciter(std::shared_ptr< Base::Exciter > exciter, std::shared_ptr< Base::ExciterParameters > params)
Add voltage regulator and exciter.
const Attribute< Real >::Ptr mLq_s
Subtransient q-axis inductance [H].
std::shared_ptr< Base::Governor > mGovernor
Modular governor (SteamTurbineGovernor / HydroTurbineGovernor)
void setBaseAndFundamentalPerUnitParameters(Real nomPower, Real nomVolt, Real nomFreq, Real nomFieldCur, Int poleNumber, Real Rs, Real Ll, Real Lmd, Real Lmq, Real Rfd, Real Llfd, Real Rkd, Real Llkd, Real Rkq1, Real Llkq1, Real Rkq2, Real Llkq2, Real inertia)
Initializes the base and fundamental machine parameters in per unit.
Real mRkd
d-axis damper resistance Rkd [Ohm]
StateType mStateType
specifies if the machine parameters are transformed to per unit
Real mNomFieldCur
nominal field current Ifn [A]
Real mRfd
field resistance Rfd [Ohm]
Real mNomOmega
nominal angular frequency wn [Hz]
Real mLaq
Inductance to calculate magnetizing flux linkage from winding flux linkages.
Real mBase_OmElec
base electrical angular frequency
Matrix mVdq0
dq0 voltage calculated from terminal voltage
const Attribute< Real >::Ptr mLl
leakage inductance Ll [H]
const Attribute< Real >::Ptr mTd0_s
Subtransient time constant of d-axis [s].
Real mBase_OmMech
base mechanical angular frequency
Real mBase_Zfd
base field impedance
virtual ~SynchronGenerator()
Destructor - does nothing.
const Attribute< Real >::Ptr mDelta
rotor angle delta
Real mRkq2
q-axis damper resistance 2 Rkq2 [Ohm]
Real mLfd
field inductance Lfd [H]
const Attribute< Real >::Ptr mTd0_t
Transient time constant of d-axis [s].
Bool mHasPSS
Determines if PSS is activated.
Int mNumDampingWindings
Number of damping windings in q.
Real mBase_V
base stator voltage (phase-to-ground peak)
const Attribute< Real >::Ptr mLd
d-axis inductance Ld [H]
Matrix mInvInductanceMat
Inverse of the inductance matrix.
Real mNomPower
nominal power Pn [VA]
void setBaseAndOperationalPerUnitParameters(Real nomPower, Real nomVolt, Real nomFreq, Int poleNumber, Real nomFieldCur, Real Rs, Real Ld, Real Lq, Real Ld_t, Real Lq_t, Real Ld_s, Real Lq_s, Real Ll, Real Td0_t, Real Tq0_t, Real Td0_s, Real Tq0_s, Real inertia)
Real mBase_Lfd
base field inductance
const Attribute< Real >::Ptr mOmMech
rotor speed omega_r
Bool mHasTurbineGovernor
Determines if legacy TurbineGovernor is activated.
const Attribute< Real >::Ptr mLd_t
Transient d-axis inductance [H].
Real mLlkq2
q-axis damper leakage inductance 2 Llkq2 [H]
const Attribute< Real >::Ptr mLd_s
Subtransient d-axis inductance [H].
std::shared_ptr< Signal::TurbineGovernorType1 > mTurbineGovernorType1
Signal component modelling governor control and steam turbine (TurbineGovernorType1)
Matrix mInductanceMat
Inductance matrix which is numerically equal to the reactance matrix in per unit.
const Attribute< Real >::Ptr mInertia
inertia constant H [s] for per unit or moment of inertia J [kg*m^2]
const Attribute< Real >::Ptr mElecTorque
electrical torque
Real mBase_V_RMS
base stator voltage (phase-to-ground RMS)