Skip to content

Injector Models

RAMSES custom injector models represent loads, induction machines, inverter-based resources (IBR), and battery energy storage systems (BESS) connected to network buses.


The exponential recovery load model captures the transient and steady-state voltage and frequency dependency of aggregated loads. Immediately after a voltage disturbance, the load behaves according to a transient voltage exponent; it then recovers exponentially to a steady-state behaviour described by a different exponent. The model supports separate active (PP) and reactive (QQ) power recovery dynamics, each with individual minimum/maximum limiters on the recovery variable.

The model is parameterized in terms of initial active and reactive conductance/susceptance, G0=P0/V02G_0 = P_0/V_0^2 and B0=Q0/V02B_0 = -Q_0/V_0^2. Two recovery state variables xPx_P and xQx_Q evolve according to:

x˙P=1Tr[(VV0)αs(1+DPΔω)xP(VV0)αt]\dot{x}_P = \frac{1}{T_r}\left[\left(\frac{V}{V_0}\right)^{\alpha_s} \left(1 + D_P\,\Delta\omega\right) - x_P \left(\frac{V}{V_0}\right)^{\alpha_t}\right]

x˙Q=1Tr[(VV0)βs(1+DQΔω)xQ(VV0)βt]\dot{x}_Q = \frac{1}{T_r}\left[\left(\frac{V}{V_0}\right)^{\beta_s} \left(1 + D_Q\,\Delta\omega\right) - x_Q \left(\frac{V}{V_0}\right)^{\beta_t}\right]

where Δω=ωCOI1\Delta\omega = \omega_{\mathrm{COI}} - 1 is the per-unit speed deviation, VV is the bus voltage magnitude, V0V_0 is the initial voltage, αt,βt\alpha_t, \beta_t are transient exponents, αs,βs\alpha_s, \beta_s are steady-state exponents, and TrT_r is the load recovery time constant. The injected currents are then:

ix=G0xPvx(1+DPΔω)B0xQvy(1+DQΔω)i_x = G_0\, x_P\, v_x\left(1 + D_P\,\Delta\omega\right) - B_0\, x_Q\, v_y\left(1 + D_Q\,\Delta\omega\right)

iy=G0xPvy(1+DPΔω)+B0xQvx(1+DQΔω)i_y = G_0\, x_P\, v_y\left(1 + D_P\,\Delta\omega\right) + B_0\, x_Q\, v_x\left(1 + D_Q\,\Delta\omega\right)

When the recovery variable hits its limit (due to e.g. stalling or complete voltage collapse), the limit is held until the direction of the derivative reverses.

#NameDescriptionUnit
1DPFrequency sensitivity of active powerpu/pu
2A1Proportion of type-1 component in PP
3alpha1Transient voltage exponent for PP (type 1)
4A2Proportion of type-2 component in PP
5alpha2Transient voltage exponent for PP (type 2)
6alpha3Transient voltage exponent for PP (type 3, proportion =1A1A2= 1-A_1-A_2)
7DQFrequency sensitivity of reactive powerpu/pu
8B1Proportion of type-1 component in QQ
9beta1Transient voltage exponent for QQ (type 1)
10B2Proportion of type-2 component in QQ
11beta2Transient voltage exponent for QQ (type 2)
12beta3Transient voltage exponent for QQ (type 3)

Internal computed parameters include the steady-state exponents for each component (derived from the transient exponents), initial conductance G0G_0, susceptance B0B_0, and initial voltage V0V_0.

VariableDescription
iyyy-component of injected current (pu on system base)
ixxx-component of injected current (pu on system base)
xpActive power recovery variable (dimensionless)
xqReactive power recovery variable (dimensionless)

Observables: P, Q, xp, xq

INJEC load LOAD1 BUS1 1. 1. 0. 0. 1.5 0.3 1.0 0.2 2.0 0.5 1.8 0.4 2.5 0.1 3.0 2.0 ;

Parameters: DP A1 alpha1 A2 alpha2 alpha3 DQ B1 beta1 B2 beta2 beta3


inj_vfd_load — Variable Frequency Drive Load

Section titled “inj_vfd_load — Variable Frequency Drive Load”

The VFD load model represents aggregate industrial loads driven by variable-frequency drives, where the power consumption exhibits a composite voltage-dependent characteristic with multiple exponential components and frequency sensitivity. It also includes low-voltage protection: below a configurable threshold VminV_{\min}, the load switches to a constant-admittance representation, preventing numerical difficulties during deep voltage sags.

The active and reactive powers depend on bus voltage VV and frequency deviation Δf=f/f01\Delta f = f/f_0 - 1:

P=(1+DPΔf)P0a1Vα1+a2Vα2+(1a1a2)Vα3a1V0α1+a2V0α2+(1a1a2)V0α3P = \left(1 + D_P\,\Delta f\right) P_0 \cdot \frac{a_1 V^{\alpha_1} + a_2 V^{\alpha_2} + (1-a_1-a_2)\, V^{\alpha_3}}{a_1 V_0^{\alpha_1} + a_2 V_0^{\alpha_2} + (1-a_1-a_2)\, V_0^{\alpha_3}}

Q=(1+DQΔf)Q0b1Vβ1+b2Vβ2+(1b1b2)Vβ3b1V0β1+b2V0β2+(1b1b2)V0β3Q = \left(1 + D_Q\,\Delta f\right) Q_0 \cdot \frac{b_1 V^{\beta_1} + b_2 V^{\beta_2} + (1-b_1-b_2)\, V^{\beta_3}}{b_1 V_0^{\beta_1} + b_2 V_0^{\beta_2} + (1-b_1-b_2)\, V_0^{\beta_3}}

Below VminV_{\min}, an equivalent constant admittance is used:

Plow=GeqV2,Qlow=BeqV2P_{\mathrm{low}} = G_{\mathrm{eq}}\, V^2, \qquad Q_{\mathrm{low}} = -B_{\mathrm{eq}}\, V^2

where GeqG_{\mathrm{eq}} and BeqB_{\mathrm{eq}} are computed at initialization to ensure continuity at V=VminV = V_{\min}. The switch between the two regimes is governed by a piecewise-linear function of VV:

