Efficient Sampling for Data-Driven Frequency Stability Constraint via Forward-Mode Automatic Differentiation

Wangkun Xu, Qian Chen, Pudong Ge, Zhongda Chu, Fei Teng

Introduction

Modern power grids are undergoing a significant transformation, replacing traditional synchronous generators with renewable energy sources like wind and solar. While environmentally beneficial, this shift reduces the grid's mechanical inertia, making frequency stability much more volatile. To maintain reliability, operators must incorporate frequency stability constraints into operational decision-making. However, these constraints are defined by complex Ordinary Differential Equations (ODEs) that are computationally expensive to solve in real-time.

Data-driven models, such as neural networks, offer a faster alternative but require high-quality datasets that accurately capture the "decision boundary" where a system transitions from stable to unstable. Traditional random sampling is inefficient for this task. This paper proposes a gradient-based sampling method using Forward-Mode Automatic Differentiation (FMAD) to efficiently generate informative samples near stability boundaries.

Methodology

The researchers introduce a two-part strategy to improve data generation:

1. Forward-Mode Automatic Differentiation (FMAD)

Standard "unrolling" differentiation techniques (similar to backpropagation through time) are memory-intensive because they store every intermediate state of the ODE solver. In contrast, FMAD augments the original ODE system with sensitivity states. By solving this augmented system, the method computes both the system's frequency response and its exact gradients relative to control parameters in a single pass. This approach is significantly more memory-friendly, which is critical for scaling to large-scale power systems.

2. Gradient Surgery for Multi-Constraint Stability

Power system stability involves multiple, often competing, criteria—such as the Rate of Change of Frequency (RoCoF) and the frequency nadir. Improving one parameter might degrade another. The authors employ "gradient surgery," a technique from multi-task learning, to resolve these conflicts. By projecting conflicting gradients onto a normal plane, the algorithm ensures that the sampling process moves toward the stability boundary while respecting all constraints simultaneously.

Experimental Results

The method was evaluated using a Load Frequency Control (LFC) model with adaptive virtual inertia.

Computational Efficiency and Accuracy

The FMAD approach demonstrated a massive reduction in memory usage. As shown in the performance comparison, FMAD required only 38.76 MB of memory, compared to 1021.46 MB for the unrolling AD method—a 25x improvement. Furthermore, FMAD maintained high accuracy (machine precision), avoiding the significant errors observed with simpler Finite Difference methods, which suffered from errors up to 10,000% due to step-size sensitivity.

Comparison of computational performance and accuracy between different differentiation methods.

Boundary-Targeted Sampling

The algorithm effectively adjusted initial random samples toward the stability boundaries. Figure 1 illustrates how the method can "push" a stable sample to the edge of instability or "pull" an unstable sample back into the safe zone, ensuring the resulting dataset is highly informative for training stability-constrained models.

Frequency and RoCoF response showing the adjustment of samples toward stability boundaries.

Conclusion and Future Work

By leveraging FMAD and gradient surgery, this research provides a memory-efficient and accurate framework for generating high-quality data for power system stability analysis. While FMAD currently exhibits a longer computation time than unrolling AD (3.52s vs 1.54s), the drastic reduction in memory overhead makes it a superior choice for complex, high-dimensional grid models. Future work will focus on integrating this method into online "safe" reinforcement learning frameworks and addressing model-specific limitations, such as the independence of steady-state frequency deviation from certain control parameters.

Summary updated

Abstract

Encoding frequency stability constraints in the operation problem is challenging due to its complex dynamics. Recently, data-driven approaches have been proposed to learn the stability criteria offline with the trained model embedded as a constraint of online optimization. However, random sampling of stationary operation points is less efficient in generating balanced stable and unstable samples. Meanwhile, the performance of such a model is strongly dependent on the quality of the training dataset. Observing this research gap, we propose a gradient-based data generation method via forward-mode automatic differentiation. In this method, the original dynamic system is augmented with new states that represent the dynamic of sensitivities of the original states, which can be solved by invoking any ODE solver for a single time. To compensate for the contradiction between the gradient of various frequency stability criteria, gradient surgery is proposed by projecting the gradient on the normal plane of the other. In the end, we demonstrate the superior performance of the proposed sampling algorithm, compared with the unrolling differentiation and finite difference. All codes are available at https://github.com/xuwkk/frequency_sample_ad.
BibTeX
@inproceedings{xu2024efficient,
  author = {Wangkun Xu and Qian Chen and Pudong Ge and Zhongda Chu and Fei Teng},
  title = {{Efficient Sampling for Data-Driven Frequency Stability Constraint via Forward-Mode Automatic Differentiation}},
  booktitle = {ISGT EUROPE},
  year = {2024},
  doi = {10.1109/isgteurope62998.2024.10863723},
}
Figure