The Python code below provides a differential-equation-based simulation of Single-Area System Frequency Response (SFR). It quantifies how high-penetration renewable energy integration reduces equivalent inertia ($H$), leading to deeper frequency nadirs and elevated Rates of Change of Frequency ($\text{RoCoF}$) during power imbalance events.
Implements $\frac{d\Delta f}{dt} = \frac{\Delta P_m - \Delta P_d - D\Delta f}{2H}$ via scipy.integrate.solve_ivp to simulate dynamic frequency responses.
Integrates primary frequency response time delays ($T_{gov}$) and speed droop gains ($R = 5\%$) to observe power restoration trajectories.
Simulates low, medium, and high renewable penetration levels by stepping inertia values from $H = 6.0\text{s}$ down to $H = 1.5\text{s}$.
import numpy as np import matplotlib.pyplot as plt from scipy.integrate import solve_ivp def system_frequency_response(t, y, H, D, Pg, Pd_step, T_gov): """ Single-Area Power System Frequency Response (SFR) Model y = [frequency_deviation (Hz), mechanical_power_deviation (p.u.)] """ delta_f, delta_Pm = y # Trigger load step disturbance at t = 1.0s delta_Pd = Pd_step if t >= 1.0 else 0.0 # Differential Equations ddelta_f_dt = (delta_Pm - delta_Pd - D * delta_f) / (2.0 * H) ddelta_Pm_dt = (-delta_Pm - (Pg * delta_f)) / T_gov return [ddelta_f_dt, ddelta_Pm_dt] # --- Parameters & Conditions --- f0 = 50.0 # Nominal grid frequency (Hz) Pd_step = 0.05 # 5% load step disturbance at t=1s D = 1.0 # Load damping factor (p.u./Hz) Pg = 20.0 # Governor gain (1/R where R=0.05) T_gov = 0.5 # Governor time constant (s) t_span = (0, 10) # Time domain (s) t_eval = np.linspace(0, 10, 1000) # Renewable Penetration Scenarios mapped to system inertia H (seconds) scenarios = { "Low Renewable (High Inertia, H=6.0s)": 6.0, "Medium Renewable (Med Inertia, H=3.5s)": 3.5, "High Renewable (Low Inertia, H=1.5s)": 1.5 } # --- Simulation Execution & Visualization --- plt.figure(figsize=(10, 5.5), dpi=100) for label, H_val in scenarios.items(): sol = solve_ivp( system_frequency_response, t_span, [0.0, 0.0], args=(H_val, D, Pg, Pd_step, T_gov), t_eval=t_eval ) actual_freq = f0 + sol.y[0] plt.plot(sol.t, actual_freq, label=label, linewidth=2) plt.axvline(x=1.0, color='#64748b', linestyle='--', label='Load Step (t=1.0s)') plt.axhline(y=f0, color='#334155', linestyle=':', alpha=0.7) plt.title('Impact of Renewable Integration on Grid Frequency Stability', fontsize=12, fontweight='bold') plt.xlabel('Time (s)', fontsize=11) plt.ylabel('Grid Frequency (Hz)', fontsize=11) plt.grid(True, linestyle='--', alpha=0.5) plt.legend(loc='lower right', fontsize=9.5) plt.tight_layout() plt.show()
| Symbol | Parameter Name | Nominal Value | Grid Impact Description |
|---|---|---|---|
| $H$ | Inertia Constant | $1.5\text{s} - 6.0\text{s}$ | Lower inertia causes higher initial RoCoF during power steps. |
| $D$ | Damping Coefficient | $1.0\text{ p.u./Hz}$ | Represents frequency sensitivity of connected loads. |
| $R$ ($1/P_g$) | Speed Droop Constant | $5.0\%$ ($P_g = 20$) | Determines primary reserve output steady-state frequency error. |

Monday -Sunday: 8:00 - 24:00
No.13 Shang Zhen East RD., Taihe Town Baiyun Area, Guangzhou China
info@futuregreenbattery.com
