---
title: 'PyPSA-Earth: Global Energy Optimization'
url: https://www.emergentmind.com/topics/pypsa-earth
type: topic
---

# PyPSA-Earth: Global Energy Optimization

PyPSA-Earth is a global, open-source energy system optimization model built on top of the PyPSA framework and derived from the European PyPSA-Eur model using new data and functions. It is designed to model the world energy system, or any subset of it, at high spatial and temporal resolution, and combines customizable data extraction and preparation scripts with direct integration into PyPSA’s modelling framework. In the form introduced in 2022, PyPSA-Earth focuses on the electricity sector, including electricity demand, generation, storage, and medium- to high-voltage networks from open sources, and it is suitable for operational studies as well as combined generation, storage, and transmission expansion studies [2209.04663][1707.09913].

## 1. Position within the PyPSA family

PyPSA, "Python for Power System Analysis", is a free Python toolbox for simulating and optimising modern electrical power systems over multiple periods. Its scope includes non-linear AC and DC power flow, linearised power flow for optimisation, linear optimal power flow, multi-period operation and investment optimisation, unit commitment, storage, mixed AC/DC networks, and sector coupling. PyPSA-Earth inherits this component-based and optimisation-centric architecture; almost everything it does at continental scale is an application and orchestration of the modelling concepts, equations, and software architecture laid out in PyPSA [1707.09913].

Within that family, PyPSA-Earth functions as the global extension of PyPSA-Eur. Its stated purpose is to provide a transparent, reproducible, community-maintained alternative to closed planning tools while avoiding two limitations that had constrained many open models: limited geographic scope and low spatial resolution or weak network representation. The model provides default data for all countries, allows the selection of any subset of countries, and can therefore be used for a single country, a regional power pool, a continent, or the entire world. The original paper characterises it as the first open-source global energy system model with data in high spatial and temporal resolution [2209.04663].

The initial sectoral scope is deliberately narrower than the full capability of the underlying PyPSA framework. PyPSA-Earth is presented as electricity-sector-only in its first major publication: generation, storage, transmission, and electricity demand are explicitly represented, whereas heat, transport, and industry are identified as future extensions. Even in that initial form, however, the model is already structured for operational dispatch, brownfield or greenfield capacity expansion, combined generation-storage-transmission expansion, and emissions-constrained planning [2209.04663].

## 2. Modelling formalism and software architecture

PyPSA represents an energy system as a `Network` containing component tables, typically implemented as pandas DataFrames. The principal components are buses, loads, generators, storage units or stores, lines, transformers, links, and carriers. Passive AC branches are modelled with an equivalent $\pi$ model, and PyPSA supports both full non-linear power flow and linearised formulations for optimisation. For large-scale planning, PyPSA adopts a linear active-power formulation with nodal balances, branch flow limits, and Kirchhoff’s Voltage Law, yielding an LP in the absence of unit commitment and other integer decisions [1707.09913].

PyPSA-Earth instantiates this architecture with globally sourced data. The workflow builds a PyPSA `Network`, adds buses from clustered nodes or fundamental shapes, adds lines and links from the OSM-derived network, maps existing generators and storage, attaches hourly demand and renewable availability time series, and then calls `network.lopf()` or an equivalent workflow stage to solve the resulting optimisation problem. In the formulation given for PyPSA-Earth, the objective is the minimisation of total annualized system cost:
$$
\min \; C =
\sum_{n,k} c^{\text{inv}}_{n,k} G_n^k
+ \sum_{n,s} \left(c^{\text{inv,P}}_{n,s} P_n^s + c^{\text{inv,E}}_{n,s} E_n^s \right)
+ \sum_{\ell} c^{\text{inv,line}}_{\ell} F_{\ell}
+ \sum_{n,k,t} c^{\text{var}}_{n,k} g_{n,t}^k \Delta t
+ \sum_{n,s,t} c^{\text{var,storage}}_{n,s} \text{(in/out)}_{n,t}^s \Delta t .
$$

The electrical core is a standard DC-load-flow-type representation. Nodal balance is imposed as
$$
\sum_{k} g_{n,t}^k
+ \sum_{s} \left( p^{\text{dis}}_{n,t,s} - p^{\text{ch}}_{n,t,s} \right)
+ \sum_{\ell \in \mathcal{L}^{\text{in}}(n)} f_{\ell,t}
- \sum_{\ell \in \mathcal{L}^{\text{out}}(n)} f_{\ell,t}
= d_{n,t},
$$
with generator limits
$$
0 \leq g_{n,t}^k \leq \bar{g}_{n,t}^k G_n^k,
$$
storage dynamics
$$
e_{n,t,s} = e_{n,t-1,s}(1-\lambda_s)
+ \eta^{\text{ch}}_s p^{\text{ch}}_{n,t,s}\Delta t
- \frac{1}{\eta^{\text{dis}}_s} p^{\text{dis}}_{n,t,s}\Delta t,
$$
and transmission flows
$$
f_{\ell,t} = B_{\ell}\left(\theta_{n,t}-\theta_{m,t}\right),
\qquad
-F_{\ell} \le f_{\ell,t} \le F_{\ell}.
$$
When a net-zero or other emissions-constrained study is performed, total emissions are bounded by
$$
\sum_{n,k,t} e_k \, g_{n,t}^k \Delta t \le \text{Budget}.
$$
This architecture is solver-agnostic at the PyPSA level, while PyPSA-Earth’s later workflow developments also make use of Linopy and related advances in LP model construction to improve scalability [2209.04663][1707.09913].

