AI-powered battery dispatch system for Ghana SREP solar mini-grids using LSTM forecasting and PPO reinforcement learning .It is trained on 6 years of real ERA5 climate data from 3 different locations in Ghana
AI Smart Battery Orchestration for Ghana SREP Mini-Grids
This project develops an AI system to manage battery storage in solar mini-grids
across Ghana's Scaling-Up Renewable Energy Programme (SREP). The system learns
when to charge and discharge a battery, hour by hour, to maximise electricity
supply to rural communities while protecting battery health.
It was trained on six years of real ERA5 climate data across six Ghana locations
and evaluated against a conventional rule-based controller.
SYSTEM SPECIFICATIONS
The trained model represents the average Ghana SREP mini-grid site.
Battery capacity 650 kWh LiFePO4
Solar PV 132.5 kWp (176.7 m2 panel area)
Community size Approximately 1,318 people
Mean load 18.96 kW
Max charge rate 130 kW (0.2C)
SOC operating range 20% to 90%
Solar/Load ratio 1.51
TRAINING PIPELINE
The system is built in five sequential phases.
Phase 1 phase1_build_dataset.py
Loads ERA5 climate data for Tamale, Kumasi, and Axim. Merges with a Nigeria
national load profile scaled to the SREP community size. Outputs
master_dataset_scaled.csv.
Phase 2 phase2_train_lstm.py
Trains a two-layer LSTM with 128 hidden units to forecast the next 24 hours
of solar irradiance and load demand from an 8-feature, 24-hour lookback window.
Outputs best_lstm_scaled.pth.
Phase 3 phase3_environment.py
Defines a custom Gymnasium environment wrapping the LSTM forecaster. Models
battery physics with charge and discharge efficiency of 0.95, a solar
performance ratio of 0.75, and a three-mechanism LiFePO4 degradation model:
rainflow cycle aging (Xu et al. 2016), Arrhenius calendar aging with asymmetric
SOC stress (Wang et al. 2014), and a lithium plating penalty below 30% SOC.
Phase 4 phase4_ppo_training.py
Trains a PPO agent using Stable-Baselines3 over three curriculum phases
totalling 12 million steps. The observation space is 52 inputs covering SOC,
SOH, a 24-hour solar forecast, a 24-hour load forecast, …