Grid forming droop and virtual synchronous machine.
Version 1.0.1 (103 KB) by
Philippe Lefebvre
This is a model comparing the performance of the droop and virtual synchronous machine grid forming control.
1. Description
The model consists of a 5 MW converter connected to an infinite bus behind and impedance. The converter is fed by a 2000 V dc voltage source. The impedance to the grid can be parametrized by the short circuit ratio as well as the reactance to resistance ratio to allow the reproduction of the results from the article.
The primary controls can be either droop or virtual synchronous machine. The virtual impedance and the inner voltage and current loops can be toggled off. The control parameters are as those in table I of reference [1].
2. Simulation
In the default example you will observe the steady-state operation of the converter with a power setpoint of 2 MW. After 10 seconds the active power set points is increased to 4 MW and after 20 seconds the reactive power set point is set to 3 Mvar. With the "690 V" block modeling the voltage source you can apply a voltage sag, a frequency step or a phase jump as needed depending on the test to reproduce.
Start simulation. Observe voltage and current waveforms on the Scope block. At simulation start the "xInitial" variable containing the initial state variables is automatically loaded (from the " Grid_forming_reproduction_Init.mat" file specified in the Model Properties) so that the simulation starts in steady state.
3. Regenerate Initial Conditions
This example is set-up with all states initialized so that the simulation starts in steady-state. Otherwise, due to the long time constants of the electromechanical part of the wind turbine model and to its relatively slow regulators you would have to wait for tens of seconds before reaching steady-state. The initial conditions have been saved in the " Grid_forming_reproduction_Init.mat" file. When you start simulation, the InitFcn callback (in the Model Properties/Callbacks) automatically loads into your workspace the contents of this .mat file ("xInitial" variable specified in the "Initial state" parameter in the Simulation/Configuration Parameters menu).
If you modify this model, or change parameter values of power components, the initial conditions stored in the "xInitial" variable will no longer be valid and Simulink® will issue an error message. To regenerate the initial conditions for your modified model, follow the steps listed below:
1. In the Configuration Parameters pane, uncheck the "Initial state" parameter and check "Final States" parameter.
2. Remove the stair generators and set a constant active and reactive power setpoints.
3. Start simulation. When Simulation is completed, verify that steady state has been reached by looking at waveforms displayed on the Scope block. The final states which have been saved in the "xFinal" structure with time can be used as initial states for future simulations. Executing the next two commands copies these final conditions in "xInitial" and saves this variable in a new file (MyModelInit.mat).
>> xInitial=xFinal;
>> save MyModelInit xInitial
4. In the InitFcn window of Model Properties pane, replace the first line of initialization commands with "load MyModelInit". Next time you start a simulation with this model, the variable xInitial saved in the MyModelInit.mat file will be loaded in your workspace.
5. In the Configuration Parameters pane, check "Initial state".
6. In the Wind Turbine Generator and Drive train data, reset the inertia constants H back to their original values.
7. Start simulation and verify that your model starts in steady-state.
8. Save your model.
4. References
The grid forming models come from the following article:
N. Mohammed, H. Udawatte, W. Zhou, D. J. Hill and B. Bahrani, "Grid-Forming Inverters: A Comparative Study of Different Control Strategies in Frequency and Time Domains," in IEEE Open Journal of the Industrial Electronics Society, vol. 5, pp. 185-214, 2024, doi: 10.1109/OJIES.2024.3371985. https://ieeexplore.ieee.org/document/10457945
The performance should be similar between the two controls because the tuning of the droop parameters come from the article :
F. Kelada, J. Buire and N. HadjSaid, "Comparative Study of Decentralized Grid-forming Converter Controls For Inverter-based Microgrids," 2023 IEEE Power & Energy Society General Meeting (PESGM), Orlando, FL, USA, 2023, pp. 1-5, doi: 10.1109/PESGM52003.2023.10252590. https://ieeexplore.ieee.org/document/10252590
This model was started from and is a modified version of the "Wind Farm - Synchronous Generator and Full Scale Converter (Type 4) Detailed Model" by Richard Gagnon and Jacques Brochu (Hydro-Quebec)
https://www.mathworks.com/help/sps/ug/wind-farm-synchronous-generator-and-full-scale-converter-type-4-detailed-model.html?searchHighlight=Richard+Gagnon&s_tid=srchtitle_support_results_7_Richard+Gagnon
Cite As
Philippe Lefebvre (2025). Grid forming droop and virtual synchronous machine. (https://www.mathworks.com/matlabcentral/fileexchange/180383-grid-forming-droop-and-virtual-synchronous-machine), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Created with
R2023b
Compatible with any release
Platform Compatibility
Windows macOS LinuxTags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.