Skip to content

Composing and Solving Networks

One rule assembles the network for each planning horizon from the clustered electricity network and the prepared sector data, and one rule solves it. Both run the same way for electricity-only and sector-coupled studies and for all foresight modes; the foresight mode decides which inputs the composition step needs. Dispatch-only analyses on an already solved network fix the expanded capacities and re-solve operation, optionally in a rolling horizon.

Temporal aggregation

time_aggregation

Computes snapshot weightings for the time aggregation of the sector-coupled network.

Script, inputs, outputs and settings

Defines the time aggregation to be used for sector-coupled network.

Computes a time aggregation scheme for the given network, in the form of a CSV file with the snapshot weightings, indexed by the new subset of snapshots. This rule only computes said aggregation scheme; aggregation of time-varying network data is done in prepare_sector_network.py.

Composing

compose_network

Assembles the full network by adding electricity and sector components to the clustered grid.

Script, inputs, outputs and settings

Compose the network for one planning horizon from the electricity and sector-coupling building blocks.

Starting from the clustered base network, the script adds the electricity components (add_electricity), the sector-coupling components if enabled (prepare_sector_network), applies temporal aggregation and the final preparation for solving (prepare_network), and then handles the planning horizon according to the foresight mode. In the first horizon of a myopic or perfect foresight run, existing capacities are added (add_existing_baseyear). In later myopic horizons, the optimised capacities of the previous horizon's solved network are carried over as brownfield (add_brownfield). Under perfect foresight, the horizon is stacked onto the previous composed network to form a multi-period network (prepare_perfect_foresight). Finally, CO2 budget constraints and configured adjustments to costs and potentials are applied and the network is exported for solving.

Solving

solve_network

Optimises investment and dispatch for one planning horizon to minimise total system cost.

Script, inputs, outputs and settings

Solves optimal operation and capacity for a network with the option to iteratively optimize while updating line reactances.

This script is used for optimizing the electrical network as well as the sector coupled network.

Total annual system costs are minimised with PyPSA. The full formulation of the linear optimal power flow (plus investment planning) is provided in the documentation of PyPSA.

The optimization is based on the network.optimize function. Additionally, some extra constraints specified in solve_network are added.

solve_operations_network

Re-optimises dispatch only, holding the capacities from the solved network fixed.

Script, inputs, outputs and settings

Solves linear optimal dispatch in hourly resolution using the capacities of a previous capacity expansion in rule solve_network.

Loads networks/solved_{horizon}.nc, fixes the optimal capacities, and re-solves dispatch only (optionally with rolling horizon). Note that load_shedding is incompatible with operational solving, as its components already exist in the solved network.

Library modules

These modules are not rules of their own. Their functions are imported and called by compose_network in the order the foresight mode requires.

add_electricity

Add electricity components to the clustered network: load, existing conventional and hydro power plants, renewable generators and extendable storage.

Load time series are attached from the clustered electricity demand. Power plants from build_powerplants are aggregated per bus and carrier (optionally by efficiency class) and attached as conventional generators with fuel costs, efficiencies and emissions from the cost assumptions; hydro plants become run-of-river generators, reservoir and pumped hydro storage units with inflow from build_hydro_profile. Wind and solar generators are added with the profiles from build_renewable_profiles and zero existing capacity, unless existing capacities are estimated from IRENASTAT or powerplantmatching. Transmission costs of lines and links are set from the cost assumptions. Carriers in electricity.extendable_carriers are added with zero initial capacity. Storage is either a StorageUnit whose energy-to-power ratio is fixed by electricity.max_hours (one investment variable) or a Store on an extra bus with separate charging and discharging links (three investment variables).

Called from compose_network

This module has no Snakemake rule of its own. Its main function is called by compose_network.

prepare_network

Prepare the composed network for solving with emission constraints, transmission limits and temporal aggregation.

The functions add global CO2 emission limits or a CO2 budget across planning horizons, a gas consumption limit, a static or monthly varying price per tonne of CO2, a limit on the cost or volume of transmission expansion relative to today's grid, caps on line and link capacities and their extension, and an N-1 security margin on line capacities. Temporal aggregation either uses every n-th snapshot as representative or averages the hourly data onto the snapshot weightings precomputed by time_aggregation. Configured adjustments to costs and potentials per planning horizon are applied as well.

Called from compose_network

This module has no Snakemake rule of its own. Its functions are called by compose_network.

prepare_sector_network

Add the sector-coupling components to the network: demand and supply technologies for buildings, transport, industry, agriculture, shipping and aviation, plus the carrier infrastructure connecting them.

Starting from the electricity network, the script adds carrier buses, CO2 tracking and conventional generation, then the sectors enabled in the configuration: land transport, heating, biomass, ammonia, methanol, industry, shipping, aviation, waste heat and agriculture. Optional infrastructure follows: hydrogen and gas networks, direct air capture, a CO2 network, Allam cycle gas turbines, electricity and gas distribution grids, enhanced geothermal and energy imports. Demands come from the population-weighted energy and heat totals and the industrial demand per node; technology costs come from the cost assumptions of the planning horizon.

Called from compose_network

This module has no Snakemake rule of its own. Its main function is called by compose_network.

add_existing_baseyear

Add existing power and heating capacities to the network for the first planning horizon.

Conventional power plants from the powerplantmatching database and historic renewable capacities from IRENA statistics are binned into installation-year groups and added as non-extendable assets with build year and remaining lifetime, so that they retire over the planning horizons. Renewable capacities per country are distributed across generators in proportion to their technical potential, and a share of solar capacity can be assigned to rooftop PV. For heating, the existing capacities of heat pumps, resistive heaters and gas, oil and biomass boilers per region are spread over the grouping years assuming a constant installation rate in the past and added as links with the efficiencies of the respective heat system. Capacities below a threshold are dropped and new assets receive the base year as build year. Used under myopic and perfect foresight.

add_brownfield

Carry optimised capacities from the previous planning horizon into the current network under myopic foresight.

Transmission lines and DC links receive the previous optimum as lower bound. Generators, links and stores from the previous solved network are copied over with fixed capacities, dropping assets that reach the end of their lifetime before the current horizon or fall below a capacity threshold, while assets newly built in the current horizon are tagged with their build year. Renewable availability profiles are switched to the technology vintage closest to the current horizon, heat pump efficiencies and dynamic pit storage capacities of earlier vintages are updated to the current values, and the gas pipeline capacity still available for hydrogen retrofitting is reduced by what was already retrofitted. Transmission expansion is disabled once its global limit is reached, and renewable potentials are reduced by the existing capacities.

prepare_perfect_foresight

Build a multi-period network for perfect foresight optimisation by stacking planning horizons.

The composed network of the current horizon is converted into an investment period and, for all but the first horizon, concatenated with the multi-period network of the previous horizons: snapshots are extended by the new period, new components are added and attributes that change between horizons become period-dependent time series. Investment periods are weighted by their duration in years and discounted with a social discount rate. Store cycling is adjusted so that most stores cycle within each period while CO2, biomass and EV battery stores accumulate over the whole horizon. Existing gas boilers receive a hydrogen retrofit option and national phase-out rules cap asset lifetimes. Perfect foresight is experimental and not thoroughly tested.