Back to rankings

PyPSA/PyPSA

Pythondocs.pypsa.org

PyPSA: Python for Power System Analysis

pythonloadflowoptimisationenergy-systempower-systems-analysisoptimal-power-flowpowerflowenergyenergy-systemspower-flowpower-systemsrenewable-energy
Star Growth
Stars
2.1k
Forks
673
Weekly Growth
Issues
113
1k2k
Feb 2016Jul 2019Jan 2023Jul 2026
ArtifactsPyPIpip install pypsa
README
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.

Related repositories
donnemartin/system-design-primer

Learn how to design large-scale systems. Prep for the system design interview. Includes Anki flashcards.

PythonPyPIOtherprogrammingdevelopment
358.8k57.3k
vinta/awesome-python

An opinionated list of Python frameworks, libraries, tools, and resources

PythonPyPIOtherawesomepython
awesome-python.com
309.8k28.4k
practical-tutorials/project-based-learning

Curated list of project-based tutorials

PythonPyPIMIT Licensetutorialproject
274.8k35.4k
TheAlgorithms/Python

All Algorithms implemented in Python

PythonPyPIMIT Licensepythonalgorithm
thealgorithms.github.io/Python/
223k50.9k
tensorflow/tensorflow

An Open Source Machine Learning Framework for Everyone

C++Apache License 2.0tensorflowmachine-learning
tensorflow.org
196.5k75.7k
Significant-Gravitas/AutoGPT

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

PythonPyPIOtheraiopenai
agpt.co
185.6k46.1k
CyC2018/CS-Notes

:books: 技术面试必备基础知识、Leetcode、计算机操作系统、计算机网络、系统设计

algorithmleetcode
cyc2018.xyz
184.9k50.8k
yt-dlp/yt-dlp

A feature-rich command-line audio/video downloader

PythonPyPIThe Unlicenseyoutube-dlpython
discord.gg/H5MNcFW63r
179.6k15.3k
521xueweihan/HelloGitHub

:octocat: 分享 GitHub 上有趣、入门级的开源项目。Share interesting, entry-level open source projects on GitHub.

PythonPyPIgithubhellogithub
hellogithub.com
166.7k12.4k
huggingface/transformers

🤗 Transformers: the model-definition framework for state-of-the-art machine learning models in text, vision, audio, and multimodal models, for both inference and training.

PythonPyPIApache License 2.0nlpnatural-language-processing
huggingface.co/transformers
162.8k34k
langgenius/dify

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

TypeScriptnpmOtheraigpt
dify.ai
149.8k23.6k
langchain-ai/langchain

The agent engineering platform.

PythonPyPIMIT Licenseaianthropic
docs.langchain.com/langchain/
142.4k23.7k