u={0V<Vmin1VVminu = \begin{cases} 0 & V < V_{\min} \\ 1 & V \geq V_{\min} \end{cases}

A small voltage filter (time constant 0.003 s) smooths the transition. The frequency deviation can optionally be computed from the local bus frequency (measured via an f_inj block with time constant TmesT_{\mathrm{mes}}) or from the system centre-of-inertia speed.

The initial voltage V0V_0 can differ from the transmission bus voltage if a distribution transformer ratio is implied (set Vinit0V_{\mathrm{init}} \ne 0 to specify the distribution-side voltage; otherwise the transmission voltage is used directly).

#NameDescriptionUnit
1DpFrequency sensitivity of active powerpu/pu
2a1Fraction of type-1 component in PP
3alpha1Voltage exponent of type-1 PP component
4a2Fraction of type-2 component in PP
5alpha2Voltage exponent of type-2 PP component
6alpha3Voltage exponent of type-3 PP component (fraction =1a1a2= 1-a_1-a_2)
7DqFrequency sensitivity of reactive powerpu/pu
8b1Fraction of type-1 component in QQ
9beta1Voltage exponent of type-1 QQ component
10b2Fraction of type-2 component in QQ
11beta2Voltage exponent of type-2 QQ component
12beta3Voltage exponent of type-3 QQ component
13VinitInitial distribution-bus voltage (0 = use transmission voltage)pu
14VlowVoltage threshold for constant-admittance regime (recommended 0.5–0.7)pu
15foption1 = use local bus frequency; 0 = use COI speedflag
16TmesFrequency measurement time constants
VariableDescription
VrealVoltage at equivalent distribution bus
VFiltered distribution-bus voltage (3 ms filter)
PActive power consumed
QReactive power consumed
fbusLocal bus frequency (used if foption=1)
dfFrequency deviation Δf\Delta f
uRegime switch (1 = above VminV_{\min}, 0 = constant admittance)

Observables: P, Q, df, u

INJEC vfd_load VFD1 BUS_IND 1. 1. 0. 0. 1.5 0.7 2.0 0.2 1.0 0.5
1.2 0.5 2.5 0.1 1.5 0.8
0.0 0.6 0 0.1 ;

The restorative load model represents loads that self-restore toward a nominal characteristic after a voltage disturbance. The load’s active and reactive powers are governed by two internal recovery variables that evolve dynamically, allowing the simulation to capture the slow restoration of thermostatically controlled loads (heating, cooling) and similar self-restoring demand.

The recovery variable xPx_P for active power satisfies:

x˙P=1Tr[Vαs(1+DPΔω)xPVαt]\dot{x}_P = \frac{1}{T_r}\left[V^{\alpha_s}\left(1 + D_P\,\Delta\omega\right) - x_P\, V^{\alpha_t}\right]

with analogous equation for xQx_Q. Here αs\alpha_s and αt\alpha_t are the steady-state and transient voltage exponents respectively. Limiters [xP,min,xP,max][x_{P,\min},\, x_{P,\max}] are applied. The injected currents are expressed as:

iy=B0(1+DQΔω)xQvx+G0(1+DPΔω)xPvyi_y = -B_0\left(1 + D_Q\,\Delta\omega\right) x_Q\, v_x + G_0\left(1 + D_P\,\Delta\omega\right) x_P\, v_y

ix=B0(1+DQΔω)xQvy+G0(1+DPΔω)xPvxi_x = \phantom{-}B_0\left(1 + D_Q\,\Delta\omega\right) x_Q\, v_y + G_0\left(1 + D_P\,\Delta\omega\right) x_P\, v_x

where the ratio V/V0V/V_0 governs the voltage dependence through vrat.

#NameDescriptionUnit
1DPFrequency sensitivity of active powerpu/pu
2alphatTransient active power voltage exponent
3alphasSteady-state active power voltage exponent
4xP_minMinimum limit for xPx_P
5xP_maxMaximum limit for xPx_P
6DQFrequency sensitivity of reactive powerpu/pu
7betatTransient reactive power voltage exponent
8betasSteady-state reactive power voltage exponent
9xQ_minMinimum limit for xQx_Q
10xQ_maxMaximum limit for xQx_Q
11TrLoad recovery time constants
VariableDescription
iyyy-component of injected current
ixxx-component of injected current
xpActive power recovery variable
xqReactive power recovery variable

Observables: P, Q, xp, xq

INJEC restld RESTLD1 BUS2 1. 1. 0. 0. 1.5 0.5 2.0 0.0 2.0 1.2 0.5 2.5 0.0 2.0 60.0 ;

The simplest injector model: maintains constant active and reactive power consumption regardless of bus voltage or frequency. The power is fixed at its initial operating-point value. A small first-order filter (time constant Tout) drives the injected currents smoothly to their target values, preventing algebraic loops.

The current references are set to deliver the initial powers P0P_0 and Q0Q_0 at the measured voltage VV:

Ix,set=P0vx+Q0vyV2,Iy,set=P0vyQ0vxV2I_{x,\mathrm{set}} = \frac{P_0 v_x + Q_0 v_y}{V^2}, \qquad I_{y,\mathrm{set}} = \frac{P_0 v_y - Q_0 v_x}{V^2}

These references pass through a first-order filter with time constant ToutT_{\mathrm{out}} to produce the actual injected currents:

Touti˙x+ix=Ix,set,Touti˙y+iy=Iy,setT_{\mathrm{out}}\,\dot{i}_x + i_x = I_{x,\mathrm{set}}, \qquad T_{\mathrm{out}}\,\dot{i}_y + i_y = I_{y,\mathrm{set}}

#NameDescriptionUnit
1ToutOutput filter time constant (recommended: 0.01 s)s

Initial conditions P0P_0, Q0Q_0, V0V_0 are computed automatically at initialization.

VariableDescription
ixInjected xx-current
iyInjected yy-current
IxsetCurrent reference xx
IysetCurrent reference yy
PObserved active power
QObserved reactive power
VBus voltage magnitude

Observables: P, Q

INJEC PQ LOAD_PQ BUS3 1. 1. 0. 0. 0.01 ;

Models an external network or generator cluster as a Thévenin equivalent: an ideal voltage source Eˉth\bar{E}_{\mathrm{th}} behind a pure reactance XthX_{\mathrm{th}}. The model computes the internal voltage magnitude and phase angle at initialization from the initial bus conditions and holds them constant during the simulation. It is useful for representing neighbouring system equivalents or simplified machine representations.

The Thévenin reactance is obtained from the specified short-circuit power SscS_{\mathrm{sc}} (MVA):

Xth=SbaseSscX_{\mathrm{th}} = \frac{S_{\mathrm{base}}}{S_{\mathrm{sc}}}

The internal voltage phasor is computed at t=0t=0:

Eth,x=vxXthiy,Eth,y=vy+XthixE_{\mathrm{th},x} = v_x - X_{\mathrm{th}}\, i_y, \qquad E_{\mathrm{th},y} = v_y + X_{\mathrm{th}}\, i_x

Eth=Eth,x2+Eth,y2,ϕ=arctan ⁣(Eth,yEth,x)E_{\mathrm{th}} = \sqrt{E_{\mathrm{th},x}^2 + E_{\mathrm{th},y}^2}, \qquad \phi = \arctan\!\left(\frac{E_{\mathrm{th},y}}{E_{\mathrm{th},x}}\right)

During simulation the injected currents satisfy:

iy=EthcosϕvxXth,ix=EthsinϕvyXthi_y = -\frac{E_{\mathrm{th}}\cos\phi - v_x}{X_{\mathrm{th}}}, \qquad i_x = \frac{E_{\mathrm{th}}\sin\phi - v_y}{X_{\mathrm{th}}}

#NameDescriptionUnit
1XTHShort-circuit power of the equivalent (converted to XthX_{\mathrm{th}} at initialization)MVA

Internal parameters ETH (Thévenin voltage magnitude, pu) and phase (internal angle, rad) are computed automatically.

VariableDescription
iyInjected yy-current
ixInjected xx-current

Observables: P, Q (in MW and Mvar at system base)

INJEC theveq EQUIV1 SLACK_BUS 1. 1. 0. 0. 2000.0 ;

inj_indmach1 — Single-Cage Induction Machine

Section titled “inj_indmach1 — Single-Cage Induction Machine”

A single-cage (single-rotor-circuit) induction machine model for motor loads. The machine is represented on its own MVA base (or inferred from load factor LF) with a shunt capacitor BshB_{\mathrm{sh}} to represent power factor correction. The mechanical torque is a quadratic function of rotor speed. At initialization, the model solves nonlinear algebraic equations to find the operating-point slip and flux linkages.

The machine uses the standard dd-qq reference-frame formulation with Lss=Lsr+LlsL_{ss} = L_{sr} + L_{ls} and Lrr=Lsr+LlrL_{rr} = L_{sr} + L_{lr}. The rotor flux-linkage equations are:

dψdrdt=ω0(RrLrrψdr+LsrRrLrriym(ωωm)ψqr)\frac{d\psi_{dr}}{dt} = \omega_0\left(-\frac{R_r}{L_{rr}}\psi_{dr} + \frac{L_{sr} R_r}{L_{rr}} i_{ym} - (\omega - \omega_m)\psi_{qr}\right)

dψqrdt=ω0(RrLrrψqr+LsrRrLrrixm+(ωωm)ψdr)\frac{d\psi_{qr}}{dt} = \omega_0\left(-\frac{R_r}{L_{rr}}\psi_{qr} + \frac{L_{sr} R_r}{L_{rr}} i_{xm} + (\omega - \omega_m)\psi_{dr}\right)

where ω0=2πfnom\omega_0 = 2\pi f_{\mathrm{nom}} and ωm\omega_m is the rotor mechanical speed. The equations for the stator (with shunt susceptance BshB_{\mathrm{sh}}) are:

Rsiym+(LssLsr2Lrr)ωixm+LsrLrrωψqr=vyR_s i_{ym} + \left(L_{ss} - \frac{L_{sr}^2}{L_{rr}}\right)\omega\, i_{xm} + \frac{L_{sr}}{L_{rr}}\omega\,\psi_{qr} = v_y

Rsixm(LssLsr2Lrr)ωiymLsrLrrωψdr=vxR_s i_{xm} - \left(L_{ss} - \frac{L_{sr}^2}{L_{rr}}\right)\omega\, i_{ym} - \frac{L_{sr}}{L_{rr}}\omega\,\psi_{dr} = v_x

The rotor speed dynamics follow the swing equation:

dωmdt=TeTm2H\frac{d\omega_m}{dt} = \frac{T_e - T_m}{2H}

where the electromagnetic torque is:

Te=LsrLrr(ψdrixm+ψqriym)T_e = \frac{L_{sr}}{L_{rr}}\left(-\psi_{dr} i_{xm} + \psi_{qr} i_{ym}\right)

and the mechanical torque is the quadratic load curve:

Tm=Tm0(Aωm2+Bωm+1AB)T_m = T_{m0}\left(A\,\omega_m^2 + B\,\omega_m + 1 - A - B\right)

#NameDescriptionUnit
1SNOMMachine nominal apparent power (0 = infer from LF)MVA
2RSStator resistancepu
3LlsStator leakage inductancepu
4LSRMagnetizing inductancepu
5RRRotor resistancepu
6LlrRotor leakage inductancepu
7HMachine inertia constants
8AQuadratic torque-speed coefficient
9BLinear torque-speed coefficient
10LFLoad factor (for SNOM inference)
VariableDescription
iyyy-component of stator current
ixxx-component of stator current
psidrdd-axis rotor flux linkage
psiqrqq-axis rotor flux linkage
omegamRotor mechanical speed

Observables: P, Qmot+comp, Qmot, omega, Tm

INJEC indmach1 MTR1 BUS_MV 1. 1. 0. 0. 10.0 0.01 0.10 2.50 0.015 0.10 1.5 0.8 0.1 0.0 ;

inj_indmach2 — Double-Cage Induction Machine

Section titled “inj_indmach2 — Double-Cage Induction Machine”

A double-cage (double-rotor-circuit) induction machine model following the Eurostag formulation. Two parallel rotor cages allow more accurate representation of the machine’s impedance-vs-frequency characteristic, which is especially important for the starting transient. The model structure mirrors inj_indmach1 but includes a second set of rotor flux states.

The machine has parameters: stator resistance R1R_1, stator leakage L1L_1, magnetizing inductance LmL_m, cage-1 resistance R2R_2 and leakage L2L_2, cage-2 resistance R3R_3 and leakage L3L_3. The state vector is (ψdr1,ψqr1,ψdr2,ψqr2,ωm)(\psi_{dr1},\psi_{qr1},\psi_{dr2},\psi_{qr2},\omega_m) with flux-linkage equations for each cage:

dψdr1dt=ω0(R2LAψdr1+LmR2LAiym(ωωm)ψqr1)\frac{d\psi_{dr1}}{dt} = \omega_0\left(-\frac{R_2}{L_{A}}\psi_{dr1} + \frac{L_m R_2}{L_{A}} i_{ym} - (\omega - \omega_m)\psi_{qr1}\right)

dψdr2dt=ω0(R3LBψdr2+LmR3LBiym(ωωm)ψqr2)\frac{d\psi_{dr2}}{dt} = \omega_0\left(-\frac{R_3}{L_{B}}\psi_{dr2} + \frac{L_m R_3}{L_{B}} i_{ym} - (\omega - \omega_m)\psi_{qr2}\right)

where LA=Lm+L2L_A = L_m + L_2 and LB=Lm+L3L_B = L_m + L_3. The total electromagnetic torque combines contributions from both cages:

Te=LmLA(ψdr1ixm+ψqr1iym)+LmLB(ψdr2ixm+ψqr2iym)T_e = \frac{L_m}{L_A}\left(-\psi_{dr1} i_{xm} + \psi_{qr1} i_{ym}\right) + \frac{L_m}{L_B}\left(-\psi_{dr2} i_{xm} + \psi_{qr2} i_{ym}\right)

The swing equation is identical to inj_indmach1.

#NameDescriptionUnit
1SNOMMachine MVA rating (0 = infer from LF)MVA
2R1Stator resistancepu
3L1Stator leakage inductancepu
4LmMagnetizing inductancepu
5R2First cage resistancepu
6L2First cage leakage inductancepu
7R3Second cage resistancepu
8L3Second cage leakage inductancepu
9HInertia constants
10AQuadratic torque-speed coefficient
11BLinear torque-speed coefficient
12LFLoad factor (for SNOM inference)
VariableDescription
iyyy-component of stator current
ixxx-component of stator current
psidr1dd-axis flux of first rotor cage
psiqr1qq-axis flux of first rotor cage
psidr2dd-axis flux of second rotor cage
psiqr2qq-axis flux of second rotor cage
omegamRotor mechanical speed

Observables: P, Qmot+comp, Qmot, omega

INJEC indmach2 MTR2 BUS_MV 1. 1. 0. 0. 10.0 0.01 0.08 2.00 0.02 0.06 0.04 0.10 1.5 0.8 0.1 0.0 ;

inj_INDM1 — Alternative Induction Machine (INDM1)

Section titled “inj_INDM1 — Alternative Induction Machine (INDM1)”

An alternative single-cage induction machine model that uses the INI_indmach1 helper function for initialization. It is equivalent in physics to inj_indmach1 but implements the equations using RAMSES .txt-style model syntax with explicit state initialization calls. This can simplify parameterization when the helper function’s output is directly used.

The model equations match those of inj_indmach1. The key distinction is the use of the INI_indmach1 function at parameter-evaluation time to pre-compute BshB_{\mathrm{sh}}, Tm0T_{m0}, and the initial flux linkages and rotor speed, rather than solving the initialization system in Fortran. With Lss=Lsr+LlsL_{ss} = L_{sr} + L_{ls} and Lrr=Lsr+LlrL_{rr} = L_{sr} + L_{lr}, the rotor flux equations are:

dψdrdt=2πf0[RRLrrψdr+LSRRRLrriym(ωωm)ψqr]\frac{d\psi_{dr}}{dt} = 2\pi f_0 \left[ -\frac{R_R}{L_{rr}}\psi_{dr} + \frac{L_{SR} R_R}{L_{rr}} i_{ym} - (\omega - \omega_m)\psi_{qr} \right]

dψqrdt=2πf0[RRLrrψqr+LSRRRLrrixm+(ωωm)ψdr]\frac{d\psi_{qr}}{dt} = 2\pi f_0 \left[ -\frac{R_R}{L_{rr}}\psi_{qr} + \frac{L_{SR} R_R}{L_{rr}} i_{xm} + (\omega - \omega_m)\psi_{dr} \right]

The rotor speed integral uses:

dωmdt=12H[LSRLrr(ψdrixm+ψqriym)Tm0(Aωm2+Bωm+1AB)]\frac{d\omega_m}{dt} = \frac{1}{2H}\left[\frac{L_{SR}}{L_{rr}}(-\psi_{dr} i_{xm} + \psi_{qr} i_{ym}) - T_{m0}(A\omega_m^2 + B\omega_m + 1 - A - B)\right]

with a lower limit of ωm0\omega_m \ge 0.

#NameDescriptionUnit
1SNOMMachine MVA ratingMVA
2RSStator resistancepu
3LlsStator leakage inductancepu
4LSRMagnetizing inductancepu
5RRRotor resistancepu
6LlrRotor leakage inductancepu
7HInertia constants
8AQuadratic torque-speed coefficient
9BLinear torque-speed coefficient
10LFLoad factor

Computed internally: BSH (shunt susceptance), TM0 (initial mechanical torque), LSS, LRR.

VariableDescription
Psidrdd-axis rotor flux linkage
Psiqrqq-axis rotor flux linkage
omegamRotor mechanical speed
iym, ixmStator current components (on machine base)
dPsidr, dPsiqr, domegamTime-derivative auxiliary states

Observables: omegam

INJEC INDM1 MTR3 BUS_MV 1. 1. 0. 0. 10.0 0.01 0.10 2.50 0.015 0.10 1.5 0.8 0.1 0.0 ;

Renewable Generation / Inverter-Based Resources

Section titled “Renewable Generation / Inverter-Based Resources”

inj_IBG — Inverter-Based Generator (Generic IBR)

Section titled “inj_IBG — Inverter-Based Generator (Generic IBR)”

A generic inverter-based generation model suitable for representing aggregated distributed generation or any grid-following IBR. The model includes a Phase-Locked Loop (PLL), inner current control with active (IpI_p) and reactive (IqI_q) current commands, LVRT/HVRT logic with voltage-dependent reactive current injection, frequency-responsive active power modulation, and reconnection logic after disconnection events.

The PLL tracks the terminal voltage angle θ\theta via a second-order PI controller with a freeze option below Vmin,pllV_{\mathrm{min,pll}}:

dθPLLdt=ΔωPLL,dΔωPLLdt=kPLLvq\frac{d\theta_{\mathrm{PLL}}}{dt} = \Delta\omega_{\mathrm{PLL}}, \qquad \frac{d\Delta\omega_{\mathrm{PLL}}}{dt} = k_{\mathrm{PLL}}\, v_q

where vqv_q is the qq-axis terminal voltage in the PLL frame. The current commands Ip,cmdI_{p,\mathrm{cmd}} and Iq,cmdI_{q,\mathrm{cmd}} are derived from outer controls:

  • Active power is modulated by frequency according to frequency deadband fdbd: P=Pext(1+bsat(Δffstart,fmin,fmax))P = P_{\mathrm{ext}}\left(1 + b\,\mathrm{sat}(\Delta f - f_{\mathrm{start}}, f_{\mathrm{min}}, f_{\mathrm{max}})\right)

  • During voltage dips (LVRT), reactive current is boosted: Iq,boost=kRCI(VrefVt)I_{q,\mathrm{boost}} = k_{\mathrm{RCI}}\,(V_{\mathrm{ref}} - V_t)

  • Current magnitude is limited to ImaxI_{\mathrm{max}} with priority to reactive current during LVRT.

The injected currents in xx-yy frame are:

ix=IpcosθPLLIqsinθPLLi_x = I_p \cos\theta_{\mathrm{PLL}} - I_q \sin\theta_{\mathrm{PLL}} iy=IpsinθPLL+IqcosθPLLi_y = I_p \sin\theta_{\mathrm{PLL}} + I_q \cos\theta_{\mathrm{PLL}}

#NameDescriptionUnit
1ImaxMaximum current magnitudepu
2INNominal currentpu
3IprateActive current ramp ratepu/s
4TgGenerator time constants
5TmMeasurement filter time constants
6tLVRT1LVRT ride-through time threshold 1s
7tLVRT2LVRT ride-through time threshold 2s
8tLVRTintLVRT integration times
9VmaxMaximum voltage for operationpu
10tauPLL response timems
11VminpllVoltage below which PLL is frozenpu
12aLVRT voltage-current curve slope
13VminMinimum LVRT voltagepu
14VintIntermediate LVRT voltagepu
15fminMinimum frequency for operationpu
16fmaxMaximum frequency for operationpu
17fstartFrequency threshold for P modulationpu
18bFrequency droop gain
19frReference frequencypu
20TrReconnection delay after trips
21ReGrid equivalent resistancepu
22XeGrid equivalent reactancepu
23CM1LVRT control mode flag
24kRCIReactive current injection gain (LVRT)
25kRCAReactive current absorption gain (HVRT)
26mActive-reactive current priority parameter
27nActive-reactive current priority parameter
28dbminFrequency deadband lower limitpu
29dbmaxFrequency deadband upper limitpu
30HVRTHVRT flag
31LVRTLVRT flag
32CM2Control mode 2 flag
33VtripTrip voltage thresholdpu
VariableDescription
vxl, vylFiltered terminal voltage components
VtTerminal voltage magnitude
PLLPhaseAnglePLL phase angle
VmVoltage magnitude measurement
Ip, IqActive and reactive current outputs
Ipcmd, IqcmdCurrent commands
Iqmax, IqminReactive current limits
Ipmax, IpminActive current limits
DeltaW, DeltaWfFrequency deviation and filtered value
Pgen, QgenGenerated active and reactive power
INJEC IBG IBG1 BUS_GEN 1. 1. 0. 0. 1.2 1.0 0.5 0.02 0.01 0.5 1.0 0.05
1.1 20.0 0.1 2.0 0.1 0.5 0.95 1.05
0.0 2.0 1.0 1.0 0.0 0.05 1 2.0 1.5
2.0 2.0 -0.02 0.02 1 1 1 0.85 ;

inj_WT3WithChanges — Type 3 Wind Turbine (DFIG)

Section titled “inj_WT3WithChanges — Type 3 Wind Turbine (DFIG)”

A Type 3 wind turbine model implementing the WECC composite structure with four coupled sub-models:

  • REPC_A: Plant-level controller (reactive power / voltage regulation, frequency response)
  • REEC_A: Electrical controller (inner dd-qq current control, LVRT/HVRT logic)
  • WTGTRQ_A: Generator torque controller (rotor speed regulation via electrical torque command)
  • WTGPT_A: Pitch controller (aerodynamic power limitation)
  • WTGAR_A: Aerodynamic rotor model
  • WTGT_A: Two-mass mechanical drivetrain (turbine inertia HtH_t, generator inertia HgH_g, shaft stiffness KshaftK_{\mathrm{shaft}}, damping DshaftD_{\mathrm{shaft}})

The doubly-fed induction generator (DFIG) topology allows decoupled control of active and reactive power via rotor-side converter injection.

The two-mass drivetrain model governs rotor dynamics:

2Htdωtdt=TmKshaft(θtθg)Dshaft(ωtωg)2H_t \frac{d\omega_t}{dt} = T_m - K_{\mathrm{shaft}}(\theta_t - \theta_g) - D_{\mathrm{shaft}}(\omega_t - \omega_g)

2Hgdωgdt=Kshaft(θtθg)+Dshaft(ωtωg)Te2H_g \frac{d\omega_g}{dt} = K_{\mathrm{shaft}}(\theta_t - \theta_g) + D_{\mathrm{shaft}}(\omega_t - \omega_g) - T_e

The torque controller (WTGTRQ_A) uses a piecewise power-speed characteristic:

Te,ref=interp(ωg;  [(spd1,p1),(spd2,p2),(spd3,p3),(spd4,p4)])T_{e,\mathrm{ref}} = \mathrm{interp}(\omega_g;\; [(\mathrm{spd}_1, p_1), (\mathrm{spd}_2, p_2), (\mathrm{spd}_3, p_3), (\mathrm{spd}_4, p_4)])

The electrical controller (REEC_A) provides reactive current injection during voltage dips:

Iq,vdip=kqv(Vref0Vt)when Vt<VdipI_{q,\mathrm{vdip}} = k_{qv}\left(V_{\mathrm{ref0}} - V_t\right)\quad \text{when } V_t < V_{\mathrm{dip}}

with limiter [Iql1,Iqh1][I_{ql1}, I_{qh1}].

The plant controller (REPC_A) optionally provides frequency response:

ΔPref=Ddnsat(Δf,fdbd1,0)+Dupsat(Δf,0,fdbd2)\Delta P_{\mathrm{ref}} = D_{\mathrm{dn}}\,\mathrm{sat}(\Delta f, f_{\mathrm{dbd1}}, 0) + D_{\mathrm{up}}\,\mathrm{sat}(\Delta f, 0, f_{\mathrm{dbd2}})

#NameSub-modelDescriptionUnit
1SNOMNominal powerMW
2–32REPC_APlant controllerReactive/voltage/frequency controlvarious
33–46WTGTRQ_ATorque ctrlSpeed-torque lookup table, rate limitsvarious
47–56WTGPT_APitch ctrlPitch PI gains, angle limits, rate limitsvarious
57–58WTGAR_AAeroAerodynamic gain, initial pitch angle
59–62WTGT_ADrivetrainHtH_t, HgH_g, DshaftD_{\mathrm{shaft}}, KshaftK_{\mathrm{shaft}}s, pu
63–97REEC_AElec ctrlLVRT/HVRT, current limits, inner PIvarious
98+REGC_AGeneratorGenerator electrical conversionvarious

Full parameter list has 80+ entries; refer to the embedded Fortran header comments in inj_WT3WithChanges.f90.

INJEC WT3WithChanges WT3_1 BUS_WIND 1. 1. 0. 0.
100.0 0.0 0.02 0 0.0 0.05 0 0.0 0.3 -0.3 2.0 0.4 0.3 -0.3 0.0 0.15 0.9 0.05
0.0 -0.06 0.06 -0.05 0.05 0.05 -0.05 2.0 1.0 1.0 -1.0 0.02 0 0 0.8
1.5 1.5 0.01 0.5 ... ;

inj_WT4WithChanges — Type 4 Wind Turbine (Full Converter)

Section titled “inj_WT4WithChanges — Type 4 Wind Turbine (Full Converter)”

A Type 4 wind turbine with full-rated converter. Unlike Type 3, the generator is fully decoupled from the grid through a back-to-back converter. The model implements the same WECC framework as WT3 but without the doubly-fed rotor circuit: the mechanical sub-model is a single-mass (or two-mass) drive train, and all electrical power passes through the converter. Sub-models include REPC_A (plant controller), REEC_A (electrical controller), WTGT_A (drivetrain), and REGC_A (generator/converter).

The two-mass drivetrain is identical to WT3:

2Htdωtdt=TmKshaftδshaftDshaft(ωtωg)2H_t \frac{d\omega_t}{dt} = T_m - K_{\mathrm{shaft}}\delta_{\mathrm{shaft}} - D_{\mathrm{shaft}}(\omega_t - \omega_g)

2Hgdωgdt=Kshaftδshaft+Dshaft(ωtωg)Te2H_g \frac{d\omega_g}{dt} = K_{\mathrm{shaft}}\delta_{\mathrm{shaft}} + D_{\mathrm{shaft}}(\omega_t - \omega_g) - T_e

dδshaftdt=ω0(ωtωg)\frac{d\delta_{\mathrm{shaft}}}{dt} = \omega_0(\omega_t - \omega_g)

There is no pitch controller or aerodynamic rotor in the basic Type 4 configuration; the active power reference is supplied directly (or from REPC_A), and rate limits dPmax/dPmin apply to the power order ramp.

The REEC_A electrical controller supplies current commands with the same LVRT/HVRT logic as WT3, with current limits through the converter lookup table (piecewise linear in voltage: (Vp1,Ip1),,(Vp4,Ip4)(V_{p1}, I_{p1}),\ldots,(V_{p4}, I_{p4}) for active current and (Vq1,Iq1),,(Vq4,Iq4)(V_{q1}, I_{q1}),\ldots,(V_{q4}, I_{q4}) for reactive).

#NameSub-modelDescriptionUnit
1SNOMNominal powerMW
2–32REPC_APlant ctrlSame as WT3various
33–37WTGT_ADrivetrainHtH_t, HgH_g, ω0\omega_0, DshaftD_{\mathrm{shaft}}, KshaftK_{\mathrm{shaft}}s, pu
38–80REEC_AElec ctrlLVRT, current limits, PI gainsvarious
81+REGC_AGeneratorConverter electrical modelvarious
INJEC WT4WithChanges WT4_1 BUS_WIND 1. 1. 0. 0.
100.0 0.0 0.02 0 0.0 0.05 0 0.0 0.3 -0.3 2.0 0.4 0.3 -0.3 0.0 0.15 0.9 0.05
0.0 -0.06 0.06 -0.05 0.05 0.05 -0.05 2.0 1.0 1.0 -1.0 0.02 0 0 5.0 1.5 1.0 1.5 20.0 ... ;

A photovoltaic generator model with similar WECC-derived structure to the wind turbine models. The model includes a plant controller (voltage/reactive power regulation), an electrical controller (current limits, LVRT), and generator/converter representation. Unlike wind turbines, there is no mechanical drive train; the active power set-point follows an irradiance input or a fixed reference. LVRT/HVRT logic and current limiting are identical to the Type 4 wind model.

The PV generator delivers active and reactive power through current commands:

Ip=PrefVt,Iq=fQV(Vt,Qref)I_p = \frac{P_{\mathrm{ref}}}{V_t}, \qquad I_q = f_{\mathrm{QV}}(V_t, Q_{\mathrm{ref}})

subject to the constraint Ip2+Iq2Imax\sqrt{I_p^2 + I_q^2} \leq I_{\mathrm{max}}. The inner current loop is a first-order filter:

TgdIpdt=Ip,cmdIp,TmdIqdt=Iq,cmdIqT_g \frac{dI_p}{dt} = I_{p,\mathrm{cmd}} - I_p, \qquad T_m \frac{dI_q}{dt} = I_{q,\mathrm{cmd}} - I_q

Low-voltage power-logic (LVPL) limits active current during deep voltage sags via a piecewise-linear function of VtV_t with breakpoints lvpnt0, lvpnt1, Lvpl1. HVRT and LVRT timers control disconnection and reconnection.

#NameDescriptionUnit
1ImaxMaximum converter currentpu
2INNominal currentpu
3ratemaxReconnection ramp ratepu/s
4TgActive current filter time constants
5TmReactive current filter time constants
6–9LVRT timerstLVRT1, tLVRT2, tLVRTint, Vmaxs, pu
10kpllPLL gain
11VminpllPLL freeze voltagepu
12–14LVRT curvea, Vmin, Vint
21–22Re, XeGrid equivalent impedancepu
23–29Current controlCM1, kRCI, kRCA, m, n, dbmin, dbmax
34BMBattery module flag
INJEC PVG PV1 BUS_PV 1. 1. 0. 0. 1.2 1.0 0.5 0.02 0.01 0.5 1.0 0.05 1.1
20.0 0.1 2.0 0.1 0.5 0.95 1.05 0.0 2.0 1.0
1.0 0.0 0.05 1 2.0 1.5 2.0 2.0 -0.02 0.02 1 1 1 0.85 0 ;

A grid-forming voltage source converter implementing Virtual Synchronous Machine (VSM) dynamics. The converter’s output voltage phase angle and magnitude are controlled to mimic the behaviour of a synchronous machine: an inertia-like integrator creates a synthetic swing equation, a droop loop regulates frequency, and a current limiter protects against overcurrents using a virtual impedance that attenuates the modulated voltage.

The phase reactor algebraic equations (pu on machine base) are:

vxr+RprixtωrefLpriyt=Vmcos(δm)\frac{v_x}{r} + R_{\mathrm{pr}} i_{xt} - \omega_{\mathrm{ref}} L_{\mathrm{pr}} i_{yt} = V_m \cos(\delta_m)

vyr+Rpriyt+ωrefLprixt=Vmsin(δm)\frac{v_y}{r} + R_{\mathrm{pr}} i_{yt} + \omega_{\mathrm{ref}} L_{\mathrm{pr}} i_{xt} = V_m \sin(\delta_m)

The VSM swing equation is:

2HdωPdt=ΔP=[P0+1ωmRVSC]γP2H \frac{d\omega_P}{dt} = \Delta P = \left[P_0 + \frac{1 - \omega_m}{R_{\mathrm{VSC}}}\right]\gamma - P

ωm=ωPKpP\omega_m = \omega_P - K_p P

dδmdt=(ωmωref)2πf0\frac{d\delta_m}{dt} = (\omega_m - \omega_{\mathrm{ref}})\cdot 2\pi f_0

The attenuation factor γ\gamma limits power during overcurrent:

γ=(VmVm0)n\gamma = \left(\frac{V_m}{V_{m0}}\right)^n

When the current exceeds ImaxI_{\mathrm{max}}, the virtual impedance modifies the modulated voltage:

ΔI=IIlim,ΔVm=1KcΔI(limited to [L1,L2])\Delta I = I - I_{\mathrm{lim}}, \quad \Delta V_m = -\frac{1}{K_c}\Delta I \quad \text{(limited to } [L_1, L_2]\text{)}

Vm,cl=Vm0ΔVmV_{m,\mathrm{cl}} = V_{m0} - \Delta V_m

#NameDescriptionUnit
1RprPhase reactor resistancepu
2LprPhase reactor inductancepu
3rTransformer turns ratio
4SnomNominal apparent powerMVA
5HInertia constants
6RVSCSteady-state frequency drooppu
7KpProportional gain in active power control
8ImaxMaximum currentpu
9nExponent in attenuation factor γ\gamma
10KcGain of current limiter integral control
11L1Lower limit of current correctionpu
12L2Upper limit of current correctionpu
VariableDescription
wrefAngular speed of reference axes
ixt, iytConverter-side currents (on machine base)
VmModulated voltage magnitude
deltamModulated voltage phase angle
PActive power (on Snom base)
gammaAttenuation factor
omegam1VSM inertia integrator output
omegamVSM frequency estimate
deltaomegamPhase-angle integrator input
ICurrent magnitude
deltaVm_un, deltaVmVoltage corrections (before/after limiter)
Pout, QoutActive and reactive power (MW, Mvar)
INJEC GFOR GFM1 BUS_BESS 1. 1. 0. 0. 0.005 0.15 1.0 50.0 5.0 0.05 0.01 1.1 2.0 0.5 0.0 0.05 ;

An advanced grid-forming VSC model with three selectable active-power synchronization modes, comprehensive reactive-power control options, DC-link dynamics, and integrated battery storage. The model is suitable for detailed studies of grid-forming inverters in islanded or weak-grid conditions.

Synchronization mode (selected by delta_m_switch):

  1. VSM — Virtual Synchronous Machine: swing equation with inertia constant HH, droop RvsmR_{\mathrm{vsm}}, and damping KpK_p
  2. Droop — P-ω\omega droop control filtered by TdT_d
  3. Selfsync — Self-synchronization using power error integration with gains KsK_s and KsK_s'

Reactive power control (selected by QV_switch):

  • 0: No reactive power control (Vm0=VrefV_{m0} = V_{\mathrm{ref}})
  • 1: Q-V droop control (Options A, B, or C switchable via QV_switch_state)

Current limiting (selected by VI_CL_switch):

  • 0: Virtual Impedance — attenuates modulated voltage using virtual RviR_{vi} and XviX_{vi}
  • 1: Current Limiter — integral control corrects VmV_m to enforce IImaxI \le I_{\max}

DC link and battery: The DC voltage vdcv_{\mathrm{dc}} evolves according to capacitor dynamics. A PI controller regulates vdcv_{\mathrm{dc}} to its setpoint. Battery SOC is tracked via integration of battery current. SOC limits automatically clamp battery current.

VSM active power loop:

2HdωPdt=[P0+1ωmRvsm]γP=ΔP2H\frac{d\omega_P}{dt} = \left[P_0 + \frac{1-\omega_m}{R_{\mathrm{vsm}}}\right]\gamma - P = \Delta P

ωm=ωPKpP\omega_m = \omega_P - K_p P

dδm,vsmdt=(ωmωref)2πf0\frac{d\delta_{m,\mathrm{vsm}}}{dt} = (\omega_m - \omega_{\mathrm{ref}})\cdot 2\pi f_0

Droop active power loop:

dωdroopdt=ωmeasωdroopTd\frac{d\omega_{\mathrm{droop}}}{dt} = \frac{\omega_{\mathrm{meas}} - \omega_{\mathrm{droop}}}{T_d}

dδm,droopdt=[(P0ωdroop)mp+1ωref]2πf0\frac{d\delta_{m,\mathrm{droop}}}{dt} = \left[(P_0 - \omega_{\mathrm{droop}}) m_p + 1 - \omega_{\mathrm{ref}}\right] \cdot 2\pi f_0

Selfsync active power loop:

dPsdt=PPsTs,ΔPss=P0Ps\frac{d P_s}{dt} = \frac{P - P_s}{T_s}, \qquad \Delta P_{\mathrm{ss}} = P_0 - P_s

dδssdt=[KsΔPss+1ωref]2πf0\frac{d\delta_{\mathrm{ss}}}{dt} = \left[K_s\Delta P_{\mathrm{ss}} + 1 - \omega_{\mathrm{ref}}\right]\cdot 2\pi f_0

δm,sync=δss+KsΔPss\delta_{m,\mathrm{sync}} = \delta_{\mathrm{ss}} + K_s'\Delta P_{\mathrm{ss}}

Phase reactor (algebraic):

vxr+RprixtωrefLpriyt=Vmcos(δm)\frac{v_x}{r} + R_{\mathrm{pr}} i_{xt} - \omega_{\mathrm{ref}} L_{\mathrm{pr}} i_{yt} = V_m \cos(\delta_m)

vyr+Rpriyt+ωrefLprixt=Vmsin(δm)\frac{v_y}{r} + R_{\mathrm{pr}} i_{yt} + \omega_{\mathrm{ref}} L_{\mathrm{pr}} i_{xt} = V_m \sin(\delta_m)

Virtual Impedance current limiting:

fI=max(0,  IIlim),Rvi=KpvifI,Xvi=σxrKpvifIf_I = \max(0,\; I - I_{\mathrm{lim}}), \qquad R_{vi} = K_{pvi}\, f_I, \qquad X_{vi} = \sigma_{xr} K_{pvi}\, f_I

(Vm0cosδmVm0sinδm)=(Vmcosδm+RviixtXviiytVmsinδm+Rviiyt+Xviixt)\begin{pmatrix} V_{m0}\cos\delta_m'\\ V_{m0}\sin\delta_m' \end{pmatrix} = \begin{pmatrix} V_m\cos\delta_m + R_{vi}i_{xt} - X_{vi}i_{yt}\\ V_m\sin\delta_m + R_{vi}i_{yt} + X_{vi}i_{xt} \end{pmatrix}

Modulation index:

m=m0+Δm,f(m)=1+A(1e(m1)/A),A=1+4πm = m_0 + \Delta m, \qquad f(m) = 1 + A\left(1 - e^{-(m-1)/A}\right), \qquad A = -1 + \frac{4}{\pi}

Vm,s=mvdc(limited to [0,mmax])V_{m,s} = m \cdot v_{\mathrm{dc}} \quad (\text{limited to } [0,\, m_{\max}])

DC link dynamics:

Cdcdvdcdt=idcsidcC_{\mathrm{dc}}\frac{dv_{\mathrm{dc}}}{dt} = i_{\mathrm{dcs}} - i_{\mathrm{dc}}

idcs=ires+Ibat,fi_{\mathrm{dcs}} = i_{\mathrm{res}} + I_{\mathrm{bat,f}}

where iresi_{\mathrm{res}} is the non-battery DC current (proportional to AC power) and Ibat,fI_{\mathrm{bat,f}} is the battery current filtered by TsimpT_{\mathrm{simp}}.

Battery SOC:

dSOCdt=IbatCbatIbase,DC\frac{d\mathrm{SOC}}{dt} = -\frac{I_{\mathrm{bat}}}{C_{\mathrm{bat}} \cdot I_{\mathrm{base,DC}}}

Battery current is clamped by rated current and by SOC limits:

Ibat[max ⁣(Irated,ISOCmin),  min ⁣(Irated,ISOC+max)]I_{\mathrm{bat}} \in \left[\max\!\left(-I_{\mathrm{rated}}, I_{\mathrm{SOC-}}^{\min}\right),\; \min\!\left(I_{\mathrm{rated}}, I_{\mathrm{SOC+}}^{\max}\right)\right]

#NameDescriptionUnit
1SnomNominal apparent powerMVA
2PnomNominal DC-side power (base)MW
3VBAC base voltagekV
4Vdc0puInitial DC link voltagepu
5RprPhase reactor resistancepu
6LprPhase reactor inductancepu
7rTransformer turns ratio
8HVSM inertia constants
9R_vsmVSM frequency drooppu
10KpVSM damping constant
11TdDroop filter time constants
12TsSelfsync filter time constants
13KsSelfsync integral gain
14Ks_primeSelfsync feedforward gain
15mpDroop proportional gain (P-ω\omega)
16T_QFReactive power filter time constants
17KqReactive power control gain
18KqvpQ-V PI proportional gain
19KqviQ-V PI integral gain
20TvfVoltage filter time constants
21dvVoltage control proportional gain
22TconvConverter delay time constants
23ImaxMaximum currentpu
24IlimCurrent threshold for virtual impedance activationpu
25nExponent in attenuation factor γ\gamma
26KcCurrent limiter integral gain
27L1Lower limit of current correctionpu
28L2Upper limit of current correctionpu
29KpviVirtual resistance gain
30sigma_xrVirtual reactance-to-resistance ratio
31QV_switchReactive power control flag (0=none, 1=active)flag
32VI_CL_switchCurrent limiting mode (0=VI, 1=CL)flag
33delta_m_switchSynchronization mode (1=VSM, 2=Droop, 3=Selfsync)flag
34CdcpuDC capacitancepu
35KppiDC voltage PI proportional gain
36KipiDC voltage PI integral gain
37TsimpBattery source simplified transfer function time constants
38m_maxUpper limit on modulation index
39SOC0Initial state of charge
40Q_batteryBattery nominal capacityAh
41Vbat_puBattery voltagepu
42I_batratedBattery rated currentkA
43SOC_upperlimitSOC upper limit%
44SOC_lowerlimitSOC lower limit%
45BatFracFraction of power supplied by battery
VariableDescription
Vmo_pu_machbaseModulated voltage setpoint (machine base)
wrefReference angular speed
ixt, iytConverter-side currents
delta_m_radModulated voltage phase angle
delta_m_VSMPhase angle from VSM integrator
delta_m_droopPhase angle from droop integrator
delta_m_syncPhase angle from selfsync integrator
PActive power (Snom base)
P_mDroop-filtered active power
P_sSelfsync-filtered active power
omega_mVSM frequency (pu)
I_pu_machbaseCurrent magnitude
Rvi, XviVirtual impedance components
Vm_pu_machbaseModulated voltage magnitude
vdcDC link voltage
SOCBattery state of charge
i_intIntegrated battery current (for SOC)
Pout_MW, Qout_MVARPower outputs

Observables: Vm_pu_machbase, delta_m_rad, omega_m, Pout_MW, Qout_MVAR, I_pu_machbase, i_dc, vdc, SOC, and more.

INJEC GFOR_v2 GFOR_V2_VSM BUS_BESS 1. 1. 0. 0.
50.0 50.0 20.0 1.0 0.005 0.15 1.0 5.0 0.05 0.01
0.5 0.5 1.0 0.0 0.02 0.5 1.0 1.0 5.0 0.1
0.0 0.05 1.1 0.9 2.0 0.5 0.0 0.05 0.5 1.5
1 0 1 0.005 0.5 5.0 0.05 1.05 0.5 100.0 1.0 0.1 90.0 10.0 0.5 ;

A grid-following VSC model for representing inverter-interfaced generation or storage in following mode. The converter synchronises to the grid via a PLL and regulates active and reactive power through outer PI controllers and an inner current loop. It includes low-voltage protection (PLL freeze), reactive current support during voltage dips, a DC link energy balance equation, and optional voltage-droop reactive support.

The PLL tracks the terminal voltage angle using:

dθplldt=Δωpll,dΔωplldt=Kiwτvq\frac{d\theta_{\mathrm{pll}}}{dt} = \Delta\omega_{\mathrm{pll}}, \qquad \frac{d\Delta\omega_{\mathrm{pll}}}{dt} = \frac{K_{iw}}{\tau}\, v_q

where τ\tau is the PLL response time and vqv_q is the qq-axis voltage. The phase reactor in dd-qq frame:

Ldiddt=Rid+vmdvd+ωLiqL\frac{di_d}{dt} = -R\, i_d + v_{\mathrm{md}} - v_d + \omega\, L\, i_q

Ldiqdt=Riq+vmqvqωLidL\frac{di_q}{dt} = -R\, i_q + v_{\mathrm{mq}} - v_q - \omega\, L\, i_d

Active power outer loop:

dPBdt=P0PKip,id,ref=PB+Kpp(P0P)\frac{dP_B}{dt} = \frac{P_0 - P}{K_{ip}}, \qquad i_{d,\mathrm{ref}} = P_B + K_{pp}\, (P_0 - P)

Reactive outer loop (voltage droop or Q control):

dVBdt=VcompV0Kiq,iq,ref=VB+Kpq(VcompV0)\frac{dV_B}{dt} = \frac{V_{\mathrm{comp}} - V_0}{K_{iq}}, \qquad i_{q,\mathrm{ref}} = V_B + K_{pq}\, (V_{\mathrm{comp}} - V_0)

During voltage dips below Vs1V_{s1}:

iq,support=Imax(Vs1Vt)Vs1Vs2i_{q,\mathrm{support}} = \frac{I_{\mathrm{max}}(V_{s1} - V_t)}{V_{s1} - V_{s2}}

The DC power balance (assuming lossless converter):

pdc=vdcidc=vmdid+vmqiqp_{\mathrm{dc}} = v_{\mathrm{dc}} \cdot i_{\mathrm{dc}} = v_{\mathrm{md}} i_d + v_{\mathrm{mq}} i_q

#NameDescriptionUnit
1RSeries transformer resistancepu
2LSeries transformer reactance/inductancepu
3RcVirtual resistance for voltage controlpu
4XcVirtual reactance for voltage controlpu
5SnomNominal apparent powerMVA
6PnomNominal active powerMW
7KppActive power PI: proportional gain
8KipActive power PI: integral gain
9T_filpActive power recovery filter time constants
10dPdt_minMinimum active power ramp ratepu/s
11dPdt_maxMaximum active power ramp ratepu/s
12KpqReactive power PI: proportional gain
13KiqReactive power PI: integral gain
14tauPLL response times
15vdcDC voltage setpointpu
16Vs_pllPLL freeze voltage thresholdpu
17ImaxMaximum currentpu
18Vs1Voltage threshold for reactive support activationpu
19Vs2Voltage threshold for full reactive supportpu
20qlimReactive power limit (±)pu
21vqswitch1 = voltage control, 0 = reactive power controlflag
VariableDescription
PActive power delivered
ix_1, iy_1VSC currents in xx-yy frame (Snom base)
w_pll, Dw_pllPLL speed and deviation
theta_pllPLL angle
id, iqdd-qq currents
vmd, vmqModulated voltages
PB, VBPI integrator states
idcDC current
id_limLimited active current
QReactive power
P_MW, Q_MVArPower outputs

Observables: Pdc, Q, P_MW, Q_MVAr, I, V, PSnom

INJEC GFol GFOL1 BUS_IBR 1. 1. 0. 0. 0.005 0.15 0.0 0.0 100.0 100.0
2.0 20.0 0.1 -10.0 10.0 2.0 20.0
0.05 1.0 0.1 1.1 0.9 0.7 0.4 1 ;

inj_BESSWithChanges — Battery Energy Storage System

Section titled “inj_BESSWithChanges — Battery Energy Storage System”

A comprehensive BESS model implementing the full WECC framework (REPC_A + REEC_C + REGC_A) plus battery state of charge (SOC) tracking. The model supports both grid-following operation (bidirectional active power dispatch) and reactive power / voltage regulation. It is built on the same REPC_A plant controller as the wind turbine models, and uses the REEC_C converter electrical controller which handles a piecewise-linear IqI_q-vs-VV and IpI_p-vs-VV characteristic for fault ride-through.

The battery SOC evolves through integration of injected power:

dSOCdt=PbessCbatSnom\frac{d\mathrm{SOC}}{dt} = -\frac{P_{\mathrm{bess}}}{C_{\mathrm{bat}} \cdot S_{\mathrm{nom}}}

with hard clamps at SOCmin and SOCmax that modify the active power limits Pmax/Pmin dynamically:

Pmax={0SOCSOCmaxPmax,ratedotherwiseP_{\max} = \begin{cases} 0 & \mathrm{SOC} \ge \mathrm{SOC}_{\max}\\ P_{\max,\mathrm{rated}} & \text{otherwise}\end{cases}

Pmin={0SOCSOCminPmin,ratedotherwiseP_{\min} = \begin{cases} 0 & \mathrm{SOC} \le \mathrm{SOC}_{\min}\\ P_{\min,\mathrm{rated}} & \text{otherwise}\end{cases}

#NameSub-modelDescriptionUnit
1SNOMNominal powerMW
2–32REPC_APlant controller (same as WT3/WT4)various
33–76REEC_CElectrical controller with piecewise Iq(V)I_q(V), Ip(V)I_p(V)various
68CapBatBESSBattery energy capacityMWh
69SOCiniBESSInitial state of chargepu
70SOCmaxBESSMaximum SOC limitpu
71SOCminBESSMinimum SOC limitpu
72–73dPmax, dPminBESSActive power ramp rate limitspu/s
74–75pmax, pminREEC_CActive current limits (pu on SNOM)pu
76TpordREEC_CActive power order time constants

Full parameter listing (125 parameters) is detailed in the embedded header of inj_BESSWithChanges.f90.

The BESS model uses over 40 internal states reflecting the three sub-models. Key states include:

VariableDescription
SOCState of charge
PrefActive power reference
QextReactive power reference from REPC_A
Ip, IqActive/reactive current outputs
PLLPhaseAnglePLL phase angle
Pgen, QgenGenerated powers
INJEC BESSWithChanges BESS1 BUS_ST 1. 1. 0. 0.
100.0 0.0 0.02 0 0.0 0.05 0 0.0 0.3 -0.3 2.0 0.4
0.3 -0.3 0.0 0.15 0.9 0.05 0.0 -0.06 0.06 -0.05 0.05
0.05 -0.05 2.0 1.0 1.0 -1.0 0.02 0 0
0.1 0.1 0.02 1.0 0.0 -0.2 0.2 0.2 -0.2 0.6 0.4 0.6 -0.6 1.1 0.9
1.0 0.5 0.01 0.01 0.05 0.9 0.2 0.9 0.1 0.9 -0.1 0.5 -0.5 0.5 -0.5 1.0 -1.0 0.5 -0.5
50.0 0.7 0.9 0.1 5.0 -5.0 1.0 -1.0 0.05 1.1 0.0 2 0.01 ;

inj_svc_hq_generic1 — SVC (Hydro-Québec Generic)

Section titled “inj_svc_hq_generic1 — SVC (Hydro-Québec Generic)”

A Static VAr Compensator model based on the Hydro-Québec generic SVC structure. It consists of two lead-lag blocks (representing the measurement chain and voltage regulator), a PI voltage controller, and a susceptance limiter. An optional PSS (power system stabiliser) output can add a damping signal to the voltage reference. The model represents the reactive power exchange of the SVC as a variable susceptance BsvcB_{\mathrm{svc}}.

The voltage measurement and regulator chain consists of two transfer functions in cascade:

G1(s)=K1(1+as)1+T1s,G2(s)=K2(1+bs)1+T2sG_1(s) = \frac{K_1(1 + as)}{1 + T_1 s}, \qquad G_2(s) = \frac{K_2(1 + bs)}{1 + T_2 s}

The PI voltage controller computes the susceptance command:

Bsvc,cmd(s)=(Kp+Kis)(Vref+BpBsvcV)B_{\mathrm{svc,cmd}}(s) = \left(K_p + \frac{K_i}{s}\right)\left(V_{\mathrm{ref}} + B_p B_{\mathrm{svc}} - V\right)

The susceptance is limited to [Bmin,Bmax][B_{\min}, B_{\max}], then normalised to the nominal susceptance BnomB_{\mathrm{nom}}:

Qsvc=BsvcBnomV2Q_{\mathrm{svc}} = B_{\mathrm{svc}} \cdot B_{\mathrm{nom}} \cdot V^2

The injected currents satisfy the reactive power balance:

iy=BsvcBnomvx,ix=BsvcBnomvyi_y = -B_{\mathrm{svc}} B_{\mathrm{nom}} v_x, \qquad i_x = B_{\mathrm{svc}} B_{\mathrm{nom}} v_y

#NameDescriptionUnit
1G1Gain of first regulator block
2T1Time constant of first regulator blocks
3aZero time constant of first regulator blocks
4K1Gain of second stage in first block
5L1Saturation limit for first block outputpu
6G2Gain of second regulator block
7T2Time constant of second regulator blocks
8bZero time constant of second regulator blocks
9K2Gain of second block
10L2Saturation limit for second block outputpu
11LtotTotal limit on regulator outputpu
12KpPI controller proportional gain
13KiPI controller integral gain
14BpSlope of V-Q droop characteristicpu/pu
15BmaxMaximum susceptancepu
16BminMinimum susceptancepu
17BnomNominal susceptance (MVAr at 1 pu)MVAr

Computed parameter: Vref (voltage setpoint, computed at initialization)

VariableDescription
iyyy-component of injected current
ixxx-component of injected current
Regulator states (×3)Outputs of lead-lag and PI blocks
PSS states (×2)PSS washout and lead-lag output
BsvcSVC susceptance (normalised)

Observables: Q, dvpss, Bsvc, Vref, Vb

INJEC svc_hq_generic1 SVC1 BUS_SVC 1. 1. 0. 0.
1.0 0.02 0.01 1.0 0.5 1.0 0.05 0.02 1.0 0.5 0.8 100.0 500.0 0.03 200.0 -100.0 100.0 ;

A utility model for testing LVRT behaviour and fault-ride-through capabilities. It injects a shunt admittance into the network at a specified bus, driving the bus voltage to a target value vfault_val set externally (through the RAMSES disturbance interface). The admittance is updated iteratively using a secant method until the voltage target is reached to within ±0.5%. This model requires no user parameters in the data file — all control is through the disturbance mechanism.

The injected currents implement a shunt admittance BfaultB_{\mathrm{fault}}:

ix=Bfaultvx,iy=Bfaultvyi_x = B_{\mathrm{fault}}\, v_x, \qquad i_y = -B_{\mathrm{fault}}\, v_y

The fault admittance is updated via the secant iteration:

Bfault(k+1)=Bfault(k)+VtargetV(k)V/BfaultB_{\mathrm{fault}}^{(k+1)} = B_{\mathrm{fault}}^{(k)} + \frac{V_{\mathrm{target}} - V^{(k)}}{\partial V / \partial B_{\mathrm{fault}}}

where the derivative is estimated numerically from consecutive iteration steps. The discrete state z(1)z(1) tracks convergence: z(1)=1z(1) = 1 when VtargetV0.005|V_{\mathrm{target}} - V| \le 0.005 pu. Up to 10 correction steps are attempted; if convergence is not reached, the simulation halts with an error message.

No user parameters required. The target voltage vfault_val and injector number are set via the RAMSES disturbance module.

VariableDescription
ixxx-component of injected current
iyyy-component of injected current

Discrete state: z(1) — convergence flag (0 = iterating, 1 = converged)

Observable: Xfault — current fault admittance BfaultB_{\mathrm{fault}}

INJEC vfault FAULT_TEST BUS_FAULT ;

The fault voltage level is set through the RAMSES disturbance file or programmatically via vfault_val.