Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
189 commits
Select commit Hold shift + click to select a range
5d5bad4
Updated single node
PeterKlein11 Sep 5, 2022
86fbed1
regions added as wildcard
PeterKlein11 Sep 5, 2022
5b5d8ce
Code update - up to prepare network
PeterKlein11 Sep 6, 2022
20021ee
Latest update to Xpress
PeterKlein11 Sep 6, 2022
4d562d7
Loadshedding update working
PeterKlein11 Sep 7, 2022
1a60dc4
Update WIP to plotting
PeterKlein11 Sep 26, 2022
9fdf3d1
Plotting progress to date
PeterKlein11 Oct 3, 2022
cd38da9
Multi horizon start
PeterKlein11 Oct 4, 2022
c0c28b8
Data folder included
PeterKlein11 Oct 4, 2022
ff6fdab
Updated load_costs for multi horizon
PeterKlein11 Oct 5, 2022
db9185d
Updated tech expansion limit
PeterKlein11 Oct 5, 2022
dde65f2
Create temporal_clustering.py
PeterKlein11 Oct 5, 2022
5fccd8f
addition of interpolation funtion in load_costs
ndivhuwoMusehane Oct 5, 2022
341f436
Merge branch 'master' of https://github.com/PeterKlein11/pypsa-za
ndivhuwoMusehane Oct 5, 2022
e8ca616
Progress to date
PeterKlein11 Oct 5, 2022
0931af9
Merge branch 'master' of https://github.com/PeterKlein11/pypsa-za
PeterKlein11 Oct 5, 2022
510d303
Updated with hourly averaged
PeterKlein11 Oct 5, 2022
68b334d
Updated plot_network
ndivhuwoMusehane Oct 10, 2022
3586e09
Modified boundaries in config.yaml to show SA map
ndivhuwoMusehane Oct 10, 2022
26f47a7
Minor tweaks to checking investment periods
PeterKlein11 Oct 10, 2022
42f8c2f
Merge branch 'master' of https://github.com/PeterKlein11/pypsa-za
PeterKlein11 Oct 10, 2022
bff3805
Fixed bug in add_electricity isinstance
PeterKlein11 Oct 10, 2022
59ee214
Corrected FREESTATE in num_lines
PeterKlein11 Oct 10, 2022
f25c352
Atlite notebook
ndivhuwoMusehane Oct 11, 2022
e9f5bd0
fixing load costs for plotting
ndivhuwoMusehane Oct 11, 2022
b266b2c
Merge branch 'master' of https://github.com/PeterKlein11/pypsa-za
ndivhuwoMusehane Oct 11, 2022
8b43015
update plotting
ndivhuwoMusehane Oct 11, 2022
ac0ee44
Removed load shedding in network generators
ndivhuwoMusehane Oct 11, 2022
d68b405
Include shape files
PeterKlein11 Oct 11, 2022
015fd41
updated to plot costs
ndivhuwoMusehane Oct 11, 2022
c960048
updated num_lines based on TDP existing and planned lines
ndivhuwoMusehane Oct 12, 2022
b1b4462
fix plotting
ndivhuwoMusehane Oct 12, 2022
58249c9
EAF update
PeterKlein11 Oct 13, 2022
a6987b0
Dispatchable EAF and min_stable added
PeterKlein11 Oct 14, 2022
5971360
Fixed pu_max issue
PeterKlein11 Oct 14, 2022
23130b0
Fix single year reference stations
PeterKlein11 Oct 14, 2022
1d01b55
Update before adding Eskom data
PeterKlein11 Oct 15, 2022
8c534a1
Update existing generators started
PeterKlein11 Oct 15, 2022
31b92c5
reworked add_vre_profiles
PeterKlein11 Oct 17, 2022
44aaace
VRE not working
PeterKlein11 Oct 17, 2022
cb4198f
build_renewables profiles moved to separate file
PeterKlein11 Oct 17, 2022
249e2d4
Updated with REIPPPP included
PeterKlein11 Oct 19, 2022
f212b70
Update before planned decom
PeterKlein11 Oct 21, 2022
01f7ec6
Messy draft - banking
PeterKlein11 Oct 27, 2022
b1cfbee
Mac WIP on cleanup
PeterKlein11 Oct 31, 2022
c6e9b6c
TSAM clustering checked
PeterKlein11 Oct 31, 2022
2aa2b7a
WSL restore point
PeterKlein11 Oct 31, 2022
10c1a88
added natura raster from pypsa-eur
ndivhuwoMusehane Nov 3, 2022
29e101a
Create cutout and calculate renewables potentials
ndivhuwoMusehane Nov 3, 2022
833b8df
ignore cutouts folder contents
ndivhuwoMusehane Nov 3, 2022
ddca0ed
correct snakefile and config file for correct cutout name
ndivhuwoMusehane Nov 3, 2022
081fd14
Uddate snakefile and config
ndivhuwoMusehane Nov 3, 2022
8c09a05
update snakefile
ndivhuwoMusehane Nov 3, 2022
f9fa73d
Updated segmentation
PeterKlein11 Nov 6, 2022
f9c3c35
Annual build limits updated for storage
PeterKlein11 Nov 6, 2022
71d8997
Merge branch 'master' of https://github.com/PeterKlein11/pypsa-za
PeterKlein11 Nov 6, 2022
f41d256
Read renewables profiles netcfd instead of excel data
ndivhuwoMusehane Nov 7, 2022
7a73cfb
resolve add_electricity inputs
ndivhuwoMusehane Nov 7, 2022
b7a40f0
Merge branch 'renewables_profiles'
ndivhuwoMusehane Nov 7, 2022
da1cadb
add_electricity wildcards updated
PeterKlein11 Nov 7, 2022
3124f11
Modified opts base_network
PeterKlein11 Nov 8, 2022
13b983a
Updated changes to snakefile
PeterKlein11 Nov 8, 2022
e4f6b37
write buses for onshore region to geojson
ndivhuwoMusehane Nov 8, 2022
301df6b
Merge branch 'master' of https://github.com/PeterKlein11/pypsa-za
ndivhuwoMusehane Nov 8, 2022
4c8448c
p_pu_max corrected
PeterKlein11 Nov 8, 2022
122aebd
Merge branch 'master' of https://github.com/PeterKlein11/pypsa-za
PeterKlein11 Nov 8, 2022
7c7d1ae
Moved other_re_profiles to add_electricity
PeterKlein11 Nov 8, 2022
f7de30e
Cleaned up scripts folder
PeterKlein11 Nov 8, 2022
3c89d66
Eskom data
PeterKlein11 Nov 9, 2022
a5c0cb5
add build natura raster to rasterize SAPAD and SACAD
ndivhuwoMusehane Nov 9, 2022
40c8035
Merge branch 'add-build_natura_raster.py-from-pypsa-eur'
ndivhuwoMusehane Nov 9, 2022
bb768f0
Merge branch 'master' of https://github.com/PeterKlein11/pypsa-za
ndivhuwoMusehane Nov 9, 2022
1852195
Update renewables profiles to limit to redz or corridors
ndivhuwoMusehane Nov 10, 2022
31dc514
Updated data folder
PeterKlein11 Nov 10, 2022
69b4cc6
PHS issue fixed
PeterKlein11 Nov 14, 2022
2276717
Projected EAF change
PeterKlein11 Nov 14, 2022
29f6f54
Added notebook on atlite_correction
PeterKlein11 Nov 17, 2022
ee58814
Resave
PeterKlein11 Nov 17, 2022
d75a409
apply_wind_correction rule added to the snakefile
PeterKlein11 Nov 17, 2022
6cbbf75
Ubuntu update
PeterKlein11 Dec 4, 2022
55edeeb
Windows update
PeterKlein11 Dec 11, 2022
53a038e
Exclude landusetypes
ndivhuwoMusehane Dec 12, 2022
53e61cf
Update clean
PeterKlein11 Dec 15, 2022
50836f8
Fixed yaml bug
PeterKlein11 Dec 17, 2022
f3c9c8a
Base network and build_topology
PeterKlein11 Dec 26, 2022
140b4ec
Updated topology and base network
PeterKlein11 Dec 27, 2022
e3a5513
Start refactor add_elec
PeterKlein11 Dec 28, 2022
6805406
Jan 4 Updates
PeterKlein11 Jan 4, 2023
dc846b1
Merge pull request #1 from PeterKlein11/Refactor
ndivhuwoMusehane Jan 4, 2023
eb6250c
fix partial_decom error
PeterKlein11 Jan 5, 2023
c8d7cf0
Model_file update
PeterKlein11 Jan 5, 2023
febdf27
model_file_update
PeterKlein11 Jan 5, 2023
e61290d
Update plot colours to ME colours
ndivhuwoMusehane Jan 6, 2023
8ad6739
Merge branch 'master' into ndivhuwoMusehane-updates
ndivhuwoMusehane Jan 6, 2023
20cced6
Merge pull request #1 from ndivhuwoMusehane/ndivhuwoMusehane-updates
ndivhuwoMusehane Jan 6, 2023
93600d5
Read the docs documentation initialize
ndivhuwoMusehane Jan 6, 2023
c7228b0
update index with pypsa-meets-africa template
ndivhuwoMusehane Jan 6, 2023
b3e1a19
Update documentation links
ndivhuwoMusehane Jan 6, 2023
4f38efc
Merge branch 'master' of https://github.com/ndivhuwoMusehane/pypsa-za…
ndivhuwoMusehane Jan 6, 2023
1b5bb34
update index location
ndivhuwoMusehane Jan 6, 2023
99fd6a8
update static
ndivhuwoMusehane Jan 6, 2023
5f57094
Update installation from pypsa-za
ndivhuwoMusehane Jan 6, 2023
8ed401f
Merge branch 'ndivhuwoMusehane-documents'
ndivhuwoMusehane Jan 6, 2023
4cdace2
Update documentation theme
ndivhuwoMusehane Jan 6, 2023
3133ce1
Merge branch 'ndivhuwoMusehane-documents'
ndivhuwoMusehane Jan 6, 2023
8d21f31
Updated aggregate costs in _helpers.py
PeterKlein11 Jan 7, 2023
877f8a4
Documentation update
ndivhuwoMusehane Jan 9, 2023
06008c4
Update _helpers.py
PeterKlein11 Jan 9, 2023
6a4b42f
Merge branch 'PeterKlein11:master' into master
ndivhuwoMusehane Jan 9, 2023
5a60382
update plotting of costs
ndivhuwoMusehane Jan 9, 2023
6894561
Remove partial_decommisioning function
PeterKlein11 Jan 10, 2023
36d7aea
Merge pull request #3 from ndivhuwoMusehane/ndivhuwoMusehane-documents
PeterKlein11 Jan 10, 2023
643a31f
Remove icons
PeterKlein11 Jan 10, 2023
c89e2a2
Merge branch 'master' of https://github.com/PeterKlein11/pypsa-za
PeterKlein11 Jan 10, 2023
c469ba8
Merge branch 'master' of https://github.com/ndivhuwoMusehane/pypsa-za
ndivhuwoMusehane Jan 10, 2023
37d6d66
Merge pull request #5 from ndivhuwoMusehane/master
PeterKlein11 Jan 10, 2023
4ac7c1d
Costs updated following discussion with J. Calitz
PeterKlein11 Jan 11, 2023
e31b010
Test
PeterKlein11 Jan 11, 2023
53b3ee8
update index
ndivhuwoMusehane Jan 12, 2023
7fcd7ea
Merge branch 'ndivhuwoMusehane-documents'
ndivhuwoMusehane Jan 12, 2023
d3e09bf
Merge branch 'PeterKlein11:master' into master
ndivhuwoMusehane Jan 12, 2023
b33ae9b
Merge pull request #6 from ndivhuwoMusehane/master
PeterKlein11 Jan 12, 2023
6988688
documentation content update
ndivhuwoMusehane Jan 12, 2023
cb7aec3
Update conf.py
ndivhuwoMusehane Jan 12, 2023
15c2dd5
Update documetation content
ndivhuwoMusehane Jan 12, 2023
db8937f
Merge branch 'ndivhuwoMusehane-documents'
ndivhuwoMusehane Jan 12, 2023
7fd46a0
Update documentation content
ndivhuwoMusehane Jan 13, 2023
30db237
Merge branch 'master' into ndivhuwoMusehane-documents
ndivhuwoMusehane Jan 13, 2023
b6f90d0
Validation updates
PeterKlein11 Jan 16, 2023
319794a
Merge branch 'master' of https://github.com/PeterKlein11/pypsa-za
PeterKlein11 Jan 16, 2023
4c7327d
Merge remote-tracking branch 'upstream/master'
ndivhuwoMusehane Jan 16, 2023
4453d54
Merge branch 'master' into ndivhuwoMusehane-documents
ndivhuwoMusehane Jan 16, 2023
4491c81
documentation update
ndivhuwoMusehane Jan 17, 2023
61b58c2
Merge pull request #7 from ndivhuwoMusehane/master
PeterKlein11 Jan 24, 2023
84f61c2
Updates
PeterKlein11 Jan 25, 2023
239d558
Merge branch 'master' of https://github.com/PeterKlein11/pypsa-za
PeterKlein11 Jan 25, 2023
9da28a3
Update to use geopackage supply regions
PeterKlein11 Feb 2, 2023
679ac8a
Update README.md for updated PyPSA-ZA
ndivhuwoMusehane May 30, 2023
1b9eb37
Merge pull request #9 from MeridianEconomics/ndivhuwoMusehane-patch-1
PeterKlein11 May 30, 2023
9b7c482
Update README.md
PeterKlein11 Jun 22, 2023
4cecde9
Merge pull request #10 from MeridianEconomics/PeterKlein11-update-readme
PeterKlein11 Jun 22, 2023
04f47ca
Update network representation to GGCA2022
PeterKlein11 Jun 30, 2023
1ac474e
Merge pull request #11 from PeterKlein11/master
PeterKlein11 Jun 30, 2023
7766d92
Cleanup
PeterKlein11 Jun 30, 2023
9d7d2ae
update to base_network build_topology
PeterKlein11 Sep 22, 2023
7bbbff4
Merge pull request #12 from MeridianEconomics/transmission
PeterKlein11 Sep 22, 2023
0b821df
Data cleanup
PeterKlein11 Sep 22, 2023
598accf
Merge pull request #13 from MeridianEconomics/transmission
PeterKlein11 Sep 22, 2023
1400836
Clean up old images
PeterKlein11 Sep 25, 2023
357cc4e
Merge pull request #14 from PeterKlein11/master
PeterKlein11 Sep 25, 2023
29611ef
Updated build_topology
PeterKlein11 Sep 26, 2023
39c7b62
Merge branch 'master' of github.com:MeridianEconomics/pypsa-za2
PeterKlein11 Sep 26, 2023
55db447
Updated build_topology to include St Clair
PeterKlein11 Sep 26, 2023
ddc046f
add envs folder
PeterKlein11 Sep 26, 2023
ed7cee8
Merge pull request #15 from PeterKlein11/master
PeterKlein11 Sep 26, 2023
c715c6f
Refinement to network and topology
PeterKlein11 Sep 26, 2023
29863c7
Merge pull request #16 from PeterKlein11/master
PeterKlein11 Sep 26, 2023
7fc82ed
Part add_elec refactor
PeterKlein11 Oct 27, 2023
469f544
refactor add_electricity.py
PeterKlein11 Nov 9, 2023
5ac9d74
Draft update complete
PeterKlein11 Nov 29, 2023
16c3266
Merge branch 'master' into improve_single_year
PeterKlein11 Dec 12, 2023
bcca39b
Merge pull request #17 from PeterKlein11/improve_single_year
PeterKlein11 Dec 12, 2023
b8ca11f
Full refactor update
PeterKlein11 Dec 12, 2023
5c79227
Merge branch 'master' into master
PeterKlein11 Dec 12, 2023
5ea5a28
Merge pull request #18 from PeterKlein11/master
PeterKlein11 Dec 12, 2023
5fad740
Clean up notebooks
PeterKlein11 Dec 12, 2023
b8da2f1
Fix refactor update
PeterKlein11 Dec 12, 2023
6ca5230
Outages added to model_file
PeterKlein11 Dec 12, 2023
574f818
Fix scripts
PeterKlein11 Dec 13, 2023
478bc9c
Update data
PeterKlein11 Dec 13, 2023
d1ae525
Fix snakefile and config
PeterKlein11 Dec 13, 2023
fa8b8bd
Update notebooks
PeterKlein11 Dec 13, 2023
b431386
Excel files update
PeterKlein11 Dec 13, 2023
c74517e
Merge pull request #2 from PeterKlein11/Fix-repo
PeterKlein11 Dec 13, 2023
77afd06
Merge pull request #19 from PeterKlein11/master
PeterKlein11 Dec 13, 2023
f0257d3
Update README.md
PeterKlein11 Apr 9, 2024
2d49df1
Major version update
PeterKlein11 May 23, 2024
e847f92
Merge pull request #21 from PeterKlein11/master
PeterKlein11 May 23, 2024
5813cfd
Update README.md
PeterKlein11 May 23, 2024
480d0a1
Update readthedocs
PeterKlein11 May 23, 2024
05d1d95
Merge pull request #22 from PeterKlein11/master
PeterKlein11 May 23, 2024
9cfadd4
Update README.md
PeterKlein11 Sep 20, 2024
e266b18
Add files via upload
PeterKlein11 Sep 20, 2024
85a7898
Clean documentation
ndivhuwoMusehane Jul 8, 2025
246b5fb
updated environment.yaml
Jul 8, 2025
d941556
updated environment.yaml
Jul 11, 2025
919d2b6
updated helpers script
Jul 11, 2025
7179360
updated scripts files
Jul 11, 2025
46bdf27
updated config file
Jul 11, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 40 additions & 13 deletions .gitignore
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,13 +1,40 @@
# Snakemake internals
.snakemake*
__pycache__

