DPsim
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/Definitions.h>
13 #include <dpsim-models/Signal/Exciter.h>
14 #include <dpsim-models/Signal/TurbineGovernor.h>
15 
16 namespace CPS {
17 namespace Base {
26 public:
31  enum class StateType { perUnit, statorReferred, rotorReferred };
33  enum class ParameterType { perUnit, statorReferred, operational };
34 
36  void addGovernor(Real Ta, Real Tb, Real Tc, Real Fa, Real Fb, Real Fc, Real K,
37  Real Tsr, Real Tsm, Real Tm_init, Real PmRef);
39  void addExciter(Real Ta, Real Ka, Real Te, Real Ke, Real Tf, Real Kf,
40  Real Tr);
41 
42 protected:
44  NumericalMethod
45  mNumericalMethod; //not needed if sundials used; could instead determine implicit / explicit solve
49  Real mTimeStep;
51  StateType mStateType = StateType::perUnit;
53  ParameterType mParameterType;
55  Bool mInitialValuesSet = false;
56 
57  // ### Machine parameters ###
59  Real mNomPower = 0;
61  Real mNomVolt = 0;
63  Real mNomFreq = 0;
65  Real mNomOmega = 0;
67  Real mNomFieldCur = 0;
71  Int mPoleNumber = 0;
72 
74  Real mLmd = 0;
76  Real mLmq = 0;
78  Real mRfd = 0;
80  Real mLlfd = 0;
82  Real mLfd = 0;
84  Real mLf = 0;
86  Real mRkd = 0;
88  Real mLlkd = 0;
90  Real mLkd = 0;
92  Real mRkq1 = 0;
94  Real mLlkq1 = 0;
96  Real mLkq1 = 0;
98  Real mRkq2 = 0;
100  Real mLlkq2 = 0;
102  Real mLkq2 = 0;
103 
104 public:
113 
114  // Operational parameters
131 
132 protected:
133  // #### Initial Values ####
134  Complex mInitElecPower = 0;
135  Complex mInitTermVoltage = 0;
136  Real mInitMechPower = 0;
137 
138  // ### Stator base values ###
140  Real mBase_V = 0;
142  Real mBase_V_RMS = 0;
144  Real mBase_I = 0;
146  Real mBase_I_RMS = 0;
148  Real mBase_Z = 0;
150  Real mBase_OmElec = 0;
152  Real mBase_OmMech = 0;
154  Real mBase_L = 0;
156  Real mBase_T = 0;
158  Real mBase_Psi = 0;
159 
161  Real mBase_ifd = 0;
163  Real mBase_vfd = 0;
165  Real mBase_Zfd = 0;
167  Real mBase_Lfd = 0;
168 
169  // ### Useful Matrices ### (still needed? )
176 
177  // ### State variables ###
179  Real mThetaMech = 0;
180 
181 public:
198 
199 protected:
209  Matrix mVsr;
219  Matrix mIsr;
229  Matrix mPsisr; //equivalent to Fluxes
232 
233  // #### dq-frame specific variables ####
235  Matrix mVdq0;
237  Matrix mIdq0;
245  Real mLad;
247  Real mLaq;
249  Real mDetLd;
251  Real mDetLq;
252 
256  Real mRcomp;
257 
260  void initPerUnitStates();
261 
262  // #### Controllers ####
264  Bool mHasTurbineGovernor = false;
266  Bool mHasExciter = false;
267 
268  // Deprecated
269  Real mInitTerminalVoltage = 0;
270  Real mInitVoltAngle = 0;
271 
273  explicit SynchronGenerator(CPS::AttributeList::Ptr attributeList)
274  : mRs(attributeList->create<Real>("Rs", 0)),
275  mLl(attributeList->create<Real>("Ll", 0)),
276  mLd(attributeList->create<Real>("Ld", 0)),
277  mLq(attributeList->create<Real>("Lq", 0)),
278  mLd_t(attributeList->create<Real>("Ld_t", 0)),
279  mLq_t(attributeList->create<Real>("Lq_t", 0)),
280  mLd_s(attributeList->create<Real>("Ld_s", 0)),
281  mLq_s(attributeList->create<Real>("Lq_s", 0)),
282  mTd0_t(attributeList->create<Real>("Td0_t", 0)),
283  mTq0_t(attributeList->create<Real>("Tq0_t", 0)),
284  mTd0_s(attributeList->create<Real>("Td0_s", 0)),
285  mTq0_s(attributeList->create<Real>("Tq0_s", 0)),
286  mDelta(attributeList->create<Real>("delta_r", 0)),
287  mMechTorque(attributeList->create<Real>("T_m", 0)),
288  mInertia(attributeList->create<Real>("inertia", 0)),
289  mOmMech(attributeList->create<Real>("w_r", 0)),
290  mElecActivePower(attributeList->create<Real>("P_elec", 0)),
291  mElecReactivePower(attributeList->create<Real>("Q_elec", 0)),
292  mMechPower(attributeList->create<Real>("P_mech", 0)),
293  mElecTorque(attributeList->create<Real>("T_e", 0)){};
294 
296  void setBaseParameters(Real nomPower, Real nomVolt, Real nomFreq);
298  void setBaseParameters(Real nomPower, Real nomVolt, Real nomFreq,
299  Real nomFieldCur);
300 
302  void calcStateSpaceMatrixDQ();
304  Real calcHfromJ(Real J, Real omegaNominal, Int polePairNumber);
305 
306 public:
308  virtual ~SynchronGenerator() {}
309 
311  void setBaseAndFundamentalPerUnitParameters(Real nomPower, Real nomVolt,
312  Real nomFreq, Real nomFieldCur,
313  Int poleNumber, Real Rs, Real Ll,
314  Real Lmd, Real Lmq, Real Rfd,
315  Real Llfd, Real Rkd, Real Llkd,
316  Real Rkq1, Real Llkq1, Real Rkq2,
317  Real Llkq2, Real inertia);
318 
322  Real nomPower, Real nomVolt, Real nomFreq, Int poleNumber,
323  Real nomFieldCur, Real Rs, Real Ld, Real Lq, Real Ld_t, Real Lq_t,
324  Real Ld_s, Real Lq_s, Real Ll, Real Td0_t, Real Tq0_t, Real Td0_s,
325  Real Tq0_s, Real inertia);
326 
328  void setFundamentalPerUnitParameters(Int poleNumber, Real Rs, Real Ll,
329  Real Lmd, Real Lmq, Real Rfd, Real Llfd,
330  Real Rkd, Real Llkd, Real Rkq1,
331  Real Llkq1, Real Rkq2, Real Llkq2,
332  Real inertia);
333 
335  void applyFundamentalPerUnitParameters();
336 
338  void setAndApplyFundamentalPerUnitParameters(Int poleNumber, Real Rs, Real Ll,
339  Real Lmd, Real Lmq, Real Rfd,
340  Real Llfd, Real Rkd, Real Llkd,
341  Real Rkq1, Real Llkq1, Real Rkq2,
342  Real Llkq2, Real inertia);
343 
345  void setOperationalPerUnitParameters(Int poleNumber, Real inertia, Real Rs,
346  Real Ld, Real Lq, Real Ll, Real Ld_t,
347  Real Lq_t, Real Ld_s, Real Lq_s,
348  Real Td0_t, Real Tq0_t, Real Td0_s,
349  Real Tq0_s);
350 
352  void calculateFundamentalFromOperationalParameters();
353 
355  void setInitialValues(Real initActivePower, Real initReactivePower,
356  Real initTerminalVolt, Real initVoltAngle,
357  Real initMechPower);
358 
360  void setNumericalMethod(NumericalMethod method) { mNumericalMethod = method; }
361 
363  std::shared_ptr<Signal::TurbineGovernor> mTurbineGovernor;
365  std::shared_ptr<Signal::Exciter> mExciter;
366 };
367 } // namespace Base
368 } // namespace CPS
Base synchronous generator model.
Matrix mIsr
Vector of stator and rotor currents.
StateType
State type of machine variables.
Real mNomFreq
nominal frequency fn [Hz]
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
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.
std::shared_ptr< Signal::Exciter > mExciter
Signal component modelling voltage regulator and exciter.
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]
SynchronGenerator(CPS::AttributeList::Ptr attributeList)
Constructor.
Real mLkq1
q-axis damper inductance 1 Lkq1 [H]
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]
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.
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
void addExciter(Real Ta, Real Ka, Real Te, Real Ke, Real Tf, Real Kf, Real Tr)
Add voltage regulator and exciter.
const Attribute< Real >::Ptr mRs
stator resistance Rs [Ohm]
Matrix mResistanceMat
resistance matrix
Real mLkq2
q-axis damper inductance 2 Lkq2 [H]
Real mDetLq
Determinant of q-axis inductance matrix.
void addGovernor(Real Ta, Real Tb, Real Tc, Real Fa, Real Fb, Real Fc, Real K, Real Tsr, Real Tsm, Real Tm_init, Real PmRef)
Add governor and turbine.
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.
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
const Attribute< Real >::Ptr mLq_s
Subtransient q-axis inductance [H].
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].
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 Turbine and Governor are 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].
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)