simulator_models.tex 22.1 KB
Newer Older
Markus Mirz's avatar
Markus Mirz committed
1
2
3
4
\chapter{Simulator Models}

\section{Basic Components}

Viviane's avatar
Viviane committed
5
6
7
Every component is a part of the class "BaseComponent", which has as variables the name of the component and the nodes on which they are connected. Furthermore, four functions are defined in "BaseComponent":

\begin{itemize}
8
\item "init": This function initializes the values of the component variables. For  instance, initial values of current and voltage of inductors and capacitors.
Viviane's avatar
Viviane committed
9

10
\item "applySystemMatrixStamp": This function stamps the conductance matrix $G$.
Viviane's avatar
Viviane committed
11

12
\item "applyRightSideMatrixStamp": This function stamps the vector $A$.
Viviane's avatar
Viviane committed
13

14
\item "step": This function updates the values of the vector $A$ in each calculation step.
Viviane's avatar
Viviane committed
15

16
\item "postStep": This function updates the variables which depends on the solution of the equation $e=G^{-1} \cdot A$.
Viviane's avatar
Viviane committed
17
18
19
20
21
22
23
24
25
26
\end{itemize}

\subsection{Linear Resistor}
The linear resistor has the following parameters defined by the user:
\begin{itemize}
\item name: Name of the component
\item src: First node where the resistor is connected
\item dest: Second node where the resistor is connected
\item resistance: Resistance given in Ohms
\end{itemize}
27
28

The function "applySystemMatrixStamp" stamps the resistance to the conductance matrix $G$ as in section \ref{ResistorMatrixStamp} considering $j=src$ and $k=dest$.
Viviane's avatar
Viviane committed
29
30


Markus Mirz's avatar
Markus Mirz committed
31
32
\subsection{Inductor}

33
The inductor model is developed based on the Resistive Companion Method presented in section \ref{ResistiveCompanion}.
Viviane's avatar
Viviane committed
34

35
For a constant frequency and fixed time step, the value of $R_L$ will be constant. Therefore, the matrix stamp of the conductance matrix will be made just once. By the other hand, the value of $A_L$ needs to be updated each step, since it depends on the voltage and current of the inductor at the previous step.
Viviane's avatar
Viviane committed
36

Viviane's avatar
Viviane committed
37
38
39
40
41
42
The inductor has the following parameters defined by the user:

\begin{itemize}
\item name: Name of the component
\item src: First node where the inductor is connected
\item dest: Second node where the inductor is connected
Viviane's avatar
Viviane committed
43
\item inductance: Inductance given in H
Viviane's avatar
Viviane committed
44
45
\end{itemize}

46
The function "applySystemMatrixStamp" will stamp $R_L$ to the conductance matrix $G$ as in subsection, considering $j=src$ and $k=dest$. \ref{ResistiveCompanionInductor}
Viviane's avatar
Viviane committed
47

Viviane's avatar
Viviane committed
48
The function "init" defines as zero the initial values of current and voltage of the inductor as well the initial value of the equivalent current source $A_L$.
Viviane's avatar
Viviane committed
49

Viviane's avatar
Viviane committed
50
51
52
53
54
\begin{align*}
v_L(0)&=0V \\
i_L(0)&=0A \\
A_L(0)&=0A \\
\end{align*}
Markus Mirz's avatar
Markus Mirz committed
55

56
The function "step" is called each step. It recalculates the value of the equivalent current source $A_L(k)$, using equation \ref{eq:AL} and apply the stamp of the vector $A$ as in subsection \ref{ResistiveCompanionInductor}, considering $j=src$ and $k=dest$.
Viviane's avatar
Viviane committed
57

Viviane's avatar
Viviane committed
58
The function "poststep" will calculate the inductor voltage $v_L$, based on the solution of the vector $e$ at the actual step (k+1) and the inductor current, based on the calculated $v_L$ and on the value of $A_L$ from the previous step (k).
Viviane's avatar
Viviane committed
59

Viviane's avatar
Viviane committed
60
61
\begin{equation} \label{eq:inductorVoltage}
v_L(k+1) = e_{src}(k+1) - e_{dest}(k+1)
Viviane's avatar
Viviane committed
62
63
\end{equation}

Viviane's avatar
Viviane committed
64
65
\begin{equation} \label{eq:inductorCurrent}
i_L(k+1) = \frac{v_L(k+1)}{R_L} + A_L(k)
Viviane's avatar
Viviane committed
66
\end{equation}
Viviane's avatar
Viviane committed
67
 
