Skip to main content

Python for Power Systems Analysis

Project description

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 sectionsin 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.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pypsa-1.2.0.tar.gz (13.0 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pypsa-1.2.0-py3-none-any.whl (358.3 kB view details)

Uploaded Python 3

File details

Details for the file pypsa-1.2.0.tar.gz.

File metadata

  • Download URL: pypsa-1.2.0.tar.gz
  • Upload date:
  • Size: 13.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pypsa-1.2.0.tar.gz
Algorithm Hash digest
SHA256 36c71ac19c9d1a379a671fbf333bde1a714ca742767fa168b40edbdfe3a1b8b1
MD5 c12fd2af77b6cf55d750e932a011f573
BLAKE2b-256 1d40bd7be1b98e2a094bd9b96793d94291d241059fb5ea77c6c446993c0c0360

See more details on using hashes here.

Provenance

The following attestation bundles were made for pypsa-1.2.0.tar.gz:

Publisher: release.yml on PyPSA/PyPSA

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pypsa-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: pypsa-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 358.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pypsa-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 76e1fdd459b8328edd0edc34a7e08350b4f1ccc2d002492d144238bc64ca481c
MD5 c96ef0481aaad32752bd3094d6a9c5ea
BLAKE2b-256 e9630b45d680612131fa26f1fd3766774d7c95766537db5cc86dbbd96c07f01b

See more details on using hashes here.

Provenance

The following attestation bundles were made for pypsa-1.2.0-py3-none-any.whl:

Publisher: release.yml on PyPSA/PyPSA

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page