Skip to main content
PyPSA Banner

PyPSA - Python for Power System Analysis

PyPI version Conda version Python Version from PEP 621 TOML Tests Documentation Status pre-commit.ci status Code coverage REUSE status Ruff License Zenodo Discord Contributor Covenant

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

PyPSA is an open-source Python framework for optimising and simulating modern power and energy systems that include features such as conventional generators with unit commitment, variable wind and solar generation, hydro-electricity, inter-temporal storage, coupling to other energy sectors, elastic demands, and linearised power flow with loss approximations in DC and AC networks. PyPSA is designed to scale well with large networks and long time series. It is made for researchers, planners and utilities with basic coding aptitude who need a fast, easy-to-use and transparent tool for power and energy system analysis.

[!NOTE] PyPSA has many contributors, with the maintenance led by the Department of Digital Transformation in Energy Systems at the Technical University of Berlin. The project is currently supported by the German Research Foundation (grant number 528775426). Previous versions were developed at the Karlsruhe Institute of Technology funded by the Helmholtz Association, and at FIAS funded by the German Federal Ministry for Education and Research (BMBF).

Features

  • Economic Dispatch (ED): Models short-term market-based dispatch including unit commitment, renewable availability, short-duration and seasonal storage including hydro reservoirs with inflow and spillage dynamics, elastic demands, load shedding and conversion between energy carriers, using either perfect operational foresight or rolling horizon time resolution.

  • Linear Optimal Power Flow (LOPF): Extends economic dispatch to determine the least-cost dispatch while respecting network constraints in meshed AC-DC networks, using a linearised representation of power flow (KVL, KCL) with optional loss approximations.

  • Security-Constrained LOPF (SCLOPF): Extends LOPF by accounting for line outage contingencies to ensure system reliability under $N-1$ conditions.

  • Capacity Expansion Planning (CEP): Supports least-cost long-term system planning with investment decisions for generation, storage, conversion, and transmission infrastructure. Handles both single and multiple investment periods. Continuous and discrete investments are supported.

  • Pathway Planning: Supports co-optimisation of multiple investment periods to plan energy system transitions over time with perfect planning foresight.

  • Stochastic Optimisation: Implements two-stage stochastic programming framework with scenario-weighted uncertain inputs, with investments as first-stage decisions and dispatch as recourse decisions.

  • Modelling-to-Generate-Alternatives (MGA): Explores near-optimal decision spaces to provide insight into the range of feasible system configurations with similar costs.

  • Sector-Coupling: Modelling integrated energy systems with multiple energy carriers (electricity, heat, hydrogen, etc.) and conversion between them. Flexible representation of technologies such as heat pumps, electrolysers, battery electric vehicles (BEVs), direct air capture (DAC), and synthetic fuels production.

  • Static Power Flow Analysis: Computes both full non-linear and linearised load flows for meshed AC and DC grids using Newton-Raphson method.

Documentation

PyPSA has extensive documentation with tutorials, user guides, examples and an API reference.

Installation

pip:

pip install pypsa

conda/mamba:

conda install -c conda-forge pypsa

uv:

uv add pypsa

Usage

import pypsa

# create a new network
n = pypsa.Network()
n.add("Bus", "mybus")
n.add("Load", "myload", bus="mybus", p_set=100)
n.add("Generator", "mygen", bus="mybus", p_nom=100, marginal_cost=20)

# load an example network
n = pypsa.examples.ac_dc_meshed()

# run the optimisation
n.optimize()

# plot results
n.generators_t.p.plot()
n.plot()

# get statistics
n.statistics()
n.statistics.energy_balance()

Dependencies

PyPSA relies heavily on other open-source Python packages. Some of them are:

Find the full list of dependencies in the pyproject.toml file.

PyPSA can be used with different solvers. For instance, the free solvers HiGHS (installed by default), GLPK and CBC or commercial solvers like Gurobi or FICO Xpress for which free academic licenses are available.

Contributing and Support