## 3. Data pipeline and global network construction

A defining characteristic of PyPSA-Earth is that it is not only an optimisation model but also a global data-production workflow. The pipeline is orchestrated with Snakemake and assembles model-ready datasets for shapes, grid topology, demand, renewable resources, generation assets, and costs. Major input sources include OpenStreetMap for transmission networks and substations, GADM for administrative boundaries, maritime boundaries and Exclusive Economic Zones for offshore assignment, the `synde` package with GlobalEnergyGIS for hourly demand forecasting, Atlite for renewable potentials and capacity-factor time series, ERA5 and SARAH-2 for meteorological and solar data, GEBCO for bathymetry, ProtectedPlanet and land-cover data for land-use exclusions, and powerplantmatching, extended with OSM generation data, for harmonised existing power plant inventories [2209.04663].

The demand workflow proceeds from country-level hourly demand time series to nodal demand allocation. Where GlobalEnergyGIS outputs are unavailable, PyPSA-Earth uses a heuristic that scales Nigeria’s profile by population and GDP. National hourly demand is then downscaled to model nodes proportionally to local population and local GDP. Renewable resource estimation is spatially explicit: Atlite constructs cutouts, eligible areas are derived after land-use and protected-area filtering, socio-technical power densities are applied to obtain maximum installable capacity, and node-level hourly availability factors are aggregated from raster cells. Hydro inflows are computed from runoff time series and then scaled to match national annual hydro production [2209.04663].

Network construction begins with OSM filtering by `power=*` tags, voltage levels, and frequency, the latter being used to distinguish HVDC from HVAC. Substations are supplemented by line-endpoint extraction where necessary; transformers and converters are inferred where lines of different voltages meet or where HVDC terminals connect. PyPSA-Earth also improves substation-line connectivity by merging any substation within a small distance tolerance of a transmission line of the same voltage and connecting them, a step intended to correct common OSM omissions of short underground links into substations [2209.04663].

A later European grid-data study is directly relevant to this pipeline because it describes its OSM workflow as an enhanced version of the data processing integrated in the PyPSA-Earth model. That workflow formalises retrieval through the Overpass API, cleaning of semicolon-separated voltage and circuit tags, graph construction by splitting lines at substation intersections, clustering buses within a configurable radius, heuristic addition of transformers and converters, and generation of PyPSA-ready CSV tables. The same paper states that, given the generic structure of the workflow, it can be easily applied to other regions and fed back to the global PyPSA-Earth project [2408.17178].

## 4. Spatial aggregation, clustering, and voltage representation

PyPSA-Earth explicitly addresses the standard trade-off between spatial detail and computational tractability through configurable network reduction. The model introduces "fundamental shapes" as the spatial basis for nodes. Onshore, these may be administrative zones derived from GADM or Voronoi cells around substations; offshore, Voronoi cells are clipped to EEZ boundaries and assigned to nearby onshore high-voltage nodes. These shapes provide the geometric support for assigning demand, renewable potentials, and network assets before further clustering [2209.04663].

Several clustering strategies are available. Resource- and demand-aware clustering incorporates similarity in demand profiles and renewable potential or capacity factors and is designed to preserve spatial diversity in VRE and demand. Grid-oriented clustering is based on impedance and connectivity, with the aim of preserving major corridors and electrical structure. Pure geographical clustering applies weighted k-means to node coordinates. Administrative clustering aggregates nodes falling inside the same administrative region. PyPSA-Earth also supports one- or two-stage reduction, where the first stage aggregates all nodal components and an optional second stage simplifies only the transmission graph while keeping finer renewable-resource resolution [2209.04663].

The workflow can further augment sparse or incomplete networks through k-edge augmentation. For a chosen $k$, the procedure ensures that each node has at least $k$ neighbours. If not, nearest neighbours are identified geographically, new lines are added using a minimum spanning tree criterion to minimise total added length, and those added lines are initialised at very small capacity so that they function as candidate investments rather than pre-imposed corridors. This mechanism is particularly relevant in regions where OSM under-represents existing connectivity [2209.04663].

A more recent methodological development addresses a structural limitation of coarse aggregation in PyPSA- and PyPSA-Earth-style models: conventional voltage-unaware aggregation collapses multiple voltage layers into a single pseudo-voltage layer and causes transformers to disappear as explicit investment objects. The proposed alternative is voltage-aware partitioning and aggregation, implemented in the Network Partitioning and Aggregation Package (NPAP). It clusters buses separately by voltage level, preserves transformers as inter-cluster connections, and can therefore retain voltage-specific line costs and transformer investment costs. In a European case study using PyPSA, the voltage-aware approach preserved about 70% of transformer expansion cost at moderate aggregation, whereas voltage-unaware aggregation preserved 0% because no transformers remained in the aggregated model. The same work states that PyPSA-Earth’s workflow is structurally similar to PyPSA-Eur and that NPAP can be inserted between dataset creation and PyPSA-Earth’s solving step to perform voltage-aware aggregation [2605.13205].