Viviane's avatar
Viviane committed
68

Viviane's avatar
Viviane committed
69
\subsection{Capacitor}
Viviane's avatar
Viviane committed
70

Viviane's avatar
Viviane committed
71
The capacitor model is also developed based on the Resistive Companion Method and is similar to the inductor model.
Viviane's avatar
Viviane committed
72

Viviane's avatar
Viviane committed
73
It has the following parameters defined by the user:
Viviane's avatar
Viviane committed
74

Viviane's avatar
Viviane committed
75
76
77
78
79
80
81
\begin{itemize}
\item name: Name of the component
\item src: First node where the inductor is connected
\item dest: Second node where the inductor is connected
\item capacitance: Capacitance given in F
\end{itemize}

82
The function "applySystemMatrixStamp" will stamp $R_C$ to the conductance matrix $G$ as in subsection \ref{ResistiveCompanionCapacitor}, considering $j=src$ and $k=dest$.
Viviane's avatar
Viviane committed
83
84
85
86
87
88
89
90
91

The function "init" defines as zero the initial values of current and voltage of the capacitor as well the initial value of the equivalent current source $A_C$.

\begin{align*}
v_C(0)&=0V \\
i_C(0)&=0A \\
A_C(0)&=0A \\
\end{align*}

92
The function "step" is called each time step. It recalculates the value of the equivalent current source $A_C(k)$ as in equation \ref{eq:AC} and stamps its value to the vector $A$ as in subsection \ref{ResistiveCompanionCapacitor}, considering $j=src$ and $k=dest$.
Viviane's avatar
Viviane committed
93

94
The function "poststep" will calculate the capacitor voltage $v_C$, based on the solution of $e$ at the actual step (k+1) and the capacitor current, based on the calculated $v_C(k+1)$ and on the value of $A_C$ from the previous step (k).
Viviane's avatar
Viviane committed
95
96

\begin{equation}
Viviane's avatar
Viviane committed
97
v_C(k+1) = e_{src}(k+1) - e_{dest}(k+1)
Viviane's avatar
Viviane committed
98
99
\end{equation}

Markus Mirz's avatar
Markus Mirz committed
100
\begin{equation}
101
i_C(k+1) = \frac{v_C(k+1)}{R_C} - A_C(k)
Markus Mirz's avatar
Markus Mirz committed
102
\end{equation}
Viviane's avatar
Viviane committed
103
 
Markus Mirz's avatar
Markus Mirz committed
104

105
\subsection{Real Voltage Source} \label{sub:RealVoltageSource}
Markus Mirz's avatar
Markus Mirz committed
106

Viviane's avatar
Viviane committed
107
A real voltage source can be represented as a voltage source $V$ in series with a resistance $R$, with
Markus Mirz's avatar
Markus Mirz committed
108

Viviane's avatar
Viviane committed
109
\begin{equation}
Viviane's avatar
Viviane committed
110
V=Va \cdot cos(\omega t + \phi)
Viviane's avatar
Viviane committed
111
\end{equation}
Viviane's avatar
Viviane committed
112
In dynamic phasors the voltage source V becomes
Viviane's avatar
Viviane committed
113

Viviane's avatar
Viviane committed
114
\begin{equation}
Viviane's avatar
Viviane committed
115
116
117
118
119
120
121
V = Va \cdot cos (\phi) + jVa \cdot sin(\phi) 
\end{equation}

As nodal analysis does not support voltage source, it is transformed to a current source using the Norton Equivalent as shown in figure \ref{fig:Real_Voltage_Source}.

\begin{figure}[ht]
	\centering
122
	\includegraphics[scale=0.6]{img/RealVoltageSource.png} 
Viviane's avatar
Viviane committed
123
124
125
	\caption{Real Voltage Source}
	\label{fig:Real_Voltage_Source}
\end{figure}
Viviane's avatar
Viviane committed
126

127
The matrix stamp for a real voltage source is therefore as in equation \ref{eq:MatrixStampRealVS}.
Viviane's avatar
Viviane committed
128

129
\begin{align} \label{eq:MatrixStampRealVS}
Viviane's avatar
Viviane committed
130
131
132
133
134
135
136
137
138
139
140
141
\begin{split}
&
\begin{matrix}
& \cdots & j & \quad k & \cdots
\end{matrix}\\[-6pt]
\begin{matrix}
\vdots\\[6pt]
j\\[6pt]
k\\[6pt]
\vdots\\
\end{matrix}
&
Viviane's avatar
Viviane committed
142
\begin{bmatrix}
Viviane's avatar
Viviane committed
143
	\quad & \quad &  \\[6pt]
