The CSD-dual-engine is an open-source, zero-topology Dynamic Verification Framework designed to evaluate, benchmark, and provide real-time physical constraints for continuous data-driven control, time-series forecasting, and foundation models operating within high-penetration, lower-inertia electrical power networks. Instability precursors often reside in high-frequency spectral structure that tokenization-based models tend to smooth away; spectral entropy recovers this by measuring the full eigenvalue distribution.
As advanced deep learning architectures and foundation models become increasingly integrated into operational grid optimization—whether through native power system spatial modeling or cross-domain policy transfer—they inherently operate as probabilistic text/action generators. In complex, low-inertia networks, any out-of-distribution neural prediction risks inducing catastrophic, un-damped electromechanical oscillations or triggering hidden bifurcations.
To bridge the gap between deep learning outputs and critical infrastructure safety, this framework provides a zero-topology, physics-driven Evaluation & Guardrail Layer:
- The Predictive Layer: Executes advanced policy inference, predictive tracking, and multi-variable optimization trajectories (applicable to all native or transferred network AI models).
- The Physics Guardrail (CSD-Dual-Engine): Continuously benchmarks the AI-generated trajectories against fundamental physical invariants in near real-time. By tracking the exact state-space proximity to critical transitions via parallel time-domain and spectral-domain metrics, it isolates dynamic stability failure modes before actual system hardware thresholds are violated.
To satisfy the rigorous verification requirements of joint critical infrastructure deployments, this release establishes explicit operational boundaries:
- High-Fidelity Numerical Simulation Environment (Sim2Real Boundary): We ground our baseline empirical validation within industrialized ANDES-equivalent platforms across multi-machine benchmark networks (e.g., IEEE 39-bus and Kundur 4-machine systems). We explicitly address the Sim2Real gap: while these deterministic numerical environments provide the exact clean mathematical reference required to track bifurcation boundaries, practical live deployment requires subsequent stages to filter stochastic noise and complex multi-time-scale converter control interactions.
- Modal Damping Constraints: Our Spectral Engine (Engine B) is highly optimized to track localized and inter-area oscillation modes near critical boundaries (e.g., the 0.6 Hz mode under progressive excitation gain degradation). It serves as a dedicated primary indicator for weak-damping tracking, and is systematically coupled in parallel with our Time-Domain Jacobian Proxy (Engine A) to eliminate blind spots across fast saddle-node bifurcations and voltage collapse regimes.
Traditional grid monitoring relies heavily on Voltage Deviation (
Validated using ANDES v2.0.0 on the New England 39-bus system across 116 multi-fault scenarios (77 stable, 39 unstable) with a 60 Hz PMU-equivalent sampling rate.
- Critical Clearing Time (CCT) Discovery: Systematically identified the exact physical bifurcation boundary for a Bus 16 fault between 1.3s (Stable) and 1.4s (Unstable).
- Pure Data-Driven Inference: Operating without any network topology, power flow models, or pre-trained classifiers, Engine A achieved an exceptional AUC-ROC of 0.8795 using rolling window metrics.
| Metric Evaluation (Post-Fault Window) | AUC-ROC |
|---|---|
score_J (Mean $\log \max |
\lambda(J) |
score_trend (Rolling trend statistic slope) |
0.8025 |
combo (Weighted Composite Score) |
0.8768 |
- Clean Binary Separation: In single-scenario validation, the rolling trend slope provides an instantaneous binary indicator—a positive slope triggers immediate critical alert routing, while a negative slope robustly tracks system post-fault recovery.
To simulate the absolute blind spot of conventional AI models, we executed an intensive 19-point excitation gain (
As the excitation system works harder to maintain voltage setpoints, traditional indicators point in the perfect opposite direction (
| Method / Indicator | Domain | Spearman Correlation ( |
|
Physical Verdict |
|---|---|---|---|---|
| Engine B LFPR (This Work) | Spectral | +0.993 | < 0.0001 | Near-Perfect Primary Indicator |
| Combo (A+B, |
Dual-Domain | +0.974 | < 0.0001 | Excellent Robust Combination |
| Engine B -Entropy | Spectral | -0.930 | < 0.0001 | Strong (Entropy decays as danger rises) |
Engine A score_J |
Time | +0.730 | 0.0004 | Significant Complementary Role |
| Vdev (Traditional Baseline) | Voltage | -0.977 | < 0.0001 | ❌ Complete Systematic Failure |
Rooted in Critical Slowing Down (CSD) theory (Scheffer et al., Nature 2009; Podolsky & Turitsyn, 2013), as a dynamical system approaches bifurcation, energy systematically concentrates into low-frequency modes.
Our spectral engine continuously extracts the Low-Frequency Power Ratio (LFPR) within a fixed
As
Our framework does not rely on a single analytical domain. Instead, it deploys Engine A and Engine B in parallel to achieve comprehensive, multi-domain physics validation near the critical stability boundary, eliminating blind spots across all primary power system instability modes.
| Instability Type | Physical Mechanism | Best Indicator | Rationale |
|---|---|---|---|
| Transient Stability (Large Disturbance) | Nonlinear angle divergence | Engine A (score_J) |
Jacobian captures rapid, highly nonlinear state transitions |
| Small-Signal Stability (Weak Damping) | Low-freq oscillation growth | Engine B (LFPR) |
Fourier directly measures energy redistribution into target modes |
| Voltage Collapse | Saddle-node bifurcation | Engine A ( |
Dynamic Jacobian singularity detection |
| Inter-Area Oscillation (0.1–2 Hz) | Mode undamping | Engine B (LFPR) |
Direct spectral measurement of target frequency |
🎯 Dual-Engine Synergy: Engine A and Engine B serve as independent physical implementations of Critical Slowing Down (CSD) theory. By cross-checking time-domain eigenvalue trajectories against frequency-domain damping rates simultaneously, the system eliminates false positives and robustly flags anomalies before they physically manifest in the grid.
Modern grid AI methods can be evaluated not only by classification accuracy or OPF feasibility, but also by whether their outputs remain consistent with physical stability margins near dynamic boundaries.
This package frames that validation in three layers:
Inspired by recent LLM-driven transient stability assessment workflows, complex power-system scenarios can be generated through simulation tools such as ANDES.
Examples include:
- clearing-time sweeps,
- excitation-gain sweeps,
- weak-damping regimes,
- renewable-penetration stress cases,
- line, bus, or generator disturbance scenarios.
In this package, the reference demo uses a Kundur 4-machine KA sweep as a controlled physical boundary case.
The package computes interpretable early-warning indicators that quantify whether a system is approaching dynamic instability.
The current dual-engine implementation includes:
- Engine A — Time-domain Jacobian proxy
Estimates a local linear transition operator from multichannel PMU-like trajectories and summarizes the eigenvalue trajectory. - Engine B — Spectral CSD indicator
Computes low-frequency power ratio (LFPR) and spectral entropy from sliding FFT windows.
These indicators act as a damping-aware physical scale for weak-damping and low-frequency oscillation regimes.
The intended next step is a standardized interface where any AI system can submit predictions for the same physical scenarios.
Examples of candidate AI systems include:
- grid-native models such as GridSFM-style approaches,
- cross-domain physical foundation models such as TokaMind-style approaches,
- LLM-generated TSA classifiers,
- conventional CNN/LSTM/Transformer stability classifiers.
Their predictions can then be cross-checked against CSD-EWS indicators, damping trends, LFPR, and instability ground truth.
The goal is not to claim that CSD-EWS replaces these models. The goal is to provide a physics-informed validation layer:
Does the AI prediction remain consistent with damping-aware stability evidence near the physical boundary? By establishing this cross-validation interface, we enable rigorous benchmarking of diverse AI architectures—ranging from grid-native foundation models like GridSFM to cross-domain models like TokaMind—against the immutable physical laws governing dynamic stability.
Current power grid stability assessment often relies on static AC-OPF feasibility tools (such as Microsoft GridSFM) to evaluate network topology and static voltage bounds. While highly effective for steady-state analysis, these tools can be complemented by dynamic time-domain monitoring to address transient instabilities.
The CSD-dual-engine introduces a dynamic precursor detection framework, designed to integrate with existing static analysis ecosystems. By continuously evaluating the damping ratio of critical system poles from PMU time-series data, it provides real-time visibility into dynamic phenomena, such as critical slowing down (CSD), prior to apparent voltage collapse.
*Figure 1: Illustration of system behavior under varying damping conditions. In scenarios with weak or negative damping, dynamic instability (captured via LFPR) can escalate even while voltage deviations remain within nominal static bounds.*
*Figure 2: The LFPR metric serves as an early warning indicator for dynamic instability, functioning independently of network topology by analyzing sliding windows of local PMU measurements.*
*Figure 3: Representation of the underlying physical constraints. Engine B extracts dynamic damping properties directly from time-series oscillations, establishing temporal constraints suitable for robust AI control applications.*
To illustrate the relationship between the system's dominant poles (eigenvalues) and the resulting time-domain response, we provide an interactive simulator based on the standard damping ratio formula: ζ = -σ / √(σ² + ω²).
👉 Launch Interactive Simulator (This simulator visually maps the real (σ) and imaginary (ω) components of the extracted Jacobian proxy to the corresponding dynamic behavior, demonstrating the transition from a strongly damped state to sustained oscillations.)
This v0.1 release provides the CSD-EWS reference layer only:
- Engine A: data-driven Jacobian proxy score.
- Engine B: LFPR and spectral entropy score.
- Kundur KA sweep demo using ANDES.
- Spearman correlation analysis against inter-area oscillation amplitude.
- Reproducible figure and data export.
It is intentionally small. It does not include a database, web service, Docker stack, CI pipeline, or full AI benchmark server.
python -m venv .venv
source .venv/bin/activate # Windows: .venv\\Scripts\\activate
pip install -e .Core engine dependencies:
pip install numpy scipy matplotlibFor the Kundur simulation demo, install ANDES:
pip install andes openpyxlpytest -qSmall sweep:
csd-dual-engine --ka-values 10,50,200,500 --output-dir results\_demoFull default 19-point sweep:
csd-dual-engine --output-dir resultsExpected outputs:
results/
├─ kundur\_engine\_ab\_summary.csv
├─ kundur\_engine\_ab.npy
└─ engine\_ab\_compare.png
import numpy as np
from csd\_dual\_engine import engine\_a\_jacobian, engine\_b\_spectral
t = np.arange(0, 15, 1/60)
y = np.column\_stack(\[
np.sin(2\*np.pi\*0.5\*t),
np.cos(2\*np.pi\*0.8\*t),
])
a = engine\_a\_jacobian(t, y, n\_vars=2)
b = engine\_b\_spectral(t, y, fs=60.0)
print(a.log\_max\_eigenvalue\_score)
print(b.lfpr\_score, b.spectral\_entropy\_score)In a weak-damping KA sweep, voltage deviation may decrease because excitation control keeps voltage regulated, even as inter-area oscillation damping deteriorates.
CSD-EWS is designed to catch this type of mismatch:
- voltage can look acceptable,
- damping can still worsen,
- LFPR or Jacobian-proxy indicators can expose the dynamic boundary.
This makes the package useful as a validation reference for AI models that claim to understand grid stability.
Use this package to:
- generate or analyze controlled physical-boundary cases,
- compute damping-aware CSD indicators,
- compare AI predictions against interpretable physical evidence,
- build small benchmark notes for grid AI evaluation,
- support technical discussions around physical AI reliability.
Do not overinterpret this release as:
- a complete PMU production system,
- a certified protection relay,
- a replacement for full power-system studies,
- a complete benchmark for all grid AI models.
- The Kundur demo requires ANDES and its bundled
kundur\_full.xlsxcase. - Engine A uses a PCA-reduced local linear transition operator, then summarizes the final post-fault eigenvalue trajectory.
- Engine B computes LFPR and spectral entropy over sliding windows.
- The package intentionally stays small: no database, no web server, no Docker, no CI by default.
Our CSD-dual-engine architecture serves as a critical, physics-informed verification layer that perfectly complements current agentic workflows in power system analysis:
- Chongqing-Imperial TSA Framework (Hu, Wang, & Pal, 2026): Their outstanding LLM-driven simulation and NAS pipeline achieves high accuracy outcome.
TaiScience Research Group — Open Source Reference Implementation.
If you use this package, please cite or acknowledge:
TaiScience Research Group. Physical Boundary Validation for Grid AI: CSD-EWS Dual-Engine Reference Implementation, 2026.