Python for Power System Analysis: Examples
These examples demonstrate PyPSA using Jupyter notebooks. To
download the notebook files directly, replace the example file ending
For some of the examples you may have to download data from the
examples folder in the PyPSA github
- Minimal example of power flow - This script performs a non-linear power flow for a three-node network.
- Minimal example of linear optimal power flow - This script performs a linear optimal power flow for a three-node network.
- Transformer example - Minimal example of transformer with non-trivial phase shift and tap ratio.
- SciGrid German network
- Linear OPF then non-linear PF on the SciGRID German network - This script performs a linear optimal power flow on the SciGRID network for Germany for a full day and then examines the results. A full non-linear power flow is then performed on the network with the optimised dispatch.
- SciGRID example above with interactive plotting - This example uses the interactive plotting from the plotly library.
- Security-constrained LOPF on the SciGRID German network - This script performs a security-constrained linear optimal power flow on the SciGRID network for Germany, taking into account several possible branch outages.
- Attaching load, generation, transformers and missing lines to the SciGRID German network - This script attaches load, conventional generation data and wind and solar data, transformers and missing lines to the SciGRID network for Germany. It then exports the resulting network for use in the script above. Only a single day's worth of data is in the PyPSA github repository; a full year (2011) of load and wind/solar data can be downloaded here.
- Meshed AC-DC network - This example demonstrates multiply-connected AC-DC meshed networks with an example of 3 separate synchronous AC areas connected by a 3-node DC network.
- Generator Unit Commitment Examples - This tutorial runs through examples of unit commitment for generators at a single bus. Examples of minimum part-load, minimum up time, minimum down time, start up costs, shut down costs and ramp rate restrictions are shown.
- Simple Electricity Market Examples - This tutorial gradually builds up more and more complicated energy-only electricity markets in PyPSA, starting from a single bidding zone, going up to multiple bidding zones connected with transmission (NTCs) along with variable renewables and storage.
- Generation Investment Screening Curve - This examples looks at the long-term equilibrium of generation investment for a given load profile and compares it to a screening curve analysis.
- Coupling to Other Energy Sectors
- Linear optimal power flow with coupling to the heating sector - In this example three locations are optimised, each with an electric bus and a heating bus and corresponding loads. At each location the electric and heating buses are connected with heat pumps; heat can also be supplied to the heat bus with a boiler. The electric buses are connected with transmission lines and there are electrical generators at two of the nodes.
- Power-to-Gas with Gas Boiler and Combined-Heat-and-Power unit
- Demonstration of Link with multiple outputs: Combined-Heat-and-Power (CHP) with fixed heat-power ratio
- Power-to-Heat with Water Tank
- Transport: Charging Battery Electric Vehicle with Solar Panel
- Chained Hydroelectric Reservoirs
- Biomass, synthetic fuels and carbon management
- Replacing Generators and Storage Units with Fundamental Stores and Links - This notebook demonstrates how generators and storage units can be replaced by more fundamental components (Stores and Links), and how their parameters map to each other.
- Logging - How to control the level of logging that PyPSA reports back, e.g. error/warning/info/debug messages.
- PyPSA-Eur: An Open Optimisation Model of the European Transmission System
- PyPSA-ZA: PyPSA Model of the South African Energy System
- Sector-Coupled European Dataset - Full dataset and code from Synergies of sector coupling and transmission extension in a cost-optimised, highly renewable European energy system, Energy, Volume 160, Pages 720-739, 2018, postprint arXiv:1801.05290, DOI: 10.1016/j.energy.2018.06.222.
- European One-Node-Per-Country Dataset - Full dataset and code from The Benefits of Cooperation in a Highly Renewable European Electricity Network, Energy, Volume 134, 1 September 2017, Pages 469-481, preprint.
- WHOBS: Optimal Wind+Hydrogen+Other+Battery+Solar (WHOBS) electricity systems for European countries
- open-Ego project - The project open-eGo aims to develop a transparent, inter-grid-level operating grid planning tool to investigate economic viable grid expansion scenarios considering alternative flexibility options such as storages or redispatch. It uses PyPSA.
If you have a nice example of using PyPSA, send your Jupyter notebook to Tom Brown (firstname.lastname@example.org).