PINN Transient Stability Analysis

PINN Transient Stability Analysis

Physics-Informed Neural Networks for power system transient stability analysis. Solves the swing equation governing generator rotor dynamics using deep learning with embedded physics constraints.

Technologies

PyTorchPhysics-Informed Neural NetworksDeep LearningNumerical Methods

PINN Transient Stability Analysis

Physics-Informed Neural Networks for power system transient stability analysis. Solves the swing equation governing generator rotor dynamics using deep learning with embedded physics constraints, requiring only sparse measurement data.

Overview

Transient stability analysis asks: when a power system experiences a sudden disturbance (fault, line trip, load change), will the generators remain in synchronism or will the system collapse? This project uses a Physics-Informed Neural Network (PINN) to predict rotor angle and angular speed trajectories and map stability boundaries for a Single Machine Infinite Bus (SMIB) system.

Unlike standard neural networks that learn purely from data, the PINN is penalized during training for violating the swing equation. This enforces physical consistency in the predictions and allows accurate results with very few measurement points.

The Physics

The swing equation governs generator rotor dynamics:

2H/ω₀ · d²δ/dt² = Pm - Pe - D·(dδ/dt)

Equivalently as two first-order ODEs:

dδ/dt  = ω - ω₀
dω/dt  = (ω₀ / 2H) · (Pm - Pe - D·ω_dev)

Where δ is rotor angle, ω is angular speed, H is inertia constant, D is damping, Pm is mechanical power, Pe = Pmax·sin(δ) is electrical power output, and ω_dev = ω - ω₀ is speed deviation.

PINN Loss Function

L_total = λ_data · L_data + λ_physics · L_physics + λ_ic · L_ic

The physics residual L_physics is computed using automatic differentiation through the network (torch.autograd.grad), giving exact derivatives without numerical approximation. If the network output satisfies the swing equation, this residual is zero.

Default weights: λ_physics = 1.0, λ_data = 10.0, λ_ic = 100.0

Architecture

LayerSizeActivationPurpose
Input1 neuronTime t (scalar)
Hidden 1-464 neurons eachTanhLearn temporal patterns
Output2 neuronsLinearδ(t) and ω(t)

Tanh is used instead of ReLU because it is infinitely differentiable, enabling clean gradient computation through the network for the physics loss term. Xavier uniform initialization on all linear layers.

System Parameters (SMIB Benchmark)

ParameterSymbolValueMeaning
Inertia constantH5.0 sKinetic energy stored per MVA
DampingD0.05 puSpeed-proportional damping
Sync speedω₀2π·60 rad/sReference angular velocity
Mechanical powerPm0.8 puPrime mover input
Max electrical powerPmax2.1 puPeak transferable power

Training

Two-phase optimization is used, which is standard in the PINN literature:

Phase 1: Adam (5000 epochs, lr=1e-3) — Fast navigation of the loss landscape.

Phase 2: L-BFGS (500 epochs, lr=0.01) — Quasi-Newton fine-tuning for final convergence.

Expected training time: approximately 3 minutes (Adam) + 5 minutes (L-BFGS) on a T4 GPU.

trainer.train_adam(batch, n_epochs=5000, lr=1e-3)
trainer.train_lbfgs(batch, n_epochs=500, lr=0.01)
trainer.save_model('models/pinn_trained.pt')

Results

  • RMSE (δ): < 0.5 degrees compared to RK4 reference solution
  • RMSE (ω): < 0.01 rad/s
  • Critical Clearing Time (CCT): approximately 200 ms for the default SMIB configuration
  • 2D stability boundary map over fault duration (50–500 ms) vs initial rotor angle

Outputs

PlotDescriptionImage
rk4_reference.pngGround truth rotor angle and speed trajectories from RK4RK4 Reference RK4 Speed
training_history.pngTotal, physics, and data loss curves on log scaleTraining History
pinn_vs_rk4.pngPINN prediction vs RK4 reference with error regionPINN vs RK4
stability_boundary.png2D stable/unstable classification mapStability Boundary
phase_portrait.pngδ vs ω phase portrait for multiple fault durationsPhase Portrait

Troubleshooting

ProblemLikely causeFix
Physics loss stays highλ_physics too lowIncrease from 1.0 to 5.0–10.0
Data loss stays highToo few data pointsIncrease n_data_points to 100–200
Total loss oscillatesLearning rate too highReduce Adam lr to 5e-4
Predictions diverge at t > 1sNetwork underfittingIncrease to 6 layers, 128 neurons
IC error stays highλ_ic too lowIncrease to 500–1000

Dependencies

torch >= 2.0.0
numpy >= 1.24.0
scipy >= 1.10.0
matplotlib >= 3.7.0
scikit-learn >= 1.2.0
tqdm >= 4.65.0

References

  • Raissi, Perdikaris & Karniadakis (2019). Physics-informed neural networks. Journal of Computational Physics.
  • Misyris, Venzke & Chatzivasileiadis (2020). Physics-Informed Neural Networks for Power Systems. IEEE PES General Meeting.
  • Kundur (1994). Power System Stability and Control. McGraw-Hill.