We strongly welcome anyone interested in contributing to this project. If you have any ideas, suggestions or encounter problems, feel invited to file issues or make pull requests on GitHub.

  • To discuss with other PyPSA users, organise projects, share news, and get in touch with the community you can use the Discord server.
  • For bugs and feature requests, please open an issue.
  • For troubleshooting and support, please check the troubleshooting and support sections in the documentation.

Detailed guidelines can be found in the Contributing guidelines of our documentation.

Code of Conduct

Please respect our Code of Conduct.

Citing PyPSA

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

Please use the following BibTeX:

@article{PyPSA,
   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 = {https://doi.org/10.5334/jors.188},
   doi = {10.5334/jors.188}
}

If you want to cite a specific PyPSA version, each release of PyPSA is archived on Zenodo with a release-specific DOI: DOI

Licence

Copyright PyPSA Contributors

PyPSA is licensed under the open source MIT License. The documentation is licensed under CC-BY-4.0.

The repository uses REUSE to expose the licenses of its files.

Release files for pypsa 1.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pypsa 1.3.0
File Size Uploaded
pypsa-1.3.0.tar.gz 9.9 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for pypsa 1.3.0
File Interpreter ABI Platform
pypsa-1.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 10.3 MB

Release files / pypsa-1.3.0.tar.gz

Download URL pypsa-1.3.0.tar.gz
Size 9.9 MB
Tags Source
SHA-256 checksum
How to use checksums
143c2fee240787b02f5bfdaa022c17baf43eafa9c0b6edb55cf6c1f1f880cac8
BLAKE2b-256 checksum
How to use checksums
18e2b0463e81e793d888d83f99d51a0b266e1b0442e42b05a57d5177ce0f70eb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 19, 2026.

Transparency log

Release files / pypsa-1.3.0-py3-none-any.whl

Download URL pypsa-1.3.0-py3-none-any.whl
Size 392.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4c3044543f3f69d129154ee584c84835a8f09ba0ed1ee119c3c87850d5863f51
BLAKE2b-256 checksum
How to use checksums
2f8f078f9fbb058c020a9bd8ec6fb606eb550ac073c68341a7191a9bb2345e17
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 19, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.3.0 This release

2 release files

1.2.4

2 release files

1.2.3

2 release files

1.2.2

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.35.2

2 release files

0.35.0

2 release files

0.34.0

2 release files

0.33.2

2 release files

0.32.2

2 release files

0.32.1

2 release files

0.31.2

2 release files

0.30.3

2 release files

0.30.2

2 release files

0.30.0

2 release files

0.29.0

2 release files

0.28.0

1 release file

0.27.1

1 release file

0.27.0

1 release file

0.26.3

1 release file

0.26.2

1 release file

0.26.1

1 release file

0.26.0

1 release file

0.25.2

1 release file

0.25.1

1 release file

0.25.0

1 release file

0.24.0

1 release file

0.23.0

1 release file

0.22.1

1 release file

0.22.0

1 release file

0.21.3

1 release file

0.21.2

1 release file

0.21.1

1 release file

0.21.0

1 release file

0.20.1

1 release file

0.20.0

1 release file

0.19.3

1 release file

0.19.2

1 release file

0.19.1

1 release file

0.19.0

1 release file

0.18.1

1 release file

0.18.0

1 release file

0.17.1

1 release file

0.17.0

1 release file

0.16.1

1 release file

0.16.0

1 release file

0.15.0

1 release file

0.14.1

1 release file

0.14.0

1 release file

0.13.2

1 release file

0.13.1

1 release file

0.13.0

1 release file

0.12.0

1 release file

0.11.0

1 release file

0.10.0

1 release file

0.9.0

1 release file

0.8.0

1 release file

0.7.1

1 release file

0.7.0

1 release file

0.6.2

1 release file

0.6.1

1 release file

0.6.0

1 release file

0.5.0

1 release file

0.4.2

1 release file

0.4.1

1 release file

0.4.0

1 release file

0.3.3

1 release file

0.3.2

1 release file

0.3.1

1 release file

0.3

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page