# Directory structure
networks/*
resources/*
results/*

benchmarks/*
logs/*

data/*
# Snakemake internals
.snakemake*
__pycache__

~$*
**/.vscode/

archive/*
benchmarks/*
cutouts/*
docs/build/*
data/archive/*
data/bundle/*
data/weather/*
envs/archive/*
logs/*
networks/*
notebooks/archive/*
notebooks/private/*
pre_processing/archive/*
pre_processing/resource_processing/archive/*
pre_processing/resource_processing/private/*
pre_processing/resource_processing/availability/*
pre_processing/resource_processing/timeseries_data/*
resources/*
results/*
scenarios/archive/*
scenarios/private/*
scripts/archive/*
scripts/private/*










16 changes: 16 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: 2

build:
os: "ubuntu-20.04"
tools:
python: "3.8"
sphinx:
fail_on_warning: false
configuration: docs/conf.py
formats:
- pdf
- epub
python:
# Install our python package before building the docs
install:
- requirements: docs/requirements.txt
17 changes: 17 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"justMyCode": true,
"cwd": "${fileDirname}"
}
]
}
8 changes: 8 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"editor.fontSize": 18,
"markdown.preview.fontSize": 18,
"terminal.integrated.fontSize": 18,
"scm.inputFontSize": 18,
"cSpell.language": "en-GB",
"taipyStudio.gUI.elementsFilePaths": []
}
154 changes: 78 additions & 76 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,76 +1,78 @@
# PyPSA-ZA

[PyPSA](https://pypsa.org/) model of the South African electricity system at the level of ESKOM's supply regions.

![Visualisation of optimal capacities and costs in the least cost scenario](imgs/network_csir-moderate_redz_E_LC_p_nom_ext.png)

The model is described and evaluated in the paper [PyPSA-ZA: Investment and operation co-optimization of integrating wind and solar in South Africa at high spatial and temporal detail](https://arxiv.org/abs/1710.11199), 2017, [arXiv:1710.11199](https://arxiv.org/abs/1710.11199).

This repository contains the scripts to automatically reproduce the analysis.

## Instructions

To build and solve the model, a computer with about 20GB of memory with a strong
interior-point solver supported by the modelling library
[PYOMO](https://github.com/Pyomo/pyomo) like Gurobi or CPLEX are required.

We recommend as preparatory steps (the path before the `%` sign denotes the
directory in which the commands following the `%` should be entered):

1. cloning the repository using `git` (**to a directory without any spaces in the path**)
```shell
/some/other/path % cd /some/path/without/spaces
/some/path/without/spaces % git clone https://github.com/FRESNA/pypsa-za.git
```

2. installing the necessary python dependencies using conda (from within the `pypsa-za` directory)
```shell
.../pypsa-za % conda env create -f environment.yaml
.../pypsa-za % source activate pypsa-za # or conda activate pypsa-za on windows
```

3. getting the separate [data bundle](https://vfs.fias.science/d/f204668ef2/files/?p=/pypsa-za-bundle.7z&dl=1) (see also [Data dependencies] below) and unpacking it in `data`
```shell
.../data % wget "https://vfs.fias.science/d/f204668ef2/files/?dl=1&p=/pypsa-za-bundle.7z"
.../data % 7z x pypsa-za-bundle.7z
```

All results and scenario comparisons are reproduced using the workflow
management system `snakemake`
```shell
.../pypsa-za % snakemake
[... will take about a week on a recent computer with all scenarios ...]
```

`snakemake` will first compute several intermediate data files in the directory
`resources`, then prepare unsolved networks in `networks`, solve them and save
the resulting networks in `results/version-0.x/networks` and finally render the
main plots into `results/version-0.5/plots`.

Instead of computing all scenarios (defined by the product of all wildcards in
the `scenario` config section), `snakemake` also allows to compute only a
specific scenario like `csir-aggressive_redz_E_LC`:
```shell
.../pypsa-za % snakemake results/version-0.5/plots/network_csir-aggressive_redz_E_LC_p_nom
```

## Data dependencies

For ease of installation and reproduction we provide a bundle
[`pypsa-za-bundle.7z`](https://vfs.fias.science/d/f204668ef2/files/?p=/pypsa-za-bundle.7z&dl=1)
with the necessary data files:

| File | Citation |
|----------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| South_Africa_100m_Population | WorldPop, South Africa 100m Population (2013). [doi:10.5258/soton/wp00246](https://doi.org/10.5258/soton/wp00246) |
| Supply area normalised power feed-in for PV.xlsx | D. S. Bofinger, B. Zimmermann, A.-K. Gerlach, D. T. Bischof-Niemz, C. Mushwana, [Wind and Solar PV Resource Aggregation Study for South Africa](https://www.csir.co.za/csir-energy-centre-documents). (2016). |
| Supply area normalised power feed-in for Wind.xlsx | same as above |
| EIA_hydro_generation_2011_2014.csv | U.S. EIA, [Hydroelectricity Net Generation ZA and MZ 2011-2014](http://tinyurl.com/EIA-hydro-gen-ZA-MZ-2011-2014) (2017). |
| Existing Power Stations SA.xlsx | Compiled by CSIR from [Eskom Holdings](https://www.eskom.co.za/) (Jan 2017) and RSA DOE, [IRP2016](http://www.energy.gov.za/IRP/2016/Draft-IRP-2016-Assumptions-Base-Case-and-Observations-Revision1.pdf) |
| Power_corridors | RSA DEA, [REDZs Strategic Transmission Corridors](https://egis.environment.gov.za/) (Apr 2017) |
| REDZ_DEA_Unpublished_Draft_2015 | RSA DEA, [Wind and Solar PV Energy Strategic Environmental Assessment REDZ Database](https://egis.environment.gov.za/) (Mar 2017) |
| SACAD_OR_2017_Q2 | RSA DEA, [South Africa Conservation Areas Database (SACAD)](https://egis.environment.gov.za/) (Jun 2017) |
| SAPAD_OR_2017_Q2 | RSA DEA, [South Africa Protected Areas Database (SAPAD)](https://egis.environment.gov.za/) (Jun 2017) |
| SystemEnergy2009_13.csv | Eskom, System Energy 2009-13 Hourly, available from Eskom on request |
| SALandCover_OriginalUTM35North_2013_GTI_72Classes | GEOTERRAIMAGE (South Africa), [2013-14 South African National Land-Cover Dataset](https://egis.environment.gov.za/data_egis/node/109) (2017) |

<!--
SPDX-FileCopyrightText: PyPSA-RSA, PyPSA-Eur and PyPSA-Earth Authors

SPDX-License-Identifier: AGPL-3.0-or-later
-->

# Development Status: **Under development**

[![Documentation Status](https://readthedocs.org/projects/pypsa-earth/badge/?version=latest)](https://pypsa-rsa.readthedocs.io/en/latest/?badge=latest)
[![License: AGPL v3](https://img.shields.io/badge/License-AGPLv3-blue.svg)](https://www.gnu.org/licenses/agpl-3.0)
[![Discord](https://img.shields.io/discord/911692131440148490?logo=discord)](https://discord.gg/bsdHkHwujt)
[![Google Drive](https://img.shields.io/badge/Google%20Drive-4285F4?style=flat&logo=googledrive&logoColor=white)](https://drive.google.com/drive/folders/17f54zTMEfeFZhNByXxLkf9qcZRdhng03)

# PyPSA-RSA: An open Optimisation Model of the South African Power System
The accelerating development of open-source energy system modelling tools in recent years has now reached the point where it opens up a credible alternative approach to closed source exclusivity. An ever increasing number of studies are demonstrating that it is possible to produce analysis of a high quality using open-source energy system models, whilst building a wider participating modelling community. This builds confidence in results by enabling more effective peer review of work and therefore more effective feedback loops. It also builds a consistent stream of new talent entering the space to ensure that energy sector analytical capacity can be retained and steadily expanded.

This model makes use of freely available and open data which encourages the open exchange of model data developments and eases the comparison of model results. It provides a full, automated software pipeline to assemble the optimisation model from the original datasets, which enables easy replacement and improvement of the individual parts. Running the model requires a wide range on input datasets. Users are required to access the following datasets from the original sources:

- [GIS shape files for supply regions](https://www.ntcsa.co.za/wp-content/uploads/2024/06/GCCA-2025-GIS.zip)
- [GIS data for existing Eskom transmission lines](https://www.ntcsa.co.za/wp-content/uploads/2024/06/Shapefiles-1.zip)
- [GIS data for population and GVA](http://stepsatest.csir.co.za/socio_econ.html)

Custom data generated for this model will need to be downloaded from [Google Drive](https://drive.google.com/drive/folders/17f54zTMEfeFZhNByXxLkf9qcZRdhng03)

# Spatial resolution
PyPSA-RSA has been designed to conduct capacity expansion planning and resource adequacy studies at differing spatial and temporal resolutions. Five different spatial resolutions are available in the model, and custom GIS shpae files can also be utilsied:

- ``1-supply``: A single node for the entire South Africa.
- ``10-supply``: 10 nodes based on the [GCCA 2025 Eskom Transmission Supply Regions](https://www.eskom.co.za/eskom-divisions/tx/gcca/).
- ``27-supply``: 27 nodes based on the Eskom 27 supply regions as per the original PyPSA-ZA model.
- ``34-supply``: 34 nodes based on the CLNs level in the [GCCA 2025 Eskom Local Supply Regions](https://www.eskom.co.za/eskom-divisions/tx/gcca/).
- ``159-supply``: 159 nodes based on the [GCCA 2025 Eskom Transmission MTS Regions](https://www.eskom.co.za/eskom-divisions/tx/gcca/).

![Spatial resolutions](docs/img/pypsa-rsa_spatial2.png)

PyPSA-RSA can be solved for a single year, or for multiple years, with perfect foresight. Multi-horizon capacity expansion planning is compuationally intensive, and therefore the spatial resolution will typically need to be reduced to ``1-supply`` or ``10-supply`` depending on the number of years modelled. By defualt PyPSA-RSA uses full chronology (8760h per year), but the number of snapshots can be reduced through the use of time-series
segmentation through the open-source [Time Series Aggregation Module (TSAM)]( https://github.com/FZJ-IEK3-VSA/tsam/).

# Resources to get started
PyPSA-RSA is built upon the fundamental components in the [PyPSA library](https://pypsa.org/). Before starting to use this model it is highly recommended to explore the [PyPSA documentation](https://pypsa.readthedocs.io/en/latest/index.html). More detailed documentation can be found under our [readthedocs](https://pypsa-za.readthedocs.io/en/latest/). A two-part video series on using PyPSA and PyPSA-RSA can be found under [link](https://meridianeconomics.co.za/our-publications/pypsa-rsa-workshop1/). Please feel free to join our [Discord channel](https://discord.gg/bsdHkHwujt) to ask questions.

PyPSA-RSA assembles the mathematical equations that need to be solved to generate a result. Whilst open-source solvers such as [HiGHS](https://highs.dev/) and [CBC](https://github.com/coin-or/Cbc) can be used to solve smaller problems, a commercial solver is likely to be required for multi-horizon capacity expansion models. Suitable options include:
- [Gurobi](https://www.gurobi.com/)
- [IBM CPLEX](https://www.ibm.com/products/ilog-cplex-optimization-studio/cplex-optimizer)
- [FICO Xpress](https://www.fico.com/en/products/fico-xpress-optimization)
- [COPT](https://www.shanshu.ai/copt)
- [MindOpt](https://opt.alibabacloud.com/)

RAM requirements will vary based on the complexity of the model. Multi-horizon capacity expansion planning models with full time chronology will likely require between 65-128GB of RAM.

# Installation
1. Open your terminal at a location where you want to install pypsa-rsa. Type the following in your terminal to download the package from GitHub:
```bash
.../some/path/without/spaces % git clone https://github.com/MeridianEconomics/pypsa-rsa.git
```
2. The python package requirements are curated in the `envs/environment.yaml` file.
The environment can be installed using:

```bash
.../pypsa-rsa % conda env create -f envs/environment.yaml
```

If the above takes longer than 30min, you might want to try mamba for faster installation:

```bash
(base) conda install -c conda-forge mamba

.../pypsa-rsa % mamba env create -f envs/environment.yaml
```

3. For running the optimization one has to install the solver. We can recommend the open source HiGHs solver which installation manual is given [here](https://github.com/PyPSA/PyPSA/blob/633669d3f940ea256fb0a2313c7a499cbe0122a5/pypsa/linopt.py#L608-L632).

# Documentation
The documentation is available here: [documentation](https://pypsa-rsa.readthedocs.io/en/latest/?badge=latest).

# Developers
New collaborators are welcome! This project is currently maintained by [Meridian Economics]( https://meridianeconomics.co.za/). Previous versions were developed within the Energy Centre at the [Council for Scientific and Industrial Research (CSIR)](https://www.csir.co.za/) as part of the [CoNDyNet project](https://fias.institute/en/projects/condynet/), which is supported by the [German Federal Ministry of Education and Research](https://www.bmbf.de/bmbf/en/home/home_node.html) under grant no. 03SF0472C. Credits to Jonas Hörsch and Joanne Calitz who developed the original [PyPSA-ZA model](https://arxiv.org/pdf/1710.11199.pdf), [Meridian Economics](http://meridianeconomics.co.za) who extended the PyPSA-ZA model.PyPSA-RSA is relies on a number of functions from the [PyPSA-Eur](https://github.com/PyPSA/pypsa-eur) and [PyPSA-Meets-Earth](https://github.com/pypsa-meets-earth/pypsa-earth).

Loading