> 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/hypersim/examples/distribution-and-industrial-power-systems/permanent-magnet-synchronous-machine-based-variable-frequency-drive-vfd.md).

# Permanent Magnet Synchronous Machine-based Variable Frequency Drive (VFD)

## Description

The **VFD-Based PMSM** example, located in **File > Open an Example File > Distributed Generation**, demonstrates two-quadrant operation (forward and reverse motoring) of a Permanent Magnet Synchronous Machine (PMSM) driven by a Variable Frequency Drive (VFD).

The objectives are to compare switching device and switching function implementations of 2‑level voltage source converters, present the associated grid-side and machine-side controls, and evaluate performance and real-time execution.

<figure><img src="https://3623212549-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLxgTpoh7kyPmQ5vuyqD7%2Fuploads%2Fgit-blob-84a1c1af2a15a8ea6d0842e9244b21cb6cd4ee11%2Fimage%20(1478).png?alt=media" alt=""><figcaption></figcaption></figure>

## Requirements

This example model does not require any additional hardware or licenses.

## Detailed explanation

VFD-based applications are increasingly adopted for improved energy efficiency and controllability. This example illustrates forward and reverse motoring, representative of applications such as elevators and cranes (e.g., lifting a loaded elevator car versus descending an empty car with gravity assist).

### Model description

The system consists of a 380 V, 60 Hz voltage source (grid) feeding a PMSM through back-to-back 2‑level voltage source converters. The mechanical load torque is proportional to speed: $$T\_\text{load} = 0.04 , \omega\_m$$

