Physics-Informed Graph Attention Network with Temporal Convolutional Encoder for Multi-Node Distribution Grid State Forecasting under Solar PV Uncertainty
TL;DR: We hypothesized that physics-informed graph neural networks would outperform simple temporal models for grid state forecasting. We were wrong. This repository documents both the hypothesis and the extensive ablation study that disproved it, ultimately finding that LSTM with simple neighbor averaging beats all complex architectures on this task.
- Summary
- The Journey: From Hypothesis to Reality
- Model Zoo
- Results
- Key Findings
- The Physics Loss Challenge
- Lessons Learned
- Dataset
- Installation and Usage
- Limitations and Acknowledgments
- References
- Citation
- License
This thesis investigates whether physics-informed graph neural networks can improve multi-node distribution grid state forecasting under solar PV uncertainty. The answer, after extensive experimentation, is nuanced but largely negative for the specific conditions studied.
We proposed that combining:
- Graph Attention Networks (GAT) to capture spatial coupling between grid buses
- Temporal Convolutional Networks (TCN) for temporal dynamics
- Physics constraints (Kirchhoff's laws) embedded in the loss function
...would outperform purely temporal models like LSTM.
The simplest hybrid approach (LSTM + neighbor-averaged features) achieved the best results. Complex attention mechanisms and physics constraints either provided no benefit or actively hurt performance.
We designed PI-GAT-TCN with these architectural innovations:
Original PI-GAT-TCN Architecture
+-------------------------------------------------------------+
| Forecast Output Head |
| V, P, Q at all 33 nodes (t+1) |
+-----------------------------+-------------------------------+
|
+-----------------------------v-------------------------------+
| Physics-Informed Loss Layer |
| L = L_forecast + lambda_1*L_KCL + lambda_2*L_PF |
+-----------------------------+-------------------------------+
|
+-----------------------------v-------------------------------+
| TCN Temporal Encoder |
| Dilated causal convolutions [1, 2, 4, 8] |
+-----------------------------+-------------------------------+
|
+-----------------------------v-------------------------------+
| Susceptance-Aware GAT Layers |
| alpha_ij = softmax(MLP([h_i || h_j || B_ij])) |
+-----------------------------+-------------------------------+
|
+-----------------------------v-------------------------------+
| IEEE 33-Bus Graph |
| 33 nodes, 32 branches, radial |
+-------------------------------------------------------------+
Initial Results: PI-GAT-TCN with physics loss performed 4-5x worse than a simple LSTM.
When the original model failed, we conducted systematic ablation:
| Experiment | Hypothesis | Result |
|---|---|---|
| GAT+TCN (no physics) | Physics loss is the problem | Still 3x worse than LSTM |
| Smaller GAT+TCN | Model is over-parameterized | Still 8x worse than LSTM |
| LSTM+Graph Hybrid | Simple graph features might help | Best results achieved |
| PI-GAT-TCN with V-drop loss | Different physics formulation | Training collapsed |
Key Discovery: The problem wasn't just the physics loss. GAT attention itself hurts performance on small, fixed-topology radial networks.
Given that LSTM+Graph was our best architecture, we tested three ways to add physics information:
Results:
- Approach 1 (Physics Features): Slight improvement in P/Q, slight degradation in V
- Approach 2 (Soft KCL Loss): No improvement over baseline
- Approach 3 (Hard Projection): Mathematically invalid for radial networks (see The Physics Loss Challenge)
This repository implements 10 model variants:
| Model | Type | Description | Performance |
|---|---|---|---|
LSTMBaseline |
Temporal | 2-layer LSTM, no graph | Good |
GCNBaseline |
Spatial | Graph convolutional network | Poor |
GATBaseline |
Spatial | Graph attention network | Poor |
GATTCNModel |
Spatiotemporal | GAT + TCN encoder | Moderate |
PIGATTCNModel |
Physics-informed | GAT + TCN + physics loss | Poor |
PIGATTCNVdrop |
Physics-informed | GAT + TCN + voltage drop loss | Failed |
LSTMGraphHybrid |
Hybrid | LSTM + neighbor features | Best |
LSTMGraphPhysFeatures |
Physics-informed | LSTM+Graph + V_drop, KCL features | Good |
LSTMGraphKCLLoss |
Physics-informed | LSTM+Graph + soft KCL loss | Good |
LSTMGraphKCLProj |
Physics-informed | LSTM+Graph + KCL projection | N/A* |
*KCL projection is mathematically invalid for radial networks and was disabled.
| Model | MAE V (pu) | MAE P (kW) | MAE Q (kVAR) | Parameters |
|---|---|---|---|---|
| Persistence Baseline | 0.000045 | - | - | - |
| LSTM+Graph Hybrid | 0.000361 | 0.398 | 0.250 | 203,651 |
| LSTM+Graph PhysFeatures | 0.000418 | 0.363 | 0.236 | 204,675 |
| LSTM+Graph KCL Loss | 0.000428 | 0.418 | 0.253 | 203,651 |
| LSTM Baseline | 0.000450 | 0.657 | 0.387 | 201,603 |
| GAT+TCN | 0.001631 | 2.284 | 1.830 | 288,707 |
| PI-GAT-TCN | 0.002256 | 3.139 | 2.130 | 297,715 |
| GCN Baseline | 0.002544 | 6.438 | 6.650 | 8,899 |
| GAT Baseline | 0.003320 | 15.140 | 10.148 | 85,123 |
| Model | MAE V (pu) | MAE P (kW) | Change from Full |
|---|---|---|---|
| LSTM+Graph Hybrid | 0.000362 | 0.410 | +3.2% P (degrades) |
| LSTM+Graph PhysFeatures | 0.000415 | 0.374 | +3.0% P (degrades) |
| LSTM Baseline | 0.000453 | 0.677 | +3.1% P (degrades) |
| GAT+TCN | 0.001554 | 2.963 | -2.1% P (improves) |
| PI-GAT-TCN | 0.002302 | 3.073 | -2.1% P (improves) |
Observation: Graph-based models show better generalization under stress, but their absolute performance is still worse than temporal models.
Why? On a small radial network with fixed topology:
- There's not enough diversity for attention to learn meaningful patterns
- Uniform averaging is near-optimal when all neighbors matter equally
- Attention adds noise rather than extracting signal
| Physics Approach | Implementation | Outcome |
|---|---|---|
| Soft KCL loss | L_total = L_forecast + lambda * L_KCL |
No improvement |
| Physics features | V_drop, KCL residual as inputs | Marginal P/Q improvement |
| Hard projection | P_proj = P - A_pinv @ (A @ P) |
Mathematically invalid |
Why soft constraints failed:
- The base model (LSTM+Graph) already predicts values that approximately satisfy physics
- Adding physics loss provides redundant gradients
- LRA balancing (Wang et al. 2021) couldn't find a lambda that helped
Why hard projection failed:
- For radial networks, the incidence matrix A is full rank (32x32, rank 32)
- This means
A_pinv @ A = I(identity) - So
P_proj = P - A_pinv @ A @ P = P - P = 0 - The projection collapses all predictions to zero!
At hourly sampling, grid states are highly autocorrelated:
Hour t-23 t-22 t-21 ... t-2 t-1 t | t+1 (predict)
+----+----+----+ +----+----+----+ +----+
|0.99|0.99|0.98| ... |1.00|1.00|1.00|--->|1.00|
+----+----+----+ +----+----+----+ +----+
Persistence baseline achieves MAE V = 0.000045 pu
LSTM learns small corrections on top of this pattern.
Despite worse absolute performance, graph models don't degrade under PV volatility. This suggests spatial modeling becomes valuable at higher temporal resolution or under more extreme conditions.
We attempted five different physics loss formulations, all of which failed:
# WRONG: Unit mismatch
L_KCL = sum(Y @ V - I) # Y in Siemens, V in per-unitProblem: Mixing raw electrical units with normalized ML quantities.
# CORRECT units, but gradients too small
Y_pu = Y * Z_base
L_KCL = sum(Y_pu @ V_pu - I_pu)Problem: KCL mismatch is tiny (~0.001 pu), swamped by forecast loss.
# Sophisticated balancing
P_loss = G_pu * (V_i - V_j)**2
lambda = (1 - alpha) * lambda + alpha * (L_forecast / L_physics)Problem: Lambda either explodes or goes to zero; no stable region.
# Enforce V_drop = (R*P + X*Q) / V
V_drop_expected = linearized_vdrop(R, X, P, Q, V)
L_vdrop = MSE(V_drop_actual, V_drop_expected)Problem: Training collapsed immediately (gradients too large).
# Project onto KCL-feasible manifold
P_proj = P - A_pinv @ A @ PProblem: Mathematically invalid for radial networks (A is full rank).
The unit conversion pipeline from OpenDSS through per-unit to z-score normalization creates opportunities for error at every step. Getting meaningful physics gradients requires perfect consistency across:
- Base values (S_base, V_base, Z_base)
- Per-unit conversion
- Z-score normalization
- Loss computation
- Gradient scaling
One mistake anywhere = meaningless gradients.
-
Simpler is often better. Before designing complex architectures, establish strong baselines. A well-tuned LSTM might be hard to beat.
-
Graph attention needs diversity. GAT excels when different neighbors should receive different attention. On fixed radial topologies, uniform averaging suffices.
-
Physics-informed ML is hard. Getting units, scales, and gradients right for electrical networks requires domain expertise and careful validation.
-
Negative results are valuable. This thesis documents what doesn't work, saving future researchers from the same pitfalls.
-
Start with LSTM + simple features. For hourly distribution grid forecasting, LSTM with neighbor-averaged features is a strong baseline.
-
Graph models may help under volatility. If operating in high-PV-ramp conditions, consider spatiotemporal models despite higher complexity.
-
Don't blindly add physics constraints. Physics loss can hurt if the base model already approximates physics or if the constraint formulation is flawed.
- Higher temporal resolution. 15-minute or 5-minute data would increase spatial signal.
- Meshed network topology. KCL projection works for meshed networks with redundant paths.
- More careful physics validation. Unit-test each component of the physics pipeline independently.
- Probabilistic forecasting. Point forecasts may not need physics; uncertainty might.
NASA POWER API --> PV Model --> OpenDSS --> PyTorch Dataset
(West Java (P_pv = (AC power (V, P, Q per
hourly GHI) eta*A*GHI) flow) node, 24h windows)
| Property | Value |
|---|---|
| Time Range | Full year 2023 |
| Resolution | 1 hour |
| Location | West Java, Indonesia |
| Nodes | 33 buses |
| Edges | 32 branches (radial) |
| PV Nodes | Nodes 6, 14, 21 |
| Features | V, P, Q, is_pv, pv_output |
| Train/Val/Test | 70% / 15% / 15% |
# Clone repository
git clone https://github.com/chairulridjaal/pi-gat-tcn.git
cd pi-gat-tcn
# Create virtual environment
python -m venv venv
source venv/bin/activate # Linux/Mac
venv\Scripts\activate # Windows
# Install dependencies
pip install -r requirements.txtpython data/data_pipeline.py# Best model (recommended)
python src/train.py --config configs/exp3_lstm_graph_hybrid.yaml
# Physics-informed variants
python src/train.py --config configs/lstm_graph_phys_features.yaml
python src/train.py --config configs/lstm_graph_kcl_loss.yaml
# Original ablation ladder
python src/train.py --config configs/lstm.yaml
python src/train.py --config configs/gat_tcn.yaml
python src/train.py --config configs/pi_gat_tcn.yamlpython src/evaluate.py --experiment experiments/<run_name>python generate_charts.pypi-gat-tcn/
├── assets/ # Generated charts for README
├── configs/ # Training configurations
│ ├── lstm.yaml
│ ├── gat_tcn.yaml
│ ├── pi_gat_tcn.yaml
│ ├── exp3_lstm_graph_hybrid.yaml # Best config
│ ├── lstm_graph_phys_features.yaml
│ ├── lstm_graph_kcl_loss.yaml
│ └── lstm_graph_kcl_proj.yaml
├── data/
│ ├── raw/ # IEEE 33-bus DSS file, irradiance
│ ├── processed/ # Processed tensors
│ └── data_pipeline.py # Data generation script
├── models/
│ ├── lstm_baseline.py
│ ├── gcn_baseline.py
│ ├── gat_baseline.py
│ ├── gat_tcn.py
│ ├── pi_gat_tcn.py
│ ├── lstm_graph_hybrid.py # Best model
│ ├── lstm_graph_phys_features.py # Physics features
│ ├── lstm_graph_kcl_loss.py # Soft KCL loss
│ └── lstm_graph_kcl_proj.py # KCL projection (disabled)
├── src/
│ ├── train.py
│ ├── evaluate.py
│ ├── dataset.py
│ ├── metrics.py
│ └── run_experiments.py
├── experiments/ # Training logs and checkpoints
├── generate_charts.py # Chart generation script
├── compute_phys_stats.py # Physics feature normalization
├── requirements.txt
├── LICENSE
└── README.md
-
Hourly resolution limits temporal variability. At 1-hour sampling, consecutive states are nearly identical (persistence MAE V = 0.000045 pu). Higher resolution (15-min, 5-min) would test spatial models more fairly.
-
Constant load profile. The IEEE 33-bus base case uses static loads, eliminating spatial heterogeneity that exists in real feeders.
-
Single location, single year. Dataset uses 2023 NASA POWER data for West Java only. Geographic and inter-annual diversity are not captured.
-
Synthetic data only. While physically grounded via OpenDSS, real-world measurement noise and operational constraints are absent.
I acknowledge that some negative results may stem from my own limitations:
-
Physics loss implementation. Five formulations failed; a more experienced researcher might find a working approach.
-
Hyperparameter tuning. Graph models may perform better with different hyperparameters than those explored.
-
KCL projection for radial networks. The mathematical proof that projection fails is sound, but there may be alternative hard constraint formulations I didn't consider.
-
Unit conversion pipeline. Ensuring consistent per-unit conversion from OpenDSS through loss computation is error-prone; subtle bugs may remain.
This thesis prioritizes transparency about what worked and what didn't, including failures that might be resolved by others.
-
Graph Attention Networks (GAT) Velickovic, P., Cucurull, G., Casanova, A., Romero, A., Lio, P., & Bengio, Y. (2018). Graph Attention Networks. ICLR 2018.
-
Temporal Convolutional Networks (TCN) Bai, S., Kolter, J. Z., & Koltun, V. (2018). An Empirical Evaluation of Generic Convolutional and Recurrent Networks for Sequence Modeling. arXiv:1803.01271.
-
Physics-Informed Neural Networks (PINNs) Raissi, M., Perdikaris, P., & Karniadakis, G. E. (2019). Physics-informed neural networks: A deep learning framework for solving forward and inverse problems involving nonlinear partial differential equations. Journal of Computational Physics, 378, 686-707.
-
Learning Rate Annealing for PINNs Wang, S., Teng, Y., & Perdikaris, P. (2021). Understanding and Mitigating Gradient Flow Pathologies in Physics-Informed Neural Networks. SIAM Journal on Scientific Computing, 43(5), A3055-A3081.
-
IEEE 33-Bus Test Feeder Baran, M. E., & Wu, F. F. (1989). Network reconfiguration in distribution systems for loss reduction and load balancing. IEEE Transactions on Power Delivery, 4(2), 1401-1407.
-
OpenDSS Dugan, R. C., & Montenegro, D. (2020). The Open Distribution System Simulator (OpenDSS). EPRI.
-
KCLNet: Physics-Informed GNN for Power Flow Donon, B., Clement, R., Donnot, B., Marot, A., Guyon, I., & Schoenauer, M. (2020). Neural Networks for Power Flow: Graph Neural Solver. Electric Power Systems Research, 189, 106547.
- NASA POWER Solar Data NASA Langley Research Center POWER Project. (2023). POWER Data Access Viewer. https://power.larc.nasa.gov/
-
PyTorch Paszke, A., et al. (2019). PyTorch: An Imperative Style, High-Performance Deep Learning Library. NeurIPS 2019.
-
PyTorch Geometric Fey, M., & Lenssen, J. E. (2019). Fast Graph Representation Learning with PyTorch Geometric. ICLR Workshop on Representation Learning on Graphs and Manifolds.
If you use this work in your research, please cite:
@misc{nurvikri2026pigattcn,
title = {PI-GAT-TCN: Physics-Informed Graph Attention Networks for
Distribution Grid State Forecasting -- A Negative Result},
author = {Mochamad Chairulridjal Nurvikri},
year = {2026},
url = {https://github.com/chairulridjaal/pi-gat-tcn},
note = {Thesis project documenting extensive ablation study finding that
simple LSTM+Graph hybrid outperforms complex physics-informed
graph neural networks for hourly distribution grid forecasting}
}This project is licensed under the MIT License - see the LICENSE file for details.
Built with PyTorch, PyTorch Geometric, and OpenDSS.
Solar irradiance data courtesy of NASA POWER.
This thesis documents both successes and failures in the spirit of reproducible science.