## 5. Validation and demonstrated applications

The principal validation study in the original PyPSA-Earth paper concerns Africa, with particular attention to grid length, electricity demand, renewable potentials, and installed generation capacities. For the African continent as a whole, OSM/PyPSA-Earth circuit length is reported as approximately 117% higher than the World Bank dataset, suggesting that the latter is incomplete at continental scale. For Nigeria, by contrast, OSM/PyPSA-Earth is about 35% shorter than official line-length reports, indicating under-reporting in OSM for that country. Demand validation shows that PyPSA-Earth’s 2030 African electricity consumption projection of about 1866 TWh/year lies close to independent estimates of 1877 TWh/year and 1924 TWh/year. The harmonised power plant database captures about 165 GW versus IRENA’s 229 GW for Africa, or roughly 72% of installed capacity, which the paper judges sufficient for macro-planning while also identifying gaps for recent thermal plants and some niche technologies [2209.04663].

The first detailed application is a 2020 dispatch validation for Nigeria. In that case, the OSM-derived network is clustered to 54 nodes, augmented so that each node has at least two connections, and solved as an hourly linear OPF with fixed existing capacities. PyPSA-Earth produces 29.5 TWh total generation, compared with 28.2 TWh reported by Our World in Data. The breakdown is 5.8 TWh hydro, 23.6 TWh gas, and 0.04 TWh solar, compared with 6.1 TWh hydro, 21.4 TWh gas, 0.6 TWh coal, and 0.04 TWh solar in the comparison dataset. The average marginal cost is about 59 €/MWh, which the paper states is consistent with a reported cost range of 45–70 €/MWh. The interpretation given is that PyPSA-Earth reproduces Nigeria’s 2020 generation mix realistically, with residual differences explained largely by slightly higher assumed demand and the absence of explicit coal plants in the open plant database [2209.04663].

The second application is a 2060 net-zero electricity planning study for Nigeria. Demand is raised to about 250 TWh, the network is augmented more aggressively so that each node has at least three AC neighbours, additional candidate HVDC lines are added between randomly selected node pairs more than 600 km apart, and solar, onshore wind, Li-ion batteries, hydrogen storage, and transmission are all allowed to expand. The resulting system is dominated by solar PV, reflecting Nigeria’s resource profile and projected 2050/2060 costs. Batteries provide the main balancing resource, with optimised energy-to-power ratios ranging from 4.6 to 15.1 hours and averaging about 7.4 hours. Hydrogen storage is available but not heavily used, which the paper attributes to limited seasonality in Nigeria’s equatorial solar profile and the absence of export or trade modelling. The optimal expansion is concentrated in new AC transmission routes, especially in the north and east, while candidate HVDC lines are not used significantly. Average marginal prices are about 51 €/MWh, lower than the 2020 value despite far higher demand and a net-zero constraint [2209.04663].

## 6. Reproducibility, limitations, and ongoing development

PyPSA-Earth is organised as an explicitly reproducible research workflow. The code is released under GPL 3.0, experiments are orchestrated with Snakemake, scenario logic is configured through YAML files, and the project is maintained through open repositories and community channels. This organisational design is tightly linked to the model’s scientific role: PyPSA-Earth is intended not merely as a static model instance but as a global workflow that can be reconfigured by country set, clustering level, weather year, technology assumptions, emissions constraints, and solver choice [2209.04663].

The limitations are equally explicit. Network quality depends on OSM completeness, which varies substantially by region; PyPSA-Earth itself notes under-representation of some national systems and the frequent absence of lower-voltage details or short substation links. Demand forecasts derived from GlobalEnergyGIS can perform worse in low-income countries, and generator databases can lag behind recent coal and gas plant additions. The initial model version covers electricity only, omits explicit reliability metrics such as LOLE unless added through custom constraints, relies on a DC power-flow approximation, and does not yet represent some technologies such as CSP, geothermal, wave, tidal, Redox Flow, CAES, LAES, or Dynamic Line Rating. Temporal representation is also limited in the initial publication to single-year studies rather than endogenous multi-period pathway optimisation [2209.04663].

Subsequent work in the broader PyPSA ecosystem addresses several of these limitations in ways that are directly relevant to PyPSA-Earth. The later OSM-grid paper strengthens the high-voltage data pipeline and explicitly frames it as a refinement of processing already integrated in PyPSA-Earth [2408.17178]. The voltage-aware aggregation paper addresses the loss of multi-voltage structure under coarse clustering and proposes an implementation path compatible with PyPSA-Earth workflows [2605.13205]. This suggests that PyPSA-Earth is best understood not as a fixed monolith but as a global modelling stack whose fidelity depends on the continual refinement of open data processing, aggregation methodology, and PyPSA-based optimisation practice.

Source: https://www.emergentmind.com/topics/pypsa-earth