pypsa-eur/doc/installation.rst

238 lines
7.8 KiB
ReStructuredText
Raw Normal View History

<<<<<<< HEAD
..
2023-02-16 10:50:55 +00:00
SPDX-FileCopyrightText: 2019-2023 The PyPSA-Eur Authors
SPDX-License-Identifier: CC-BY-4.0
=======
>>>>>>> pypsa-eur-sec/master
2019-08-07 08:56:23 +00:00
.. _installation:
2019-06-07 08:34:36 +00:00
##########################################
Installation
##########################################
2019-08-10 20:46:26 +00:00
The subsequently described installation steps are demonstrated as shell commands, where the path before the ``%`` sign denotes the
directory in which the commands following the ``%`` should be entered.
2019-08-06 14:53:32 +00:00
<<<<<<< HEAD
2019-08-06 14:53:32 +00:00
Clone the Repository
====================
2019-08-10 20:46:26 +00:00
First of all, clone the `PyPSA-Eur repository <https://github.com/PyPSA/pypsa-eur>`_ using the version control system ``git``.
The path to the directory into which the ``git repository`` is cloned, must **not** have any spaces!
If you do not have ``git`` installed, follow installation instructions `here <https://git-scm.com/book/en/v2/Getting-Started-Installing-Git>`_.
2019-08-06 14:53:32 +00:00
.. code:: bash
/some/other/path % cd /some/path/without/spaces
/some/path/without/spaces % git clone https://github.com/PyPSA/pypsa-eur.git
2019-08-07 08:56:23 +00:00
.. _deps:
2019-08-06 14:53:32 +00:00
Install Python Dependencies
===============================
2019-08-10 20:46:26 +00:00
PyPSA-Eur relies on a set of other Python packages to function.
We recommend using the package manager and environment management system ``conda`` to install them.
Install `miniconda <https://docs.conda.io/en/latest/miniconda.html>`_, which is a mini version of `Anaconda <https://www.anaconda.com/>`_ that includes only ``conda`` and its dependencies or make sure ``conda`` is already installed on your system.
For instructions for your operating system follow the ``conda`` `installation guide <https://docs.conda.io/projects/conda/en/latest/user-guide/install/>`_.
2019-08-06 14:53:32 +00:00
The python package requirements are curated in the `envs/environment.yaml <https://github.com/PyPSA/pypsa-eur/blob/master/envs/environment.yaml>`_ file.
2019-08-06 14:53:32 +00:00
The environment can be installed and activated using
=======
Install PyPSA-Eur and its data
==============================
First install `PyPSA-Eur <https://github.com/PyPSA/pypsa-eur>`_ and all
its dependencies. Clone the repository:
.. code:: bash
2021-01-01 16:53:59 +00:00
projects % git clone https://github.com/PyPSA/pypsa-eur.git
then download and unpack all the PyPSA-Eur data files by running the following snakemake rule:
.. code:: bash
projects/pypsa-eur % snakemake -j 1 retrieve_databundle
Clone PyPSA-Eur-Sec repository
==============================
2020-08-21 10:16:15 +00:00
Create a parallel directory for `PyPSA-Eur-Sec <https://github.com/PyPSA/pypsa-eur-sec>`_ with:
.. code:: bash
2021-01-01 16:53:59 +00:00
projects % git clone https://github.com/PyPSA/pypsa-eur-sec.git
Environment/package requirements
================================
The requirements are the same as `PyPSA-Eur <https://github.com/PyPSA/pypsa-eur>`_. For
``solve_network.py`` in addition you need ``gurobipy``. If you have
xarray version >= 0.15.1, you will need the latest master branch of
atlite version 0.0.2.
2022-11-18 08:08:07 +00:00
You can create an environment using the environment.yaml file in pypsa-eur/envs:
>>>>>>> pypsa-eur-sec/master
2019-08-06 14:53:32 +00:00
.. code:: bash
.../pypsa-eur % conda env create -f envs/environment.yaml
2019-08-06 14:53:32 +00:00
.../pypsa-eur % conda activate pypsa-eur
<<<<<<< HEAD
Note that activation is local to the currently open shell!
After opening a new terminal window, one needs to reissue the second command!
2019-08-08 15:13:36 +00:00
.. note::
If you have troubles with a slow ``conda`` installation, we recommend to install
`mamba <https://github.com/QuantStack/mamba>`_ as a fast drop-in replacement via
.. code:: bash
conda install -c conda-forge mamba
and then install the environment with
.. code:: bash
mamba env create -f envs/environment.yaml
2019-08-08 15:13:36 +00:00
Install a Solver
================
2019-08-10 20:46:26 +00:00
PyPSA passes the PyPSA-Eur network model to an external solver for performing a total annual system cost minimization with optimal power flow.
PyPSA is known to work with the free software
- `Ipopt <https://coin-or.github.io/Ipopt/INSTALL.html>`_
2019-08-10 20:46:26 +00:00
- `Cbc <https://projects.coin-or.org/Cbc#DownloadandInstall>`_
- `GLPK <https://www.gnu.org/software/glpk/>`_ (`WinGLKP <http://winglpk.sourceforge.net/>`_)
2022-07-26 13:01:21 +00:00
- `HiGHS <https://highs.dev/>`_
2019-08-10 20:46:26 +00:00
and the non-free, commercial software (for some of which free academic licenses are available)
2019-08-10 20:46:26 +00:00
- `Gurobi <https://www.gurobi.com/documentation/quickstart.html>`_
2019-08-10 20:46:26 +00:00
- `CPLEX <https://www.ibm.com/products/ilog-cplex-optimization-studio>`_
- `FICO® Xpress Solver <https://www.fico.com/de/products/fico-xpress-solver>`_
2019-08-08 15:13:36 +00:00
For installation instructions of these solvers for your operating system, follow the links above.
Commercial solvers such as Gurobi and CPLEX currently significantly outperform open-source solvers for large-scale problems.
It might be the case that you can only retrieve solutions by using a commercial solver.
2019-08-10 20:46:26 +00:00
.. seealso::
`Getting a solver in the PyPSA documentation <https://pypsa.readthedocs.io/en/latest/installation.html#getting-a-solver-for-linear-optimisation>`_
.. note::
The rules :mod:`cluster_network` and :mod:`simplify_network` solve a quadratic optimisation problem for clustering.
The open-source solvers Cbc and GlPK cannot handle this. A fallback to Ipopt is implemented in this case, but requires
also Ipopt to be installed. For an open-source solver setup install in your ``conda`` environment on OSX/Linux
.. code:: bash
conda activate pypsa-eur
conda install -c conda-forge ipopt coincbc
and on Windows
.. code:: bash
conda activate pypsa-eur
conda install -c conda-forge ipopt glpk
2023-02-16 10:50:55 +00:00
or
.. code:: bash
conda activate pypsa-eur
pip install highspy
.. _defaultconfig:
Set Up the Default Configuration
================================
PyPSA-Eur has several configuration options that must be specified in a ``config.yaml`` file located in the root directory.
An example configuration ``config.default.yaml`` is maintained in the repository.
More details on the configuration options are in :ref:`config`.
Before first use, create a ``config.yaml`` by copying the example.
.. code:: bash
.../pypsa-eur % cp config.default.yaml config.yaml
Users are advised to regularly check their own ``config.yaml`` against changes in the ``config.default.yaml``
when pulling a new version from the remote repository.
=======
2021-01-01 16:53:59 +00:00
See details in `PyPSA-Eur Installation <https://pypsa-eur.readthedocs.io/en/latest/installation.html>`_
Data requirements
=================
2020-10-12 13:37:47 +00:00
Small data files are included directly in the git repository, while
2022-01-24 11:42:53 +00:00
larger ones are archived in a data bundle on zenodo (`10.5281/zenodo.5824485 <https://doi.org/10.5281/zenodo.5824485>`_).
The data bundle's size is around 640 MB.
2020-10-12 13:37:47 +00:00
To download and extract the data bundle on the command line:
.. code:: bash
2022-01-24 11:42:53 +00:00
projects/pypsa-eur-sec/data % wget "https://zenodo.org/record/5824485/files/pypsa-eur-sec-data-bundle.tar.gz"
projects/pypsa-eur-sec/data % tar -xvzf pypsa-eur-sec-data-bundle.tar.gz
2020-10-12 13:37:47 +00:00
The data licences and sources are given in the following table.
.. csv-table::
:header-rows: 1
:file: data.csv
Set up the default configuration
================================
First make your own copy of the ``config.yaml`` based on
``config.default.yaml``. For example:
.. code:: bash
projects/pypsa-eur-sec % cp config.default.yaml config.yaml
Getting started
===============
In ``config.yaml`` you can control the settings for the scenarios you
want to run, such as the number of nodes, the CO2 limit, the
installable potentials for solar and wind, which technologies are
activated, etc.
To run the full optimization with your settings:
.. code:: bash
projects/pypsa-eur-sec % snakemake -j1
Warning: you may need a computer cluster for this (with e.g. 10-100 GB of RAM
and several processors).
To only prepare the networks, you can run the scripts up to the point before optimization:
.. code:: bash
projects/pypsa-eur-sec % snakemake -j1 prepare_sector_networks
>>>>>>> pypsa-eur-sec/master