koen-vg / stressful-weather

Code and data for reproducing results in the paper on identifying weather-induced power systems stress
5 stars 1 forks source link

Using power system modelling outputs to identify weather-induced extreme events in highly renewable systems

This repository contains the code necessary to reproduce the results of the paper "Using power system modelling outputs to identify weather-induced extreme events in highly renewable systems". Additional data accompanying the paper can be found at DOI:10.5281/zenodo.8328689.

Difficult power system event example

Overview

This repository contains a simple Snakemake-based workflow to organise the computations. The "snakefile" specifying the workflow is found at workflow/Snakefile. Broadly speaking, the workflow follows just a few steps:

  1. A modified version of PyPSA-Eur is used to build a model for the European power system. We build 40 model instances ("networks") corresponding to the 40 weather years 1980-2020 (summer to summer); these instances are identical apart from differing time series for capacity-factors, hydro inflows and temperature-dependent load. The modelling framework PyPSA-Eur is itself organised as a Snakemake workflow; this workflow is included as a snakemake module in the present workflow.
  2. Each network is solved to optimality in capacity-expansion mode in the compute_optimum rule.
  3. Shadow prices of the networks are used to extract a set of system-defining events in the difficult_periods rule.
  4. For validation we also operate each solved network over all weather years with fixed capacities (the solve_operations rule) in order to obtain load shedding data to compare with shadow prices.

Getting started

  1. Clone this git repository with the --recurse-submodules option in order to also pull in PyPSA-Eur:

    git clone --recurse-submodules git@github.com:koen-vg/stressful-weather.git
  2. Obtain the ERA5 historical weather data needed to build the model instances. Download the data for the desired weather years at DOI: 10.11582/2022.00034, and place each file (of the form europe-era5_yyyy where yyyy is the year) in workflow/modules/pypsa-eur/cutouts.

  3. Install Snakemake 7.0.1 or higher. The recommended way is using mamba to install snakemake into its own conda environment as follows:

    mamba create -c conda-forge -c bioconda -n snakemake 'snakemake>=7.0.1'

    Now activate the environment with conda activate snakemake and run snakemake --version to check that you have the correct version installed.

    See https://snakemake.readthedocs.io/en/stable/getting_started/installation.html for more detailed instructions.

  4. Run the whole workflow with the following command:

    snakemake --configfile config/config-stressful-weather.yaml --use-conda -j all -- all_difficult_periods

    Adjust the -j flag to change how many CPU cores to use. For the first time, consider using the testing configuration instead (config/config-testing.yaml), which runs the workflow with a much smaller model and fewer years (but which does require the same ERA5 cutouts as the main config).

  5. Use the operate_all_networks rule to run the operations of each network over every weather year.

Solved networks

Readily build unsolved and solved networks as well as the difficult periods computed from them can be found at DOI:10.5281/zenodo.8328689. They are presented in the same format that would be generated by running the present workflow.

Software versions

The workflow presented here uses fixed software environments (workflow/envs/stressful-weather.fixed.yaml and workflow/modules/pypsa-eur/envs/environment.fixed.yaml) as well as a fixed (modified) version of PyPSA-Eur (the commit at which PyPSA-Eur is included as a git submodule in the present repository) meaning that the results should be reproducible. However, we see no immediate barriers to using newer software versions. While upstream PyPSA-Eur at the time of writing doesn't support multiple weather years, we expect that once this is supported, the present workflow could be made to work with an unmodified, upstream verion of PyPSA-Eur without much effort.

Contributors

This project was developed jointly by Koen van Greevenbroek, Aleksander Grochowicz and Hannah Bloomfield.

Licences

PyPSA-Eur, included here as a git submodule, is distributed under the MIT licences; see the PyPSA-Eur homepage for more information.

All other code included in this repository is licensed under the GPL-3.0.