Digital twin of South Africa's electricity grid
# GridTwin ZA
**An interactive digital twin of the South African power system.**
Live at: **
nickhedley.github.io
Adjust the fleet, demand and policy — the app re-simulates a full year of hourly dispatch instantly in your browser, runs a 60-year Monte Carlo for load-shedding *risk*, and includes a suite of tools for C&I developers, IPPs, and energy analysts. Driven by **actual Eskom hourly data for 2025**.
Built in the spirit of PyPSA-CA, as the fast intuition layer in front of rigorous optimisation models like PyPSA-RSA.
---
## What it models
A national-level (single-node) hourly dispatch simulation of one calendar year (8,760 hours). Every slider movement re-solves the year in ~20 ms; scenario settings are encoded in the URL for easy sharing. A full 10-region nodal engine runs on demand via the **Nodal Simulation** panel.
**Merit order.** Each hour, demand is served in sequence:
1. **Rooftop / embedded PV** — behind the meter, nets off demand directly
2. **Wind, utility PV, CSP** — zero marginal cost, curtailed only on surplus
3. **Nuclear, hydro, Cahora Bassa imports** — near-must-run
4. **Coal** — 42 GW installed × EAF, with real ramp limits and unit commitment
5. **Pumped storage & batteries** — discharge before peakers; recharge from surplus renewables and off-peak coal headroom
6. **Gas CCGT** (if built) — LNG-fired at ~R2,800/MWh; dispatched only as backup
7. **Diesel OCGT** — last resort, ~R6,100/MWh
8. **Unserved energy** — reported as load shedding; one stage ≈ 1,000 MW shed
**Outage risk (Monte Carlo).** Coal availability follows a mean-corrected daily AR(1) process around the EAF slider value, calibrated to Eskom's reported unplanned outage volatility. The app dispatches **60 synthetic outage-years** per scenario (asynchronously) and reports P(shed >100 GWh), expected and P90 energy shed, stage exceedance probabilities, and expected diesel burn. When a nodal run exists, all 60 paths are scaled by a corridor correction fact …