Viviane's avatar
Viviane committed
144
145
	\quad & \dfrac{1}{R} & \dfrac{-1}{R} & \quad  \\[6pt]
	\quad & \dfrac{-1}{R} & \dfrac{1}{R} & \quad \\[6pt]
Viviane's avatar
Viviane committed
146
	\quad &  & 
Viviane's avatar
Viviane committed
147
148
\end{bmatrix}
\begin{bmatrix}
Viviane's avatar
Viviane committed
149
150
151
152
	\quad \\[6pt]
	e_j(k+1)\\[6pt]
	e_k(k+1)\\[6pt]
	\quad
Viviane's avatar
Viviane committed
153
154
\end{bmatrix}
=
Viviane's avatar
Viviane committed
155
156
157
158
159
160
\begin{matrix}
\vdots\\[6pt]
j\\[6pt]
k\\[6pt]
\vdots\\
\end{matrix}
Viviane's avatar
Viviane committed
161
\begin{bmatrix}
Viviane's avatar
Viviane committed
162
	\quad \\[6pt]
Viviane's avatar
Viviane committed
163
164
	\dfrac{V}{R} \\[6pt]
	-\dfrac{V}{R} \\[6pt]
Viviane's avatar
Viviane committed
165
	\quad
Viviane's avatar
Viviane committed
166
\end{bmatrix}
Viviane's avatar
Viviane committed
167
168
\end{split}
\end{align}
Viviane's avatar
Viviane committed
169

Viviane's avatar
Viviane committed
170
The following parameters are defined by the user for the real voltage source:
Viviane's avatar
Viviane committed
171

Viviane's avatar
Viviane committed
172
173
\begin{itemize}
\item name: Name of the component
174
175
\item src: Node connected to voltage source positive terminal (j)
\item dest: Node connected to voltage source negative terminal (k)
Viviane's avatar
Viviane committed
176
177
178
179
\item voltage: Voltage in V
\item phase: Phase shift in degrees
\item resistance: Series resistance in ohms 
\end{itemize}
Viviane's avatar
Viviane committed
180

181
The function "applySystemMatrixStamp" will stamp the resistance at the conductance matrix $G$.
Viviane's avatar
Viviane committed
182
The function "applyRightSideVectorStamp" will stamp the equivalent current source $I=\frac{V}{R}$ to the vector $A$.
183
The function "step" will repeat the stamp of the vector $A$ each time step.
Viviane's avatar
Viviane committed
184

Viviane's avatar
Viviane committed
185
\subsection{Ideal Voltage Source}
Markus Mirz's avatar
Markus Mirz committed
186

187
The model of the ideal voltage source uses the modified nodal analysis as presented in subsection \ref{IdealVoltageSource}.
Viviane's avatar
Viviane committed
188
The following parameters are defined by the user:
189

Viviane's avatar
Viviane committed
190
191
192
193
194
195
196
197
\begin{itemize}
\item name: Name of the component
\item src: Node connected to voltage source positive terminal
\item dest: Node connected to voltage source negative terminal
\item voltage: Voltage in V
\item phase: Phase shift in degrees
\item num: Number of the voltage source (the voltage sources have to be numbered in sequence) 
\end{itemize}
198

199
The function "applyMatrixStamp" will stamp the conductance matrix according to subsection \ref{IdealVoltageSource}. The additional unknown $i_{jk}$ of the voltage source number 1 (with variable num=1) will be added in the first line after the last node voltage and so on. Therefore, for a circuit with n voltage sources and m nodes, the vector of unknown variable $e$ and the vector $A$ will have the size $m+n$. The conductance matrix G will have the size $(m+n)X(m+n)$.
200
201

\begin{equation}
Viviane's avatar
Viviane committed
202
203
204
205
206
207
208
209
210
	e=
	\begin{bmatrix}
		e_1 \\
		\vdots \\
		e_m \\
		i_1 \\
		\vdots \\
		i_n
	\end{bmatrix}
211
212
\end{equation}

Viviane's avatar
Viviane committed
213
214
The function "applyRightSideVectorStamp" will stamp the voltage at the corresponding line of the vector $A$.
The function step will repeat the stamp of the vector $A$ each time step.
Markus Mirz's avatar
Markus Mirz committed
215

Viviane's avatar
Viviane committed
216
\subsection{Current Source}
Markus Mirz's avatar
Markus Mirz committed
217

