# Virtual Synchronous Machine (Grid-Forming) (`vsm`)

> Makes an inverter behave like a synchronous generator: its frequency follows the power through a virtual inertia and a droop damping.

![vsm](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/vsm.svg)

[Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/vsm/)

**Group:** Control · **Kind:** `{"block":"vsm","kind":"control"}`

## When to use it

Use it for a grid-forming inverter that should resist fast frequency changes on an island or weak grid, giving inertia as well as load sharing. Use Droop Control when only the sharing matters; with the same kp both share a load the same way in steady state.

## Pins

| Pin | Domain | Meaning |
|---|---|---|
| `p` | signal | Measured active power the inverter delivers, in W |
| `q` | signal | Measured reactive power, in var, positive for an inductive load |
| `theta` | signal | Angle of the voltage reference, in radians |
| `w` | signal | Angular frequency of the voltage, in rad/s |
| `e` | signal | Amplitude of the voltage reference, peak per phase, in V |

## Common parameters

- `e0`: Voltage amplitude (peak, per phase) at the reactive power qset (Default: required)
- `prated`: Rated active power: the base of h and kp (Default: required)
- `h`: Inertia constant: stored energy at the nominal speed over the rated power (Default: required)
- `kp`: Frequency droop per unit, the inverse of the damping: the frequency settles kp·f0 lower at the rated power (Default: required)
- `kq`: Voltage droop per unit: the amplitude falls by kq·e0 at the rated reactive power (Default: required)

## Parameters

| Key | Unit | Default | Typical range | Description |
|---|---|---|---|---|
| `f0` | Hz | 50 |  | Nominal frequency, at the power pset (50 Hz mains, IEC 60038:2009 Table 1) |
| `e0` | V | required |  | Voltage amplitude (peak, per phase) at the reactive power qset |
| `prated` | W | required |  | Rated active power: the base of h and kp |
| `qrated` | var | optional (off) |  | Rated reactive power: the base of kq (prated when absent) |
| `h` | s | required |  | Inertia constant: stored energy at the nominal speed over the rated power |
| `kp` | — | required |  | Frequency droop per unit, the inverse of the damping: the frequency settles kp·f0 lower at the rated power |
| `kq` | — | required |  | Voltage droop per unit: the amplitude falls by kq·e0 at the rated reactive power |
| `fc` | Hz | required |  | Cutoff of the filter on the measured reactive power |
| `pset` | W | 0 |  | Active power at which the frequency is f0 |
| `qset` | var | 0 |  | Reactive power at which the amplitude is e0 |
| `theta0` | rad | 0 |  | Angle at the start |

_Parameter descriptions are in English in both languages._

## Model

The per-unit speed follows the swing equation 2*h*d(w/w0)/dt = (pset - p)/prated - (w/w0 - 1)/kp, with w0 = 2*pi*f0: h is the inertia constant in seconds on the base prated, and the damping 1/kp makes the frequency settle on the droop line w = w0*(1 - kp*(p - pset)/prated). Right after a power step dP the frequency moves at f0*dP/(2*h*prated) Hz/s, then settles with the time constant 2*h*kp. theta is the integral of w, kept between 0 and 2*pi. The amplitude follows the Q-V droop e = e0*(1 - kq*(Qf - qset)/qrated), with q filtered at fc. With the same kp, inverters share active power by their ratings like Droop Control; the machine equals a droop whose power filter has the cutoff 1/(2*pi*2*h*kp). h = 0 leaves no inertia and kp = 0 holds the frequency at f0. w stays between 0 and twice the nominal speed and e between 0 and 2*e0. The block has no direct feedthrough, so it can sit in the loop it feeds. Feed theta and e to Inverse Park (dq2abc) with d = e and q = 0.

## Common mistakes

- A large inertia with a small droop is a slow, lightly damped swing against the line inductance: the power oscillates at the electromechanical frequency after a load step. Raise kp or lower h, or check the step response before adding inertia.
- The inertia is virtual: the energy for it comes from the DC link. A step of rated power for the time constant 2*h*kp has to be covered by the source or the link capacitor, or the link voltage sags.
- The droops assume a mainly inductive output impedance, as for Droop Control; with a resistive line add series inductance or a virtual impedance.

Problems rules: `pin.unconnected`

## Datasheet and sources

There is no datasheet. e0 is the phase voltage peak of the grid the inverter forms, prated and qrated are the inverter's ratings, h is a design choice (synchronous generators have a few seconds), and kp and kq come from the grid's rules or the microgrid's design. fc is a few hertz.

## Example

Open the example with the command `file.openExample` and the name `demo:vsm`.

---
Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand.
