IBR Dynamic Modeling and Simulation
PLL and Grid-Following Control
C1-04 · Lesson + simulation + practice · Allow 90 minutes
Follow synchronization, power commands, and current regulation through a GFL model.
Learning objectives
- Explain how a PLL establishes the local reference frame.
- Derive the power-to-current and current-control paths.
From structure to model
Follow the voltage angle, then control current
A grid-following controller estimates the network angle with a phase-locked loop and expresses voltage and current in that estimated frame. The SRF PLL drives local v_q toward zero. Positive v_q means the voltage vector leads the estimated d axis; the stated PLL sign increases the estimated angle.
Our four-state realization uses δ, the PLL integral ξ, and two ideal current-actuator states i_d and i_q. A 20 ms current-actuator time constant replaces the detailed current controller and LCL plant. It is useful for studying synchronization and command tracking, but cannot evaluate inner-loop resonance or current-limit behavior.
Normalize the PLL and preserve the time scale
The phase detector is e = v_q/|V|. Its PI output is a per-unit frequency offset: ω̂ = 1 + k_p e + k_i ξ, with ξ̇ = e. The relative angle obeys δ̇ = ω_b(ω̂ − ω_g). Near alignment with a stiff voltage, the characteristic polynomial is s² + ω_b k_p s + ω_b k_i.
Set k_p = 2ζω_n/ω_b and k_i = ω_n²/ω_b, where ζ = 0.707 and ω_n = 2πb. The lab’s “PLL bandwidth” b is a natural-frequency design parameter in Hz; it is not a measured closed-loop −3 dB bandwidth in every network.
Map power to current at the measured port
Use the full inverse P–Q map from Module 2, rather than dividing both commands by v_d while assuming v_q = 0 throughout a transient. The local current rotates into the grid frame, then the network gives V = V_g + Z_g I. This feedback makes voltage angle and PLL response depend on grid impedance.
The baseline holds total PoC P = 0.6 and Q = 0. A P-command step changes current demand; a grid-frequency step makes the PLL track the new frequency. This teaching GFL has no frequency–watt law, volt–var law or RoCoF injection. Those are separate controls in the source’s higher-order GFL models.
Interpret a weak-grid experiment carefully
Decrease SCR while holding the commands and gains fixed. Compare P, Q, PCC magnitude and estimated frequency. A smooth response in this model establishes only that this ideal-actuator realization remained bounded for the declared test. The repository’s full 15-state GFL also retains measurement filters and physical plant states.
Reconnect the detailed current-control plant
For the source LCL GFL, a PoC P–Q command first produces grid-side current reference i₂*. With capacitor-current compensation enabled, i₁* = i₂* − ω_b ω̂ c Jv_c. Define e_i = i₁* − i₁ and integrate ξ̇_i = e_i. The current PI, voltage feedforward and inductive decoupling generate the average converter voltage u; then the six LCL equations determine actual current. The full 15-state realization retains one relative angle, one PLL integral, two voltage-measurement states, one frequency-measurement state, two power-command filter states, two current PI integrals and six electrical states. The four-state browser model is a distinct ideal-actuator realization.
Core equations
e=\frac{v_q}{\lVert v\rVert},\quad\dot\xi=e,\quad\hat\omega=1+k_pe+k_i\xi,\quad\dot\delta=\omega_b(\hat\omega-\omega_g)k_p=\frac{2\zeta\omega_n}{\omega_b},\qquad k_i=\frac{\omega_n^2}{\omega_b}\tau_i\dot i_{dq}=i_{dq}^*-i_{dq},\qquad V=V_g+Z_gIi_1^*=i_2^*-\omega_b\hat\omega cJv_c,\quad\dot\xi_i=i_1^*-i_1u=v_c-\omega_b\hat\omega\ell_1Ji_1+K_{pi}(i_1^*-i_1)+K_{ii}\xi_iSimulation experiment
- Run the baseline P step, then select estimated frequency and PCC magnitude.
- Apply a +0.1 Hz grid-frequency step; check the PLL frequency after the transient.
- At SCR = 2, compare PLL design settings of 1 and 5 Hz using the same disturbance.
Laboratory · Python runs in your browser
Predict → run → inspect
Predict the response, then change a parameter and run. The initial plot is a baseline generated by the same solver. The first computation downloads Python; later runs reuse it.
Loading the baseline…
Numerical audit and samples
Low-frequency teaching realization: nominal-frequency algebraic network and ideal current/voltage realization. 50 Hz, 10 kVA, 400 V; initial PCC total P = 0.6, Q = 0; X/R = 10. τᵢ = 0.02 s, τₚ = 0.1 s, τq = 0.05 s, nq = 0.0325; GFM source impedance 0.00625 + j0.1 pu. LCL, inner PI, DC dynamics and current limits are omitted.
Edit the model and reproduce the experiment
The code reads the controls above and plots its own result. Edit the experiment or expand the solver source to test your prediction. Download experiment produces one .py file containing the parameters, full solver and experiment code; local execution needs only Python 3.
case is a snapshot of the controls when you press Run. Call solve(case) and assign the final solution to result to plot it.
The first run needs internet access to download Python. Computation stays in your browser; the solver uses only the standard library.
Ready to run.
Output appears here.
Python result
Inspect and edit the model source (advanced)
The source contains the transforms, LCL, PLL, droop, VSM, shared PCC and explicit reset. Source edits affect the next Python experiment; the laboratory above retains the original teaching equations.
Check your understanding
Trace a voltage disturbance from the PLL to delivered power.
Continue in the source repository
Adapted from local PINN-IBR materials reviewed on 2026-10-03. The web code is a separately authored teaching realization. These repository paths contain the detailed models, configurations and research cases.
Coding/Modeling/src/ibrsim/models/gfl_pll_pq_droop.pyCoding/Modeling/Single-IBR-Infinite-Bus/02_GFL_PLL_PQDroop_Infinite_Bus.ipynb