The example includes two implementations of the converters: (a) a Switching Devices model and (b) a Switching Function model. Both are 2‑level Voltage Source Converters with identical control architecture and network parameters. The Switching Function model uses a PWM average generator that interpolates switching transitions within the simulation time step. The Switching Devices model uses a standard carrier-based PWM generator. Both operate at a switching frequency of 4.2 kHz. For converter model details, see [Switching Device](https://www.opal-rt.com/docs/hypersim/library-blocks-reference/network-voltage-source-converters/2-level-converter-switching-devices.md) and [Switching Function](https://www.opal-rt.com/docs/hypersim/library-blocks-reference/network-voltage-source-converters/2-level-converter-switching-function.md).

<figure><img src="https://3623212549-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLxgTpoh7kyPmQ5vuyqD7%2Fuploads%2Fgit-blob-6ae193e8858fdf46eabc792b1b2feffa037d27e9%2Fimage%20(1479).png?alt=media" alt="" width="563"><figcaption><p>Schematic diagram</p></figcaption></figure>

## Grid-side converter control

The grid-side converter (GSC) regulates the DC-link voltage and reactive power. The outer voltage loop maintains the DC-link at 700 V. The reactive power loop is set for unity power factor. The inner loop regulates the d–q currents.

<figure><img src="https://3623212549-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLxgTpoh7kyPmQ5vuyqD7%2Fuploads%2Fgit-blob-a36bf7edc810a63bcc6e8e351fca99bfa5ff1db3%2Fimage%20(1480).png?alt=media" alt="" width="375"><figcaption><p>Outer loop DC link voltage regulator</p></figcaption></figure>

<figure><img src="https://3623212549-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLxgTpoh7kyPmQ5vuyqD7%2Fuploads%2Fgit-blob-6a881d6fd40bbb944f3ec4637ab6e0a8c634c8dc%2Fimage%20(1481).png?alt=media" alt="" width="375"><figcaption><p>Inner loop current regulator</p></figcaption></figure>

Where:

* Id: d-axis component of source current
* Iq: q-axis component of source current
* Vd: d-axis component of source voltage
* Vq: q-axis component of source voltage

## Machine-side converter control

The machine-side converter (MSC) regulates generator speed. Shunt LC filters reduce harmonics. The outer loop is a speed regulator; the inner loop regulates torque and stator currents.

<figure><img src="https://3623212549-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLxgTpoh7kyPmQ5vuyqD7%2Fuploads%2Fgit-blob-6bbeebe2c0d742d88a59a13d55863875ffd3104e%2Fimage%20(1482).png?alt=media" alt="" width="375"><figcaption><p>Outer loop speed regulator</p></figcaption></figure>

<figure><img src="https://3623212549-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLxgTpoh7kyPmQ5vuyqD7%2Fuploads%2Fgit-blob-4f85c8275fd48fb8a5ce628d91a291074071ef9a%2Fimage%20(1483).png?alt=media" alt="" width="375"><figcaption><p>Inner loop torque and current regulator</p></figcaption></figure>

Where:

* Id: d-axis component of machine stator current
* Iq: q-axis component of machine stator current
* Φ: magnetic flux of the machine
* p: number of poles

### Model parameters

<details>

<summary>System parameters</summary>

| S. No | Name                                | Unit    | Value         |
| ----- | ----------------------------------- | ------- | ------------- |
| 1     | Source voltage                      | V       | 380           |
| 2     | Series resistance- Rs               | Ω       | 1             |
| 3     | Series inductance - Ls              | H       | 10            |
| 4     | GSC Filter - F<sub>GSC</sub> \[R C] | \[Ω uF] | \[14.27 15.6] |
| 5     | GSC Choke - L<sub>GSC</sub>         | mH      | 20            |
| 6     | DC Link Capacitor - C<sub>dc</sub>  | uF      | 300           |
| 7     | MSC Choke - L<sub>MSC</sub>         | mH      | 10.46         |
| 8     | MSC Filter - F<sub>MSC</sub> \[R C] | \[Ω uF] | \[10.95 2.42] |

</details>

<details>

<summary>Machine general parameters</summary>

| S No. | Name                  | Unit | Value |
| ----- | --------------------- | ---- | ----- |
| 1     | Rated voltage - V     | V    | 380   |
| 2     | Rated power - S       | kVA  | 3     |
| 3     | Nominal frequency - f | Hz   | 60    |
| 4     | Number of poles - p   | -    | 6     |

</details>

<details>

<summary>Machine electrical parameters</summary>

| S No. | Name                                         | Unit | Value    |
| ----- | -------------------------------------------- | ---- | -------- |
| 1     | Armature resistance - R<sub>s</sub>          | pu   | 0.068559 |
| 2     | Armature leakage reactance - XI              | pu   | 0.032    |
| 3     | Zero sequence reactance - X<sub>o</sub>      | pu   | 0.0652   |
| 4     | d-axis synchronous reactance - X<sub>d</sub> | pu   | 0.32574  |
| 5     | q-axis synchronous reactance - Xq            | pu   | 0.4469   |
| 6     | D1 damper leakage reactance - XID1           | pu   | 0.13     |
| 7     | D2 damper leakage reactance - XID2           | pu   | 0.13     |
| 8     | D1 damper resistance - RD1                   | pu   | 0.054    |
| 9     | D2 damper resistance - RD2                   | pu   | 0.054    |
| 10    | Q1 damper leakage reactance - XIQ1           | pu   | 0.13     |
| 11    | Q2 damper leakage reactance - XIQ2           | pu   | 0.13     |
| 12    | Q1 damper resistance - RQ1                   | pu   | 0.108    |
| 13    | Q2 damper resistance - RQ2                   | pu   | 0.108    |
| 14    | Permanent flux magnet                        | Wb   | 0.4832   |

</details>

<details>

<summary>Machine mechanical parameters</summary>

| S No. | Name                                         | Unit     | Value  |
| ----- | -------------------------------------------- | -------- | ------ |
| 1     | Inertia constant - H                         | s        | 0.0265 |
| 2     | Absolute damping coefficient - K<sub>d</sub> | Nm/rad/s | 0.0    |
| 3     | Stiffness coefficient - Kij                  | Nm/rad   | 0.0    |
| 4     | Self damping coefficient - D                 | Nm/rad/s | 0.0    |
| 5     | Mutual damping coefficient - Dij             | Nm/rad/s | 0.0    |
| 6     | Fraction external torque - F                 | -        | 0.0    |

</details>

<details>

<summary>Converter parameters</summary>

| S No.                                   | Name                | Unit | Value |
| --------------------------------------- | ------------------- | ---- | ----- |
| 1                                       | Switching frequency | Hz   | 4200  |
| Switching device converter parameters   |                     |      |       |
| 2                                       | Rclose              | m Ω  | 1     |
| 3                                       | Rsnubber            | Ω    | 500   |
| 4                                       | Csnubber            | nF   | 100   |
| Switching function converter parameters |                     |      |       |
| 5                                       | Rclose              | m Ω  | 1     |
| 6                                       | Rsnubber            | Ω    | 500   |
| 7                                       | Rsource             | MΩ   | 1     |

</details>

<details>

<summary>Controller parameters</summary>

| S No.                      | Name | Unit | Value   |
| -------------------------- | ---- | ---- | ------- |
| DC voltage regulator - GSC |      |      |         |
| 1                          | Kp   | --   | 0.04    |
| 2                          | Ki   | --   | 6.35    |
| Current regulator - GSC    |      |      |         |
| 1                          | Kp   | --   | 60      |
| 2                          | Ki   | --   | 2000    |
| Speed regulator - MSC      |      |      |         |
| 1                          | Kp   | --   | 5.035   |
| 2                          | Ki   | --   | 1258.75 |
| Current regulator - MSC    |      |      |         |
| 1                          | Kp   | --   | 67.52   |
| 2                          | Ki   | --   | 3300    |

</details>

## Simulation and results

The following sequence demonstrates forward and reverse motoring and introduces line-to-ground (L–G) faults during operation.

<table><thead><tr><th width="107">Operating points</th><th width="89">From</th><th width="87">To</th><th width="102">Vdc (V)</th><th width="114">Wref (rad/s)</th><th>Scenario</th><th>Fault type</th></tr></thead><tbody><tr><td>1</td><td>0 s</td><td>1.5 s</td><td>700</td><td>125.66</td><td>Forward motoring</td><td>-</td></tr><tr><td>2</td><td>1.5 s</td><td>3 s</td><td>700</td><td>0</td><td>Motor stop (Stand-still)</td><td>-</td></tr><tr><td>3</td><td>3 s</td><td>4.5 s</td><td>700</td><td>-100</td><td>Reverse motoring</td><td>-</td></tr><tr><td>4</td><td>4.5 s</td><td>4.51 s</td><td>700</td><td>125.66</td><td>Reverse motoring</td><td>L-G fault applied</td></tr><tr><td>5</td><td>4.51 s</td><td>6 s</td><td>700</td><td>125.66</td><td>Forward motoring</td><td>-</td></tr><tr><td>6</td><td>6 s</td><td>6.1 s</td><td>700</td><td>125.66</td><td>Forward motoring</td><td>L-G fault applied</td></tr><tr><td>7</td><td>6.1 s</td><td>8 s</td><td>700</td><td>125.66</td><td>Forward motoring</td><td>-</td></tr></tbody></table>

The model is simulated at a 20 µs time step. The Switching Function implementation closely matches the Switching Devices model across operating modes and during faults. In the original figures, results in **red** correspond to the Switching Devices model and results in **blue** correspond to the Switching Function model.

<figure><img src="https://3623212549-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLxgTpoh7kyPmQ5vuyqD7%2Fuploads%2Fgit-blob-882683e2869d9114196181e6887a6dd5865bcfaf%2Fimage%20(1484).png?alt=media" alt=""><figcaption><p>Results at 20 us</p></figcaption></figure>

<figure><img src="https://3623212549-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLxgTpoh7kyPmQ5vuyqD7%2Fuploads%2Fgit-blob-577d48eb792e560f9feffdf25821b75ed9b0e995%2Fimage%20(1485).png?alt=media" alt=""><figcaption><p>Results at 20 us (zoomed in at 4 sec)</p></figcaption></figure>

<figure><img src="https://3623212549-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLxgTpoh7kyPmQ5vuyqD7%2Fuploads%2Fgit-blob-a7af04515749bad74f8e6a2e8260037fc39ef13d%2Fimage%20(1486).png?alt=media" alt=""><figcaption><p>Stator current of the machine</p></figcaption></figure>

### Real-time performance

Execution performance on the same setup indicates the Switching Function model requires less execution time than the Switching Devices model.

| HYPERSIM Model                      | Execution Time (us) | Max Execution time (us) |
| ----------------------------------- | ------------------- | ----------------------- |
| Switching Device based PMSM model   | 2.5022              | 5.14                    |
| Switching Function based PMSM model | 2.3867              | 4.92                    |

### Comparison at different time steps

The Switching Function model at 20 µs (real time) is compared against the Switching Devices model at 2 µs (offline). The results are very close, demonstrating that the Switching Function approach can achieve similar fidelity at a larger time step.

In the original figures, results in **red** are from the Switching Devices model and results in **blue** are from the Switching Function model.

<figure><img src="https://3623212549-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLxgTpoh7kyPmQ5vuyqD7%2Fuploads%2Fgit-blob-71691aac7052b805231768c5bb47c0fe2de51d89%2Fimage%20(1487).png?alt=media" alt=""><figcaption><p>Switching Function based PMSM model at 20 us and Switching device based PMSM model at 2 us</p></figcaption></figure>

<figure><img src="https://3623212549-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLxgTpoh7kyPmQ5vuyqD7%2Fuploads%2Fgit-blob-50e803fdab697c0536fe2a617589cc9607889d93%2Fimage%20(1488).png?alt=media" alt=""><figcaption><p>Switching Function at 20 us and Switching device based at 2 us (Zoomed in at 4 sec)</p></figcaption></figure>

<figure><img src="https://3623212549-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLxgTpoh7kyPmQ5vuyqD7%2Fuploads%2Fgit-blob-8b819dd9dfc84b1de18ce96ee4e4446088313548%2Fimage%20(1489).png?alt=media" alt=""><figcaption><p>Stator current of the machine</p></figcaption></figure>

## References

\[1] B. K. Bose, Power electronics and Variable Frequency Drives, Wiley-IEEE Press, 1996


---

# 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/hypersim/examples/distribution-and-industrial-power-systems/permanent-magnet-synchronous-machine-based-variable-frequency-drive-vfd.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.
