VoltageBehindReactanceEMT.h 6.29 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/** Voltage behind reactance (EMT)
 *
 * @file
 * @author Markus Mirz <mmirz@eonerc.rwth-aachen.de>
 * @copyright 2017, Institute for Automation of Complex Power Systems, EONERC
 * @license GNU General Public License (version 3)
 *
 * DPsim
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *********************************************************************************/

24
#pragma once
25

26
#include "SynchGenBase.h"
27
#include "Exciter.h"
28
#include "TurbineGovernor.h"
29
30
31
32

namespace DPsim {

	/// Synchronous generator model
Steffen Vogel's avatar
Steffen Vogel committed
33
	/// If parInPerUnit is not set, the parameters have to be given with their respective stator or rotor
34
35
36
37
38
	/// referred values. The calculation to per unit is performed in the initialization.
	/// The case where parInPerUnit is not set will be implemented later.
	/// parameter names include underscores and typical variables names found in literature instead of
	/// descriptive names in order to shorten formulas and increase the readability

39
	class VoltageBehindReactanceEMT : public SynchGenBase {
40
41
	protected:

42
43
44
45
		/// Exciter Model
		Exciter mExciter;
		bool WithExciter = false;

46
47
48
49
		/// Governor Model
		TurbineGovernor mTurbineGovernor;
		bool WithTurbineGovernor = false;

50
		/// d dynamic inductance
Markus Mirz's avatar
Markus Mirz committed
51
		Real mDLmd;
52
		/// q dynamic inductance
Markus Mirz's avatar
Markus Mirz committed
53
		Real mDLmq;
54
55

		/// Auxiliar inductance
Markus Mirz's avatar
Markus Mirz committed
56
		Real mLa;
57
		/// Auxiliar inductance
Markus Mirz's avatar
Markus Mirz committed
58
		Real mLb;
59
60
61


		/// d dynamic flux
Markus Mirz's avatar
Markus Mirz committed
62
		Real mDPsid;
63
		/// q dynamic flux
Markus Mirz's avatar
Markus Mirz committed
64
		Real mDPsiq;
65
		/// Dynamic d voltage
Markus Mirz's avatar
Markus Mirz committed
66
		Real mDVq;
67
		/// Dynamic q voltage
Markus Mirz's avatar
Markus Mirz committed
68
		Real mDVd;
69
		/// Dynamic voltage phase a
Markus Mirz's avatar
Markus Mirz committed
70
		Real mDVa;
71
		/// Dynamic voltage phase b
Markus Mirz's avatar
Markus Mirz committed
72
		Real mDVb;
73
		/// Dynamic voltage phase c
Markus Mirz's avatar
Markus Mirz committed
74
		Real mDVc;
Viviane Sapucaia's avatar
Viviane Sapucaia committed
75

76
		/// Interface voltage phase a
Markus Mirz's avatar
Markus Mirz committed
77
		Real mVa;
78
		/// Interface voltage phase b
Markus Mirz's avatar
Markus Mirz committed
79
		Real mVb;
80
		/// Interface voltage phase c
Markus Mirz's avatar
Markus Mirz committed
81
		Real mVc;
82

83
		/// Interface curent phase a
Markus Mirz's avatar
Markus Mirz committed
84
		Real mIa;
85
		/// Interface curent phase b
Markus Mirz's avatar
Markus Mirz committed
86
		Real mIb;
87
		/// Interface curent phase c
Markus Mirz's avatar
Markus Mirz committed
88
		Real mIc;
89

90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105

		/// Interface curent phase a last time step
		Real mIa_hist;
		/// Interface curent phase b last time step
		Real mIb_hist;
		/// Interface curent phase c last time step
		Real mIc_hist;