Viviane's avatar
Viviane committed
218
For the current source, the following parameters are defined by the user:
Markus Mirz's avatar
Markus Mirz committed
219

Viviane's avatar
Viviane committed
220
221
222
223
224
225
226
\begin{itemize}
\item name: Name of the component
\item src: Node connected to current source positive terminal
\item dest: Node connected to current source negative terminal
\item current: Current in A
\item phase: Phase shift in degrees
\end{itemize}
Markus Mirz's avatar
Markus Mirz committed
227

228
The function "applyRightSideVectorStamp" will stamp the current at the vector $A$ as in subsection \ref{CurrentSourceMatrixStamp}.
229

Viviane's avatar
Viviane committed
230
231
\subsection{RX Line}
The RX Line model corresponds to a resistance in series with a inductance. The inductance is represented using resistive companion and therefore replaced by a resitance in parallel to a current source.
232

Viviane's avatar
Viviane committed
233
The user can define the RX Line in two ways. The first one is with the following parameters:
234

Viviane's avatar
Viviane committed
235
236
237
238
239
240
241
242
\begin{itemize}
\item name: Name of the component
\item node1: First node, where the resistance is connected
\item node2: Second node, where the inductance is connected
\item node3: Node between resistance and inductance 
\item resistance: Resistance in ohms
\item inductance: Inductance in H
\end{itemize}
243

244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
\begin{figure}[h]
	\centering
	\includegraphics[scale=0.5]{img/RxLine.png} 
	\caption{RX Line model}
	\label{fig:RxLine}
\end{figure}

In this case, the function "applySystemMatrixStamp" will stamp the resistances $R$ between node1 and node3 and $R_L$ between node3 and node2 to the conductance matrix $G$. The function "step" will recalculate the value of $A_L$ as in equation \ref{eq:AL} and stamp it between node3 and node2 to the vector $A$. The function "poststep" will update the values of inductor current and voltage using equations \ref{eq:inductorCurrent} and \ref{eq:inductorVoltage}.

\begin{align}
\begin{split}
&
\begin{matrix}
& \cdots & node1 & node2 &  node3 & \cdots
\end{matrix}\\[-6pt]
G \quad = \quad
\begin{matrix}
\vdots\\[8pt]
node1\\[8pt]
node2\\[8pt]
node3\\[8pt]
\vdots\\
\end{matrix}
&
\begin{bmatrix}
	\quad & \quad &  \\[8pt]
	\quad & \quad \dfrac{1}{R} & \quad & \quad \dfrac{-1}{R} & \quad  \\[8pt]
	\quad & \quad & \quad \dfrac{1}{R_L} & \quad \dfrac{-1}{R_L} & \quad \\[8pt]
	\quad & \quad \dfrac{-1}{R} & \quad \dfrac{-1}{R_L} & \dfrac{1}{R}+\dfrac{1}{R_L} & \quad\\[8pt]
	\quad\\ 
\end{bmatrix}
\end{split}
\end{align}
\begin{align}
\begin{split}
A\quad = \quad
\begin{matrix}
\vdots\\[8pt]
node1\\[8pt]
node2\\[8pt]
node3\\[8pt]
\vdots\\
\end{matrix}
\begin{bmatrix}
	\quad \\[8pt]
	\quad \\[8pt]
	A_L(k) \\[8pt]
	-A_L(k) \\[8pt]
	\quad
\end{bmatrix}
\end{split}
\end{align}
296

297
The second way of define the RX Line is defining only two nodes (node1 and node2). In this case, the equivalent circuit in figure \ref{fig:RxLine2} is considered.
298
299
300

\begin{figure}[ht]
	\centering
Viviane's avatar
Viviane committed
301
302
303
	\includegraphics[scale=0.5]{img/RxLine2.png} 
	\caption{RX Line model with two nodes}
	\label{fig:RxLine2}
304
305
\end{figure}

306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
The function "applySystemMatrixStamp" will stamp the resistance $R+R_L$ between node1 and node2 to the conductance matrix $G$.

\begin{align}
\begin{split}
&
\begin{matrix}
& \cdots & node1 & \quad node2 & \cdots
\end{matrix}\\[-5pt]
G \quad = \quad
\begin{matrix}
\vdots\\[6pt]
node1\\[6pt]
node2\\[6pt]
\vdots\\
\end{matrix}
&
\begin{bmatrix}
	\quad & \quad &  \\[6pt]
	\quad & \dfrac{1}{R+R_L} & \dfrac{-1}{R+R_L} & \quad  \\[6pt]
	\quad & \dfrac{-1}{R+R_L} & \dfrac{1}{R+R_L} & \quad \\[6pt]
	\quad &  & 
