You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Tom Brown f21b81d62e
Merge pull request #179 from nworbmot/master
2 weeks ago
.github .github: add issue/PR templates [skip travis] 5 months ago
binder Mybinder (#150) 2 months ago
doc doc: Document bug fix to multi-link outputs for LOPF pyomo=False 2 weeks ago
examples Fix paths in example notebooks (#172) 1 month ago
pypsa linopf: Fix long line 2 weeks ago
test Small code cleanup (#162) 2 months ago
website Small code cleanup (#162) 2 months ago
.gitignore website: Add website files 3 years ago
.readthedocs.yml conda readthedocs environment 10 months ago
.travis.yml travis: omit python 3.8 due to missing gurobi version for conda (#112) 5 months ago
LICENSE.txt Include full GPL v3 licence 3 years ago MANIFEST add varbiales.csv 7 months ago
Makefile Prepare for travis-ci 2 years ago
README.rst Fix paths in example notebooks (#172) 1 month ago
environment.yaml Merge branch 'master' into nomopyomo 5 months ago
environment_dev.yaml travis: install cbc after environment activation 6 months ago
environment_docs.yml dependency: add pytables/tables for hdf5 export 7 months ago
setup.cfg Include a more friendly package format with etc. 4 years ago PyPSA Version 0.17.0 2 months ago


|badge_pypi| |badge_conda| |badge_travis| |badge_docs| |badge_license| |link-latest-doi| |gitter| |binder|


Python for Power System Analysis

.. contents::

.. section-numbering::


PyPSA stands for "Python for Power System Analysis". It is pronounced "pipes-ah".

PyPSA is a `free software
<>`_ toolbox for
simulating and optimising modern power systems that include features
such as conventional generators with unit commitment, variable wind
and solar generation, storage units, coupling to other energy sectors,
and mixed alternating and direct current networks. PyPSA is designed
to scale well with large networks and long time series.

This project is maintained by the `Energy System Modelling
group <>`_ at the `Institute for
Automation and Applied
Informatics <>`_ at the
`Karlsruhe Institute of
Technology <>`_. The group is funded by the
`Helmholtz Association <>`_ until 2024.
Previous versions were developed by the `Renewable Energy Group
at `FIAS <>`_ to carry out simulations
for the `CoNDyNet project <>`_, financed by the
`German Federal Ministry for Education and Research (BMBF) <>`_ as part of the `Stromnetze Research Initiative <>`_.


`Documentation as a website <>`_

`Quick start <>`_

`Examples <>`_

Documentation is in `sphinx
<>`_ reStructuredText format in
the ``doc`` sub-folder of the repository.


PyPSA can calculate:

* static power flow (using both the full non-linear network equations and
the linearised network equations)
* linear optimal power flow (least-cost optimisation of power plant
and storage dispatch within network constraints, using the linear
network equations, over several snapshots)
* security-constrained linear optimal power flow
* total electricity/energy system least-cost investment optimisation
(using linear network equations, over several snapshots
simultaneously for optimisation of generation and storage dispatch
and investment in the capacities of generation, storage,
transmission and other infrastructure)

It has models for:

* meshed multiply-connected AC and DC networks, with controllable
converters between AC and DC networks
* standard types for lines and transformers following the implementation in `pandapower <>`_
* conventional dispatchable generators with unit commitment
* generators with time-varying power availability, such as
wind and solar generators
* storage units with efficiency losses
* simple hydroelectricity with inflow and spillage
* coupling with other energy carriers
* basic components out of which more complicated assets can be built,
such as Combined Heat and Power (CHP) units, heat pumps, resistive
Power-to-Heat (P2H), Power-to-Gas (P2G), battery electric vehicles
(BEVs), Fischer-Tropsch, direct air capture (DAC), etc.; each of
these is demonstrated in the `examples

Other complementary libraries:

* `pandapower <>`_ for more
detailed modelling of distribution grids, short-circuit
calculations, unbalanced load flow and more
* `PowerDynamics.jl
<>`_ for dynamic
modelling of power grids at time scales where differential equations are relevant

Example scripts as Jupyter notebooks

There are `extensive examples <>`_
available as `Jupyter notebooks <>`_. They are
also described in the `doc/examples.rst <doc/examples.rst>`_ and are
available as Python scripts in `examples/ <examples/>`_.


* `PyPSA-Eur <>`_ optimising capacities of generation, storage and transmission lines (9% line volume expansion allowed) for a 95% reduction in CO2 emissions in Europe compared to 1990 levels

.. image:: doc/img/elec_s_256_lv1.09_Co2L-3H.png
:align: center
:width: 700px

* `SciGRID model <>`_ simulating the German power system for 2015. Interactive plots also be generated with the `plotly <>`_ library, as shown in this `Notebook <>`_

.. image:: doc/img/stacked-gen_and_storage-scigrid.png
:align: center

.. image:: doc/img/lmp_and_line-loading.png
:align: right

.. image:: doc/img/reactive-power.png
:align: center
:width: 600px

* Small meshed AC-DC toy model

.. image:: doc/img/ac_dc_meshed.png
:align: center
:width: 400px

All results from a PyPSA simulation can be converted into an interactive
online animation using `PyPSA-animation
<>`_, for an example see the `PyPSA-Eur-30
example <>`_.

What PyPSA uses under the hood

PyPSA is written and tested to be compatible with Python 3.6 and
3.7. The last release supporting Python 2.7 was PyPSA 0.15.0.

It leans heavily on the following Python packages:

* `pandas <>`_ for storing data about components and time series
* `numpy <>`_ and `scipy <>`_ for calculations, such as
linear algebra and sparse matrix calculations
* `pyomo <>`_ for preparing optimisation problems (currently only linear)
* `plotly <>`_ for interactive plotting
* `matplotlib <>`_ for static plotting
* `cartopy <>`_ for plotting the baselayer map
* `networkx <>`_ for some network calculations
* `py.test <>`_ for unit testing
* `logging <>`_ for managing messages

The optimisation uses pyomo so that it is independent of the preferred
solver. You can use e.g. one of the free solvers `GLPK <>`_
and `CLP/CBC <>`_ or the commercial
solver `Gurobi <>`_
for which free academic licenses are available.

The time-expensive calculations, such as solving sparse linear
equations, are carried out using the `scipy.sparse <>`_ libraries.

Mailing list

PyPSA has a Google Group `forum / mailing list

Anyone can join and anyone can read the posts; only members of the
group can post to the list.

The intention is to have a place where announcements of new releases
can be made and questions can be asked.

To discuss issues and suggest/contribute features
for future development we prefer ticketing through the `PyPSA Github Issues page

Citing PyPSA

If you use PyPSA for your research, we would appreciate it if you
would cite the following paper:

* T. Brown, J. Hörsch, D. Schlachtberger, `PyPSA: Python for Power
System Analysis <>`_, 2018,
`Journal of Open Research Software
<>`_, 6(1),
`arXiv:1707.09913 <>`_,
`DOI:10.5334/jors.188 <>`_

Please use the following BibTeX: ::

author = {T. Brown and J. H\"orsch and D. Schlachtberger},
title = {{PyPSA: Python for Power System Analysis}},
journal = {Journal of Open Research Software},
volume = {6},
issue = {1},
number = {4},
year = {2018},
eprint = {1707.09913},
url = {},
doi = {10.5334/jors.188}

If you want to cite a specific PyPSA version, each release of PyPSA is
stored on `Zenodo <>`_ with a release-specific DOI.
This can be found linked from the overall PyPSA Zenodo DOI:

.. image::


Copyright 2015-2020 Tom Brown (KIT, FIAS), Jonas Hörsch (KIT, FIAS),
David Schlachtberger (FIAS)

This program is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either `version 3 of the
License <LICENSE.txt>`_, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
`GNU General Public License <LICENSE.txt>`_ for more details.

.. |link-latest-doi| image::
.. _link-latest-doi:

.. |badge_pypi| image::
:alt: PyPI version

.. |badge_license| image::
:target: License

.. |badge_travis| image::
:alt: Build status on Linux

.. |badge_docs| image::
:alt: Documentation Status

.. |badge_conda| image::
:alt: Conda version

.. |gitter| image::
:alt: Chat on Gitter

.. |binder| image::
:alt: Examples of use