gridfm-datakit-v1: A Python Library for Scalable and Realistic Power Flow and Optimal Power Flow Data Generation

Alban Puech, Matteo Mazzonelli, Celia Cintas, Tamara Govindasamy, Mangaliso Mngomezulu, Jonas Weiss, Matteo Baù, Anna Varbella, François Mirallès, Kibaek Kim, Le Xie, Hendrik F. Hamann, Etienne E. Vos, Thomas BrunschwilerarXiv 2025 · DOI

Introduction

As the global energy transition accelerates, integrating renewable energy and electric vehicles introduces unprecedented complexity and volatility into power grids. Machine Learning (ML) has emerged as a promising tool for managing these systems; however, the efficacy of ML models is fundamentally constrained by the quality and scale of their training data. Currently, the field suffers from a "data desert," where existing libraries are often fragmented, limited to small-scale networks (typically under 1,000 buses), or produce overly idealized data that lacks the "messy" edge cases—such as branch overloads and voltage violations—encountered in real-world utility operations.

To address these gaps, we present gridfm-datakit, an open-source Python library designed to generate massive, realistic datasets for power grid analysis. By unifying state-of-the-art techniques, it enables the production of diverse Power Flow (PF) and Optimal Power Flow (OPF) data at scales up to 30,000 buses.

Methodology

gridfm-datakit incorporates several novel strategies to bridge the gap between simulation and reality:

  • Hybrid Load Perturbation: The library combines global scaling factors from real-world utility profiles (e.g., EIA data) with localized per-bus noise. This approach preserves the spatial and temporal correlations inherent in actual grids while maintaining high sample diversity.
  • Natural Violation Generation: To train "failure-aware" models, the library generates violations like overloads naturally. It calculates optimal generator settings for a base case and then perturbs the topology (e.g., $N-k$ contingencies). This ensures that failures emerge from the system's physics rather than artificial constraint removals.
  • Cost and Admittance Diversity: By permuting generator cost coefficients and scaling branch resistance/reactance, the library prevents ML models from simply memorizing specific economic or physical configurations.
  • Scalable Backend: Leveraging PowerModels.jl via Julia, the library efficiently solves non-linear AC power flow equations, scaling to systems with over 10,000 buses that typically stall other Python-based tools.

Datasets and Comparison

The library was evaluated using standard benchmarks from the PGLib and MATPOWER collections, including IEEE 24-bus, 118-bus, and GOC 2,000 and 10,000-bus systems. We compared gridfm-datakit against seven existing baselines, including OPFData, PGLearn, PFΔ, and PowerFlowNet.

Comparison of gridfm-datakit-opf with existing OPF data generation libraries.

As shown in the comparison, gridfm-datakit is uniquely capable of handling large grid sizes while supporting a comprehensive suite of variations, including $N-k$ contingencies and admittance variations.

Key Results and Insights

The library demonstrates significant improvements in both generation speed and data diversity:

  • High-Speed Generation: gridfm-datakit can generate 200,000 samples for a 118-bus grid in just 20 minutes. For a 10,000-bus grid, it produces the same volume of PF samples in approximately 23 hours.
  • Superior Diversity: Using normalized Shannon entropy as a metric, the library achieved generator power ($P_g$) diversity scores 2.3x to 2.8x higher than leading libraries like PGLearn and OPFData.
  • Realistic Failure Rates: In PF mode, 79% of scenarios contain at least one branch overload, yet only 1.2% of total branches are overloaded across the dataset. This provides a "needle in a haystack" challenge representative of stressed grids.
Radar charts comparing the entropy (diversity) of features across different PF and OPF datasets.

The "Aha" moment regarding violations came from fixing generator setpoints before changing topology. This creates a balanced mix of safe and overloaded states, mimicking a real operator facing a sudden contingency.

Limitations and Future Work

While gridfm-datakit represents a major advancement, future work will focus on:

  • Granular Profiles: Integrating bus-specific real-world data rather than system-wide aggregates.
  • Subgraph Sampling: Implementing methods to sample smaller sections of massive grids to increase topological diversity.
  • Foundation Models: Feeding data into gridfm-graphkit for training Graph Neural Networks (GNNs) and open-sourcing pre-trained datasets.
  • Economic Indicators: Including "dual solutions" like Locational Marginal Prices (LMPs) for market-based research.

Summary updated

BibTeX
@misc{puech2025gridfm,
  author = {Alban Puech and Matteo Mazzonelli and Celia Cintas and Tamara Govindasamy and Mangaliso Mngomezulu and Jonas Weiss and Matteo Baù and Anna Varbella and François Mirallès and Kibaek Kim and Le Xie and Hendrik F. Hamann and Etienne E. Vos and Thomas Brunschwiler},
  title = {{gridfm-datakit-v1: A Python Library for Scalable and Realistic Power Flow and Optimal Power Flow Data Generation}},
  year = {2025},
  eprint = {2512.14658},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2512.14658},
}
Figure