\end{bmatrix}
\end{split}
\end{align}

The function "step" will update the values of $A_L$ as in equation \ref{eq:AL} and $A_{Leq}(k)$. $A_{Leq}$ will be stamped to the vector $A$ as in equation \ref{eq:AleqStamp}.

333
\begin{equation}
334
A_{Leq}(k)=A_L(k) \cdot \frac{R_L}{R_L+R}
335
336
\end{equation}

337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
\begin{align} \label{eq:AleqStamp}
\begin{split}
A\quad = \quad
\begin{matrix}
\vdots\\[8pt]
node1\\[8pt]
node2\\[8pt]
\vdots\\
\end{matrix}
\begin{bmatrix}
	\quad \\[8pt]
	-A_{Leq}(k) \\[8pt]
	A_{Leq}(k) \\[8pt]
	\quad
\end{bmatrix}
\end{split}
\end{align}

The function "poststep" will calculate the values of the line voltage and current and inductor voltage and current for the actual step (k+1).

\begin{equation}
	v_{Line}(k+1) = v_{node1}(k+1) - v_{node2}(k+1) 
\end{equation}

\begin{equation}
	i_{Line}(k+1) = \frac{v_{Line}(k+1)}{R+R_L} + A_{Leq} 
\end{equation}

\begin{equation}
	v_L(k+1) = v_{Line}(k+1) - R \cdot i_{Line}(k+1)
\end{equation}

\begin{equation}
	i_L(k+1) = i_{Line}(k+1)
\end{equation}
372

373
In both cases, the function "init" is setting every initial value to zero.
Viviane's avatar
Viviane committed
374
 
375
376
377
378
379
\section{Synchronous Machine}

The model is according to \cite{wang2010methods} and \cite{kundur1994power}. 

\subsubsection{Prerequisites}
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450


\subsubsection{Magnetic Circuits}

Considering two magnetically coupled windings with number of turns $N_1$ and $N_2$, resistance $r_1$ and $r_2$ and winding currents $i_1$ and $i_2$ respectively, the flux linkage with the respective windings, produced by the total effect of both currents are given by equations \ref{eq:FluxLinkage1} and \ref{eq:FluxLinkage2}.

\begin{equation} \label{eq:FluxLinkage1}
	\Psi_1 = N_1(\Phi_{l1} + \Phi_{m1} + \Phi_{m2})
\end{equation}
\begin{equation} \label{eq:FluxLinkage2}
	\Psi_2 = N_2(\Phi_{l2} + \Phi_{m2} + \Phi_{m1})
\end{equation}
\\
where

$\Phi_{m1}$ is the mutual flux linking both windings due to current $i_1$;

$\Phi_{m2}$ is the mutual flux linking both windings due to current $i_2$;

$\Phi_{l1}$ is the leakage flux linking winding 1 only;

$\Phi_{l2}$ is the leakage flux linking winding 2 only.

The flux linkage can also be expressed in terms of self and mutual inductance as in equation \ref{eq:FluxLinkageInductances}

\begin{equation} \label{eq:FluxLinkageInductances}
	\begin{bmatrix}
		\Psi_1\\
		\Psi_2
	\end{bmatrix}
		=
	\begin{bmatrix}
		L_{11} & L_{12}\\
		L_{21} & L_{22}
	\end{bmatrix}
		\cdot
	\begin{bmatrix}
		i_1\\
		i_2		
	\end{bmatrix}
\end{equation}
\\
where $L_{11}$ and $L_{22}$ are the self inductances of windings 1 and 2 respectively and defined as the flux linkage per unit current in the same winding. $L_{12}$ and $L_{21}$ are the mutual inductance between two windings, defined as the flux linkage with one winding per unit current in the other winding.

\begin{equation}
	L_{11} = N_1(\Phi_{m1} + \Phi_{l1}) / i_1
\end{equation}
\begin{equation}
	L_{22} = N_2(\Phi_{m2} + \Phi_{l2}) / i_2
\end{equation}

\begin{equation}
	L_{12} = N_1 \Phi_{m2} / i_2
\end{equation}
\begin{equation}
	L_{21} = N_2 \Phi_{m1} / i_1
\end{equation}

The terminal voltages $e_1$ and $e_2$ are defined as following:

