2020-05-29 07:50:55 +00:00
|
|
|
..
|
2024-02-19 15:21:48 +00:00
|
|
|
SPDX-FileCopyrightText: 2019-2024 The PyPSA-Eur Authors
|
2020-12-03 18:50:53 +00:00
|
|
|
|
2020-05-29 07:50:55 +00:00
|
|
|
SPDX-License-Identifier: CC-BY-4.0
|
|
|
|
|
2019-08-07 08:56:23 +00:00
|
|
|
.. _intro:
|
|
|
|
|
2019-06-07 08:34:36 +00:00
|
|
|
##########################################
|
|
|
|
Introduction
|
|
|
|
##########################################
|
|
|
|
|
2020-05-28 19:30:10 +00:00
|
|
|
.. raw:: html
|
2020-05-28 18:36:45 +00:00
|
|
|
|
2020-05-28 19:30:10 +00:00
|
|
|
<iframe width="832" height="468" src="https://www.youtube.com/embed/ty47YU1_eeQ" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
|
|
|
|
|
2023-03-15 16:00:06 +00:00
|
|
|
.. note::
|
2024-04-11 13:55:11 +00:00
|
|
|
Find the introductory slides `here <https://docs.google.com/presentation/d/e/2PACX-1vQGQZD7KIVdocRZzRVu8Uk-JC_ltEow5zjtIarhyws46IMJpaqGuux695yincmJA_i5bVEibEs7z2eo/pub?start=false&loop=true&delayms=3000>`__.
|
2020-05-28 18:36:45 +00:00
|
|
|
|
2023-03-17 11:39:13 +00:00
|
|
|
.. warning::
|
|
|
|
The video only introduces the electricity-only part of PyPSA-Eur.
|
|
|
|
|
2019-08-08 15:13:36 +00:00
|
|
|
Workflow
|
2019-06-07 08:34:36 +00:00
|
|
|
=========
|
|
|
|
|
2023-03-15 16:00:06 +00:00
|
|
|
The generation of the model is controlled by the open workflow management system
|
2024-04-11 13:55:11 +00:00
|
|
|
`Snakemake <https://snakemake.github.io/>`__. In a nutshell, the ``Snakefile``
|
2023-03-15 16:00:06 +00:00
|
|
|
declares for each script in the ``scripts`` directory a rule which describes
|
|
|
|
which files the scripts consume and produce (their corresponding input and
|
|
|
|
output files). The ``snakemake`` tool then runs the scripts in the correct order
|
|
|
|
according to the rules' input and output dependencies. Moreover, ``snakemake``
|
|
|
|
will track what parts of the workflow have to be regenerated when files or
|
|
|
|
scripts were modified.
|
2019-08-08 15:13:36 +00:00
|
|
|
|
2023-03-15 16:00:06 +00:00
|
|
|
For instance, an invocation to
|
2019-08-08 15:13:36 +00:00
|
|
|
|
|
|
|
.. code:: bash
|
|
|
|
|
2024-09-13 13:37:01 +00:00
|
|
|
.../pypsa-eur % snakemake -call results/networks/base_s_128_elec_lvopt_.nc
|
2019-08-08 15:13:36 +00:00
|
|
|
|
2023-03-15 16:00:06 +00:00
|
|
|
follows this dependency graph
|
2019-08-08 15:13:36 +00:00
|
|
|
|
2023-03-15 16:00:06 +00:00
|
|
|
.. image:: img/intro-workflow.png
|
2023-02-16 11:37:30 +00:00
|
|
|
:class: full-width
|
2019-08-08 15:13:36 +00:00
|
|
|
|
2023-03-15 16:00:06 +00:00
|
|
|
to solve an electricity system model.
|
|
|
|
|
|
|
|
The **blocks** represent the individual rules which are required to create the
|
|
|
|
file referenced in the command above. The **arrows** indicate the outputs from
|
|
|
|
preceding rules which another rule takes as input data.
|
2019-08-08 15:13:36 +00:00
|
|
|
|
|
|
|
.. note::
|
2023-03-15 16:00:06 +00:00
|
|
|
The dependency graph was generated using
|
2024-09-13 13:37:01 +00:00
|
|
|
``snakemake --dag results/networks/base_s_128_elec_lvopt_.nc -F | sed -n "/digraph/,/}/p" | dot -Tpng -o doc/img/intro-workflow.png``
|
2019-08-08 15:13:36 +00:00
|
|
|
|
2023-03-15 16:00:06 +00:00
|
|
|
For the use of ``snakemake``, it makes sense to familiarize yourself quickly
|
|
|
|
with the `basic tutorial
|
2024-04-11 13:55:11 +00:00
|
|
|
<https://snakemake.readthedocs.io/en/stable/tutorial/basics.html>`__ and then
|
2023-03-15 16:00:06 +00:00
|
|
|
read carefully through the documentation of the `command line interface
|
2024-04-11 13:55:11 +00:00
|
|
|
<https://snakemake.readthedocs.io/en/stable/executing/cli.html>`__, noting the
|
2023-03-15 16:00:06 +00:00
|
|
|
arguments ``-j``, ``-c``, ``-f``, ``-F``, ``-n``, ``-r``, ``--dag`` and ``-t``
|
|
|
|
in particular.
|
2019-08-08 15:13:36 +00:00
|
|
|
|
2019-08-12 17:01:53 +00:00
|
|
|
Scenarios, Configuration and Modification
|
|
|
|
=========================================
|
2019-08-08 15:13:36 +00:00
|
|
|
|
2023-03-15 16:00:06 +00:00
|
|
|
It is easy to run PyPSA-Eur for multiple scenarios using the `wildcards feature
|
2024-04-11 13:55:11 +00:00
|
|
|
<https://snakemake.readthedocs.io/en/stable/snakefiles/rules.html#wildcards>`__
|
2023-03-15 16:00:06 +00:00
|
|
|
of ``snakemake``. Wildcards allow to generalise a rule to produce all files that
|
|
|
|
follow a `regular expression
|
2024-04-11 13:55:11 +00:00
|
|
|
<https://en.wikipedia.org/wiki/Regular_expression>`__ pattern, which defines
|
2023-03-15 16:00:06 +00:00
|
|
|
a particular scenario. One can think of a wildcard as a parameter that shows
|
|
|
|
up in the input/output file names and thereby determines which rules to run,
|
|
|
|
what data to retrieve and what files to produce. Details are explained in
|
|
|
|
:ref:`wildcards` and :ref:`scenario`.
|
2019-08-08 15:13:36 +00:00
|
|
|
|
2023-03-15 16:00:06 +00:00
|
|
|
The model also has several further configuration options collected in the
|
2024-02-12 11:10:05 +00:00
|
|
|
``config/config.default.yaml`` file located in the root directory, which that are not part of
|
2023-03-15 16:00:06 +00:00
|
|
|
the scenarios. Options are explained in :ref:`config`.
|
2019-08-07 08:56:23 +00:00
|
|
|
|
2019-08-11 20:34:18 +00:00
|
|
|
Folder Structure
|
|
|
|
================
|
|
|
|
|
2019-08-12 17:01:53 +00:00
|
|
|
- ``scripts``: Includes all the Python scripts executed by the ``snakemake`` rules.
|
2023-03-15 16:00:06 +00:00
|
|
|
- ``rules``: Includes all the ``snakemake`` rules loaded in the ``Snakefile``.
|
|
|
|
- ``envs``: Includes all the ``conda`` environment specifications to run the workflow.
|
|
|
|
- ``data``: Includes input data that is not produced by any ``snakemake`` rule.
|
|
|
|
- ``cutouts``: Stores raw weather data cutouts from ``atlite``.
|
2019-08-12 17:01:53 +00:00
|
|
|
- ``resources``: Stores intermediate results of the workflow which can be picked up again by subsequent rules.
|
|
|
|
- ``results``: Stores the solved PyPSA network data, summary files and plots.
|
2023-03-15 16:00:06 +00:00
|
|
|
- ``logs``: Stores log files.
|
2019-08-12 17:01:53 +00:00
|
|
|
- ``benchmarks``: Stores ``snakemake`` benchmarks.
|
2023-03-15 16:00:06 +00:00
|
|
|
- ``doc``: Includes the documentation of PyPSA-Eur.
|
2024-01-05 16:33:32 +00:00
|
|
|
- ``graphics``: Includes some graphics for the documentation of PyPSA-Eur.
|
2019-08-12 17:01:53 +00:00
|
|
|
|
2019-08-07 08:56:23 +00:00
|
|
|
System Requirements
|
|
|
|
===================
|
|
|
|
|
2023-03-15 16:00:06 +00:00
|
|
|
Building the model with the scripts in this repository runs on a regular computer.
|
|
|
|
But optimising for investment and operation decisions across many scenarios requires a strong interior-point solver
|
2024-04-11 13:55:11 +00:00
|
|
|
like `Gurobi <http://www.gurobi.com/>`__ or `CPLEX <https://www.ibm.com/analytics/cplex-optimizer>`__ with more memory.
|
2023-03-15 16:00:06 +00:00
|
|
|
Open-source solvers like `HiGHS <https://highs.dev>` can also be used for smaller problems.
|