> For the complete documentation index, see [llms.txt](https://www.opal-rt.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.opal-rt.com/docs/rt-lab/simulink-blocks-reference/efpgasim-library/simulink-sps-workflow/machines/generic-machines/synchronous-machine-model.md).

# Synchronous Machine Model

## Introduction <a href="#introduction" id="introduction"></a>

This document presents the formulation implemented on FPGA for **Synchronous machine with Round and Salient-pole rotors** as well as the mechanical model. The three-phase to q-d park transform has the 3/2 factor in rotor reference frame. The machine can operate in both motor mode, when the mechanical torque is positive, and generating mode, when the mechanical torque is negative.

## State space representation

The modeling of the Generic Machines is based on state space equations. The forward Euler discretization of the state space model can be presented as follows:

$$
x(n+1) = x(n) + T\_s \left( A(n)x(n) + B(n)u(n) \right)  \\\[8pt] y(n+1) = C(n+1)x(n+1)
$$

The state space equation can be simplified into:

$$
x(n+1) = A\_d(n)x(n) + B\_d(n)u(n) \\\[8pt]
y(n+1) = C(n+1)x(n+1)
$$

where

$$
A\_d(n) = T\_sA(n) + eye \\\[8pt]
B\_d(n) = T\_sB(n)
$$

## Q-d transformation

The 3-phase to q-d transformation and the inverse used for the model are:

$$
\begin{bmatrix} V\_q \ V\_d \ V\_0 \end{bmatrix} = \frac{2}{3} \begin{bmatrix} \cos(\theta) & \cos!\left(\theta-\frac{2\pi}{3}\right) & \cos!\left(\theta+\frac{2\pi}{3}\right) \ \sin(\theta) & \sin!\left(\theta-\frac{2\pi}{3}\right) & \sin!\left(\theta+\frac{2\pi}{3}\right) \ \frac{1}{2} & \frac{1}{2} & \frac{1}{2} \end{bmatrix} \begin{bmatrix} V\_a \ V\_b \ V\_c \end{bmatrix} \\\[14pt]
\begin{bmatrix} V\_a \ V\_b \ V\_c \end{bmatrix} = \begin{bmatrix} \cos(\theta) & \sin(\theta) & 1 \ \cos!\left(\theta-\frac{2\pi}{3}\right) & \sin!\left(\theta-\frac{2\pi}{3}\right) & 1 \ \cos!\left(\theta+\frac{2\pi}{3}\right) & \sin!\left(\theta+\frac{2\pi}{3}\right) & 1 \end{bmatrix} \begin{bmatrix} V\_q \ V\_d \ V\_0 \end{bmatrix}
$$

Since the Synchronous Machine is modeled in rotor reference frame, the θ required for the q-d transformation is the rotor electrical angle.

## Electrical model <a href="#synchronous-machine-electrical-model" id="synchronous-machine-electrical-model"></a>

Electric machine models in state space framework based on magnetic fluxes as the state variables and winding currents as the outputs can be represented as follows:

$$
\psi(n+1) = A\_d(n)\psi(n) + B\_d(n)u(n) \\\[8pt] I(n+1) = C(n+1)\psi(n+1)
$$

where the coefficient matrices are the same for all electric machine types as follows:

$$
A\_d = T\_s\left(-RL^{-1}-\Omega\right) + eye \\\[8pt]
B\_d = T\_s \times eye \\\[8pt] C = L^{-1}
$$

### Round Rotor (up to 3 damper windings)

$$
I = \begin{bmatrix} I\_{sq} & I\_{sd} & I\_{0} & I\_f' & I\_{kd}' & I\_{kq1}' & I\_{kq2}' \end{bmatrix}^{t} \\\[8pt]
\psi = \begin{bmatrix} \psi\_{sq} & \psi\_{sd} & \psi\_{0} & \psi\_f' & \psi\_{kd}' & \psi\_{kq1}' & \psi\_{kq2}' \end{bmatrix}^{t} \\\[8pt] R = \begin{bmatrix} R\_s & R\_s & R\_0 & R\_f' & R\_{kd}' & R\_{kq1}' & R\_{kq2}' \end{bmatrix}^{t} \\\[12pt] L = \begin{bmatrix} L\_q & 0 & 0 & 0 & 0 & L\_{mq} & L\_{mq} \ 0 & L\_d & 0 & L\_{md} & L\_{md} & 0 & 0 \ 0 & 0 & L\_0 & 0 & 0 & 0 & 0 \ 0 & L\_{md} & 0 & L\_f' & L\_{md} & 0 & 0 \ 0 & L\_{md} & 0 & L\_{md} & L\_{kd}' & 0 & 0 \ L\_{mq} & 0 & 0 & 0 & 0 & L\_{kq1}' & L\_{mq} \ L\_{mq} & 0 & 0 & 0 & 0 & L\_{mq} & L\_{kq2}' \end{bmatrix} \\\[12pt] \Omega = \begin{bmatrix} 0 & \omega & 0 & 0 & 0 & 0 & 0 \ -\omega & 0 & 0 & 0 & 0 & 0 & 0 \ 0 & 0 & 0 & 0 & 0 & 0 & 0 \ 0 & 0 & 0 & 0 & 0 & 0 & 0 \ 0 & 0 & 0 & 0 & 0 & \omega-\omega\_r & 0 \ 0 & 0 & 0 & 0 & -(\omega-\omega\_r) & 0 & \omega-\omega\_r \ 0 & 0 & 0 & 0 & 0 & -(\omega-\omega\_r) & 0 \end{bmatrix}
$$

### Salient-pole Rotor (up to 2 damper windings)

$$
I = \begin{bmatrix} I\_{sq} & I\_{sd} & I\_{0} & I\_f' & I\_{kd}' & I\_{kq1}' \end{bmatrix}^{t} \\\[8pt] \psi = \begin{bmatrix} \psi\_{sq} & \psi\_{sd} & \psi\_{0} & \psi\_f' & \psi\_{kd}' & \psi\_{kq1}' \end{bmatrix}^{t} \\\[8pt] R = \begin{bmatrix} R\_s & R\_s & R\_0 & R\_f' & R\_{kd}' & R\_{kq1}' \end{bmatrix}^{t} \\\[12pt] L = \begin{bmatrix} L\_q & 0 & 0 & 0 & 0 & L\_{mq} \ 0 & L\_d & 0 & L\_{md} & L\_{md} & 0 \ 0 & 0 & L\_0 & 0 & 0 & 0 \ 0 & L\_{md} & 0 & L\_f' & L\_{md} & 0 \ 0 & L\_{md} & 0 & L\_{md} & L\_{kd}' & 0 \ L\_{mq} & 0 & 0 & 0 & 0 & L\_{kq1}' \end{bmatrix} \\\[12pt] \Omega = \begin{bmatrix} 0 & \omega & 0 & 0 & 0 & 0 \ -\omega & 0 & 0 & 0 & 0 & 0 \ 0 & 0 & 0 & 0 & 0 & 0 \ 0 & 0 & 0 & 0 & 0 & 0 \ 0 & 0 & 0 & 0 & 0 & \omega-\omega\_r \ 0 & 0 & 0 & 0 & -(\omega-\omega\_r) & 0 \end{bmatrix}
$$

The Synchronous Machine is modeled in rotor reference frame so ω=ωr.

The electrical torque can be calculated as follows:

$$
T\_e = \frac{3}{2}pp\left(\psi\_d i\_q - \psi\_q i\_d\right)
$$

## Mechanical model <a href="#mechanical-model" id="mechanical-model"></a>

The mechanical model is the same for all machine types to calculate the rotor mechanical speed (ωm) as follows:

$$
T\_e - T\_m = J\dot{\omega}\_m + F\_v\omega\_m + F\_s
$$

## Nomenclature <a href="#nomenclature" id="nomenclature"></a>

* **x**: state variables vector
* **y**: outputs vector
* **u**: inputs vector
* **A**,**B**,**C**: state space coefficient matrices
* Ts: simulation time step
* n: time step number
* Va: stator phase a voltage
* Vb: stator phase b voltage
* Vc: stator phase c voltage
* Vsq: stator q-axis voltage
* Vsd: stator d-axis voltage
* V0: zero sequence voltage
* V'fd: field voltage (referred to the stator)
* **I**: current vector
* Isq: stator q-axis current
* Isd: stator d-axis current
* I0: zero sequence current
* I'f: field winding current (referred to the stator)
* I'kd: damper 1 winding current (referred to the stator)
* I'kq1: damper 2 winding current (referred to the stator)
* I'kq2: damper 3 winding current (referred to the stator)
* **Ψ**: magnetic flux vector
* ψsq: stator q-axis magnetic flux
* ψsd: stator d-axis magnetic flux
* ψ0: zero sequence magnetic flux
* ψ'f: field winding magnetic flux (referred to the stator)
* ψ'kd: damper 1 winding magnetic flux (referred to the stator)
* ψ'kq1: damper 2 winding magnetic flux (referred to the stator)
* ψ'kq2: damper 3 winding magnetic flux (referred to the stator)
* **R**: resistance matrix
* Rs: stator winding resistance
* R0: neutral resistance
* R'f: field winding resistance (referred to the stator)
* R'kd: damper 1 winding resistance (referred to the stator)
* R'kq1: damper 2 winding resistance (referred to the stator)
* R'kq2: damper 3 winding resistance (referred to the stator)
* **L**: inductance matrix
* Lq: stator q-axis inductance (mutual (Lmq) +leakage (Lls) )
* Ld: stator d-axis inductance (mutual (Lmd) +leakage (Lls) )
* L0: neutral inductance
* Lmd: d-axis mutual inductance
* Lmq: q-axis mutual inductance
* L'fd: field d-axis inductance (mutual (Lmd) +leakage (L'lfd) ) (referred to the stator)
* L'kd: damper 1 d-axis inductance (mutual (Lmd) +leakage (L'lkd) ) (referred to the stator)
* L'kq1: damper 2 q-axis inductance (mutual (Lmq) +leakage (L'lkq1) ) (referred to the stator)
* L'kq2: damper 3 q-axis inductance (mutual (Lmq) +leakage (L'lkq2) ) (referred to the stator)
* **Ω**: speed matrix
* ω, θ: rotation speed, and position of the reference frame
* ωr, θr: rotation speed, and position of the rotor (electrical) frame
* ωm, θm: rotation speed, and position of the rotor (mechanical) frame
* Te: electromagnetic torque
* Tm: mechanical torque
* pp: number of pole pairs
* J: rotor inertia
* Fv: viscous friction coefficient
* Fs: static friction torque


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://www.opal-rt.com/docs/rt-lab/simulink-blocks-reference/efpgasim-library/simulink-sps-workflow/machines/generic-machines/synchronous-machine-model.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