		///Load Resistance phase a
		Real Ra;
		///Load Resistance phase b
		Real Rb;
		///Load Resistance phase c
		Real Rc;


106
		/// Magnetizing flux linkage in q axis
Viviane Sapucaia's avatar
Viviane Sapucaia committed
107
		Real mPsimq;
108
		/// Magnetizing flux linkage in d axis
Viviane Sapucaia's avatar
Viviane Sapucaia committed
109
110
		Real mPsimd;

111
		/// Rotor flux vector
Markus Mirz's avatar
Markus Mirz committed
112
		Matrix mRotorFlux = Matrix::Zero(4, 1);
113
		/// Dq stator current vector
Markus Mirz's avatar
Markus Mirz committed
114
		Matrix mDqStatorCurrents = Matrix::Zero(2, 1);
115
		/// Dq stator current vector - from previous time step
Markus Mirz's avatar
Markus Mirz committed
116
		Matrix mDqStatorCurrents_hist = Matrix::Zero(2, 1);
Viviane Sapucaia's avatar
Viviane Sapucaia committed
117

118
119
		// ### Useful Matrices ###
		/// inductance matrix
Markus Mirz's avatar
Markus Mirz committed
120
		Matrix mDInductanceMat = Matrix::Zero(3, 3);
121
		/// Derivative of inductance matrix
Markus Mirz's avatar
Markus Mirz committed
122
		Matrix pmDInductanceMat = Matrix::Zero(3, 3);
123

124
		/// Load Resistance 
Markus Mirz's avatar
Markus Mirz committed
125
		Matrix R_load = Matrix::Zero(3, 3);
126

127
		/// Phase currents in pu
Markus Mirz's avatar
Markus Mirz committed
128
		Matrix mIabc = Matrix::Zero(3, 1);
129
		/// Subtransient voltage in pu
Markus Mirz's avatar
Markus Mirz committed
130
		Matrix mDVabc = Matrix::Zero(3, 1);
131
		Matrix mDVabc_hist = Matrix::Zero(3, 1);
Viviane Sapucaia's avatar
Viviane Sapucaia committed
132

133
		/// Matrix paremeters for integration of rotor flux linkages - A
Markus Mirz's avatar
Markus Mirz committed
134
		Matrix A_flux = Matrix::Zero(4, 4);
135
		/// Variables for integration of rotor flux linkages - B
Markus Mirz's avatar
Markus Mirz committed
136
		Matrix B_flux = Matrix::Zero(4, 2);
137
		/// Variables for integration of rotor flux linkages - C
Markus Mirz's avatar
Markus Mirz committed
138
		Matrix C_flux = Matrix::Zero(4, 1);
139

140
141
142

	public:
		VoltageBehindReactanceEMT() { };
143
		~VoltageBehindReactanceEMT();
144

Steffen Vogel's avatar
Steffen Vogel committed
145
		/// Initializes the per unit or stator referred machine parameters with the machine parameters given in per unit or
146
147
		/// stator referred parameters depending on the setting of parameter type.
		/// The initialization mode depends on the setting of state type.
148
		VoltageBehindReactanceEMT(String name, Int node1, Int node2, Int node3,
Markus Mirz's avatar
Markus Mirz committed
149
			Real nomPower, Real nomVolt, Real nomFreq, Int poleNumber, Real nomFieldCur,
150
			Real Rs, Real Ll, Real Lmd, Real Lmd0, Real Lmq, Real Lmq0,
151
152
			Real Rfd, Real Llfd, Real Rkd, Real Llkd,
			Real Rkq1, Real Llkq1, Real Rkq2, Real Llkq2,
153
			Real inertia, bool logActive = false);
154

155
		void AddExciter(Real Ta, Real Ka, Real Te, Real Ke, Real Tf, Real Kf, Real Tr, Real Lad, Real Rfd);
156
		void AddGovernor(Real Ta, Real Tb, Real Tc, Real Fa, Real Fb, Real Fc, Real K, Real Tsr, Real Tsm, Real Tm_init);
157

Steffen Vogel's avatar
Steffen Vogel committed
158
		/// Initializes states in per unit or stator referred variables depending on the setting of the state type.
159
160
		/// Function parameters have to be given in real units.
		void init(Real om, Real dt,
161
			Real initActivePower, Real initReactivePower, Real initTerminalVolt, Real initVoltAngle, Real initFieldVoltage, Real initMechPower);
162

Steffen Vogel's avatar
Steffen Vogel committed
163
		/// Performs an Euler forward step with the state space model of a synchronous generator
164
		/// to calculate the flux and current from the voltage vector.
165
		void step(SystemModel& system, Real time);
166

Steffen Vogel's avatar
Steffen Vogel committed
167
		/// Performs an Euler forward step with the state space model of a synchronous generator
168
		/// to calculate the flux and current from the voltage vector in per unit.
169
		void stepInPerUnit(Real om, Real dt, Real time, NumericalMethod numMethod);
170
171
172
173
174

		/// Retrieves calculated voltage from simulation for next step
		void postStep(SystemModel& system);

		/// Park transform as described in Krause
Markus Mirz's avatar
Markus Mirz committed
175
		Matrix parkTransform(Real theta, Real a, Real b, Real c);
176
177

		/// Inverse Park transform as described in Krause
Markus Mirz's avatar
Markus Mirz committed
178
		Matrix inverseParkTransform(Real theta, Real q, Real d, Real zero);
179

180
181
182
183
184
185
186
		/// Calculate inductance Matrix L and its derivative
		void CalculateLandpL();

		Matrix& getRotorFluxes() { return mRotorFlux; }
		Matrix& getDqStatorCurrents() { return mDqStatorCurrents; }
		Real getElectricalTorque() { return mElecTorque*mBase_T; }
		Real getRotationalSpeed() { return mOmMech*mBase_OmMech; }
Markus Mirz's avatar
Markus Mirz committed
187
		Real getRotorPosition() { return mThetaMech; }
188
189
190
191

		void init(Real om, Real dt) { }
		void applySystemMatrixStamp(SystemModel& system) { }
		void applyRightSideVectorStamp(SystemModel& system) { }
192

193
194
	};
}