\begin{equation} \label{eq:VoltageEquation1}
	e_1 = \frac{d \Psi_1}{d t} + r_1 i_1
\end{equation}
\begin{equation} \label{eq:VoltageEquation2}
	e_2 = \frac{d \Psi_2}{d t} + r_2 i_2
\end{equation}

Equations \ref{eq:FluxLinkageInductances}, \ref{eq:VoltageEquation1} and \ref{eq:VoltageEquation2} give the performance of the circuit.

\subsubsection{Park's transformation}

451
452
453
454
455
456
457
458
459
460
461
Park's transformation is commonly used to achieve a model with static parameters:
%
\begin{equation}
\mathbf{K_s} = \frac{2}{3}
 \begin{bmatrix} 
  \cos \theta & \cos(\theta-\frac{2\pi}{3}) & \cos(\theta+\frac{2\pi}{3}) \\
  \sin \theta & \sin(\theta-\frac{2\pi}{3}) & \sin(\theta+\frac{2\pi}{3}) \\
  \frac{1}{2} & \frac{1}{2} & \frac{1}{2}
 \end{bmatrix}
\end{equation}
%
462
463
464
465
466
467
468
469
470
471
472
473
Note that the scaling factor $\frac{2}{3}$, which ensures an equal length of the current dq-axis and stator reference frame current, is not always used. 
%
\begin{equation}
(\mathbf{K_s})^{-1} = 
 \begin{bmatrix} 
  \cos \theta & \sin \theta & 1 \\
  \cos(\theta-\frac{2\pi}{3}) & \sin(\theta-\frac{2\pi}{3}) & 1 \\
  \cos(\theta+\frac{2\pi}{3}) & \sin(\theta+\frac{2\pi}{3}) & 1
 \end{bmatrix}
\end{equation}
%
where $\theta$ is the rotor angle in this case.
474
475
476
477
478
479

\subsubsection{Model}

The mechanical equations are:
%
\begin{align}
480
481
\frac{d\theta_r}{dt} &= \omega_r \label{eq:d_theta} \\
\frac{d\omega_r}{dt} &= \frac{P}{2J} (T_e-T_m) \label{eq:d_omega}
482
483
484
485
486
487
488
489
490
491
\end{align}
%
where $\theta_r$ is the rotor position, $\omega_r$ is the angular electrical speed, $P$ is the number of poles, $J$ is the moment of inertia, $T_m$ and $T_e$ are the mechanical and electrical torque, respectively. Motor convention is used for all models. 

The electrical model in the phase domain is described by the following equations:
%
\begin{align}
  \mathbf{v}_{abcs} &= \mathbf{R}_s \mathbf{i}_{abcs} + \frac{d}{dt} \boldsymbol{\lambda}_{abcs} \\
  \mathbf{v}_{qdr} &= \mathbf{R}_r \mathbf{i}_{qdr} + \frac{d}{dt}  \boldsymbol{\lambda}_{qdr}
\end{align}
492
493
494
495
496
%
where
%
\begin{align}
  \mathbf{v}_{abcs} &= 
497
  \begin{pmatrix}
498
    v_{as} & v_{bs} & v_{cs}
499
  \end{pmatrix}^T \\
500
501
  %  
  \mathbf{v}_{qdr} &= 
502
  \begin{pmatrix}
503
    v_{kq1} & v_{kq2} & v_{fd} & v_{kd} 
504
  \end{pmatrix}^T \\
505
506
  %
  \mathbf{i}_{abcs} &= 
507
  \begin{pmatrix}
508
    i_{as} & i_{bs} & i_{cs}
509
  \end{pmatrix}^T \\
510
511
  %  
  \mathbf{i}_{qdr} &= 
512
  \begin{pmatrix}
513
    i_{kq1} & i_{kq2} & i_{fd} & i_{kd} 
514
  \end{pmatrix}^T \\
515
516
  %
  \boldsymbol{\lambda}_{abcs} &= 
517
  \begin{pmatrix}
518
    \lambda_{as} & \lambda_{bs} & \lambda_{cs}
519
  \end{pmatrix}^T \\
520
521
  %  
  \boldsymbol{\lambda}_{qdr} &= 
522
  \begin{pmatrix}
523
    \lambda_{kq1} & \lambda_{kq2} & \lambda_{fd} & \lambda_{kd} 
524
  \end{pmatrix}^T \\
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
  %
  \mathbf{R}_s &= diag
  \begin{bmatrix}
    r_s & r_s & r_s 
  \end{bmatrix} \\
  %
  \mathbf{R}_r &= diag
  \begin{bmatrix}
    r_{kq1} & r_{kq2} & r_{fd} & r_{kd}
  \end{bmatrix}
\end{align}
%
The flux linkages are:
%
\begin{align}
  \boldsymbol{\lambda}_{abcs} &= \mathbf{L}_{ss} \mathbf{i}_{abcs} + \mathbf{L}_{sr} \mathbf{i}_{qdr}  \\
541
  \boldsymbol{\lambda}_{qdr} &= \mathbf{L}_{rs} \mathbf{i}_{abcs} + \mathbf{L}_{rr} \mathbf{i}_{qdr}
542
543
544
545
546
547
548
549
550
\end{align}
%
where the inductances are time variant variables as defined in \cite{krause2002sudhoff}.
TODO: electromagnetic torque

\subsubsection{Equations in Rotor Reference Frame}

This section depicts the synchronous generator equations in terms of machine variables referred to the stator windings which is indicated by the prime symbol. Due to the transform of the stator variables to the rotor reference frame, the stator equations change, whereas the rotor equations remain the same.
%
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
\begin{equation}
  \begin{pmatrix}
    \mathbf{v}_{qd0s} \\
    \mathbf{v}_{qdr}
  \end{pmatrix}
  =  
  \mathbf{R}'
  \begin{pmatrix}
    \mathbf{i}_{qd0s} \\
    \mathbf{i}_{qdr}'
  \end{pmatrix}
  +
  \frac{d}{dt}
  \begin{pmatrix}
    \boldsymbol{\lambda}_{qd0s} \\
    \boldsymbol{\lambda}_{qdr}'
  \end{pmatrix}
  + \omega_r
  \begin{pmatrix}
    \boldsymbol{\lambda}_{dqs} \\
    0
  \end{pmatrix}
\end{equation}
574
575
576
577
%
where
%
\begin{align}
578
  \mathbf{R}' &= diag
579
  \begin{bmatrix}
580
581
582
583
    r_s & r_s & r_s & r_{kq1}' & r_{kq2}' & r_{fd}' & r_{kd}' 
  \end{bmatrix} \\
  \boldsymbol{\lambda}_{dqs} &= 
  \begin{pmatrix}
584
    \lambda_{ds} & -\lambda_{qs} & 0
585
  \end{pmatrix}^T
586
587
588
589
\end{align}
%
The flux linkages are:
%
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
\begin{equation}
  \begin{pmatrix}
    \boldsymbol{\lambda}_{qd0s} \\
    \boldsymbol{\lambda}_{qdr}'
  \end{pmatrix}
  =
  \begin{bmatrix}
    \mathbf{L}_{qdss} & \mathbf{L}_{qdsr}' \\
    \mathbf{L}_{qdrs}' & \mathbf{L}_{rr}'    
  \end{bmatrix}
  \begin{pmatrix}
    \mathbf{i}_{qd0s} \\
    \mathbf{i}_{qdr}'
  \end{pmatrix}
  \label{eq:flux}
\end{equation}
606
607
608
609
610
611
612
%
where
%
\begin{align}
  \mathbf{L}_{qdss} &= 
  \begin{bmatrix}
    L_{q} & 0 & 0 \\
613
    0 & L_{d} & 0 \\
614
615
616
    0 & 0 & L_{ls}
  \end{bmatrix} \\
  %  
617
  \mathbf{L}_{qdsr}' &= 
618
619
620
621
622
623
  \begin{bmatrix}
    L_{mq} & L_{mq} & 0 & 0 \\
    0 & 0 & L_{md} & L_{md} \\
    0 & 0 & 0 & 0
  \end{bmatrix} \\
  %
624
  \mathbf{L}_{qdrs}' &=
625
626
627
628
629
630
631
  \begin{bmatrix}
    L_{mq} & 0 & 0 \\
    L_{mq} & 0 & 0 \\
    0 & L_{md} & 0 \\
    0 & L_{md} & 0
  \end{bmatrix} \\
  %
632
  \mathbf{L}_{rr}' &=
633
  \begin{bmatrix}
634
635
636
637
    L_{kq1}' & L_{mq} & 0 & 0 \\
    L_{mq} & L_{kq2}' & 0 & 0 \\
    0 & 0 & L_{fd}' & L_{md} \\
    0 & 0 & L_{md} & L_{kd}'
638
639
640
641
642
643
644
645
646
  \end{bmatrix} \\
  %
\end{align}
%
with 
%
\begin{align}
  L_{q} &= L_{ls} + L_{mq} \\
  L_{d} &= L_{ls} + L_{md} \\
647
648
649
650
  L_{kq1'} &= L_{lkq1'} + L_{mq} \\
  L_{kq2'} &= L_{lkq2'} + L_{mq} \\
  L_{fd'} &= L_{lfd'} + L_{md} \\
  L_{kd'} &= L_{lkd'} + L_{md}
651
\end{align}
652

653
\subsubsection{State Space Model}
654
The flux linkage variables are chosen as electrical states of the state-space representation. Then, the currents can be calculated from equation \ref{eq:flux}.
655
656
657
658
%
\begin{equation}
  \frac{d}{dt}
  \begin{pmatrix}
659
660
    \boldsymbol{\lambda}_{qd0s} \\
    \boldsymbol{\lambda}_{qdr}'
661
  \end{pmatrix}
662
  =
663
664
  \begin{pmatrix}
    \mathbf{v}_{qd0s} \\
665
    \mathbf{v}_{qdr}'
666
  \end{pmatrix}
667
  - \mathbf{R}'
668
669
  \begin{pmatrix}
    \mathbf{i}_{qd0s} \\
670
    \mathbf{i}_{qdr}'
671
672
673
  \end{pmatrix}
  - \omega_r
  \begin{pmatrix}
674
    \boldsymbol{\lambda}_{dqs} \\
675
676
677
678
    0
  \end{pmatrix}
\end{equation}
%
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
or
%
\begin{equation}
  \frac{d}{dt}
  \begin{pmatrix}
    \boldsymbol{\lambda}_{qd0s} \\
    \boldsymbol{\lambda}_{qdr}'
  \end{pmatrix}
  =
  \begin{pmatrix}
    \mathbf{v}_{qd0s} \\
    \mathbf{v}_{qdr}'
  \end{pmatrix}
  - \mathbf{R}'
  \begin{bmatrix}
    \mathbf{L}_{qdss} & \mathbf{L}_{qdsr}' \\
    \mathbf{L}_{qdrs}' & \mathbf{L}_{rr}'    
  \end{bmatrix}^{-1}
  \begin{pmatrix}
    \boldsymbol{\lambda}_{qd0s} \\
    \boldsymbol{\lambda}_{qdr}
  \end{pmatrix}  
    - \omega_r
  \begin{pmatrix}
    \boldsymbol{\lambda}_{dqs} \\
    0
  \end{pmatrix}
\end{equation}
%
since the currents are 
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
%
\begin{align} 
   \begin{pmatrix}
    \mathbf{i}_{qd0s} \\
    \mathbf{i}_{qdr}'
  \end{pmatrix}
  = 
  \begin{bmatrix}
    \mathbf{L}_{qdss} & \mathbf{L}_{qdsr}' \\
    \mathbf{L}_{qdrs}' & \mathbf{L}_{rr}'    
  \end{bmatrix}^{-1}
  \begin{pmatrix}
    \boldsymbol{\lambda}_{qd0s} \\
    \boldsymbol{\lambda}_{qdr}
  \end{pmatrix}
\end{align}
%
The voltages of the damper windings are always zero since they are short-circuited. The state-space representation of the mechanical part is
%
\begin{align}
 \frac{d}{dt}
  \begin{pmatrix}
    \theta_r \\
    \omega_r
  \end{pmatrix}
  =
  \begin{bmatrix}
    0 & 1 \\
    0 & 0 \\
  \end{bmatrix}
  \begin{pmatrix}
    \theta_r \\
    \omega_r
  \end{pmatrix}
  + 
  \begin{pmatrix}
    0 \\
    \frac{P}{2J} \left( T_e - T_m \right)
  \end{pmatrix} 
\end{align}
%
where the electric torque is
%
\begin{equation}
  T_e = \frac{3P}{4} \left( \boldsymbol{\lambda}_{ds} \mathbf{i}_{qs} - \boldsymbol{\lambda}_{qs} \mathbf{i}_{ds} \right)
\end{equation}
%

\subsubsection{Alternative State Space Representation}
Defining q- and d-axis flux linkages 
%
\begin{align}
  \lambda_{mq} &= L_{mq} \left( i_{qs} + i_{kq1}' + i_{kq2}' \right) \\
  \lambda_{md} &= L_{md} \left( i_{ds} + i_{fd}' + i_{kd}' \right) \\
\end{align}
%
765
allows to rewrite the equations