DEV Community

daniel.sakdinun
daniel.sakdinun

Posted on

Introducing 4PACE: I built an open-source, YAML-driven power grid simulator in Python ⚑

Hi DEV community! πŸ‘‹ I'm Dan, a recent Electrical Engineering graduate. While looking for my first full-time role, I decided to channel my energy into building something that solves a real problem in my field.

Today, I’m excited to share the initial release (v0.1.0a1) of 4PACE (Four-Quadrant Power Analysis & Computational Engine). It’s an open-source, Python-based power system analysis tool.

The Problem with Existing Tools πŸ€”

In power engineering, we often deal with complex simulations. Many existing tools are either expensive commercial black-boxes or require writing a massive amount of boilerplate code just to set up a simple grid topology.

I wanted an engine where users could define the grid simply and transparently, while the core handles the heavy non-linear physics under the hood.

Enter 4PACE πŸš€

4PACE shares a space with great libraries like PyPSA and pandapower, but it brings a few distinct architectural choices to the table:

1. Declarative YAML Topology
Instead of writing Python code to build your network node-by-node, you define the entire grid in a clean YAML file. Once configured, you simply call the analytical functions.

2. Taming the Non-Convex ACOPF
AC Optimal Power Flow (ACOPF) is notoriously non-convex and hard to solve. 4PACE tackles this by applying Convex Relaxation into Cone Programming (SOCP/SDP) using CVXPY. It then uses a Newton-Raphson solver to close the relaxation gap, ensuring the final dispatch is 100% physically rigorous.

3. Built for the Modern Grid
With the rise of renewable energy, 4PACE utilizes Multi-Period Optimal Power Flow (MPOPF) to accurately model the time-series behavior of Inverter-Based Resources (IBR) like Solar and Battery Energy Storage Systems.

Current Features (v0.1.0a1) ⚑

  • Capacity Expansion Planning (CEP)
  • Security-Constrained OPF (SCOPF) with Validate_N1()
  • Fault Analysis
  • Transient Stability equipped with standard IEEE dynamic control models (SEXS, TGOV1, PSS1A, CSVGN1, STATCOM1, and TCSC1).

The Architecture πŸ—οΈ

I prioritized minimal dependencies to keep the library lightweight and easy to audit. The core is an Object-Oriented Differential Algebraic Equation (DAE) engine built on top of NumPy, SciPy, CVXPY, and NetworkX.

I would love your feedback! ❀️

Since this is my very first major open-source project, I would absolutely love any feedback from the experienced developers here. Whether it's about the Pythonic structure, the mathematical implementation, or just general advice!

Thanks for reading! If you are interested in power system modernization or computational engineering, feel free to connect with me.

Top comments (0)