Sector-Coupling¶
Scripts for sector-coupling features including heat, transport, industry, and hydrogen.
Energy Totals¶
build_base_energy_totals
¶
prepare_energy_totals
¶
get(item, investment_year=None)
¶
Check whether item depends on investment year.
build_base_industry_totals
¶
Created on Thu Jul 14 19:01:13 2022.
@author: user
build_industry_demand
¶
Created on Thu Jul 14 21:18:06 2022.
@author: user
Heat¶
build_heat_demand
¶
Build heat demand time series.
build_existing_heating_distribution
¶
Builds table of existing heat generation capacities for initial planning horizon.
Existing heat generation capacities are distributed to nodes based on population. Within the nodes, the capacities are distributed to sectors (residential and services) based on sectoral consumption and urban/rural based population distribution.
Inputs:¶
- Existing heating generators:
data/existing_heating_raw.csvper country - Population layout:
resources/{run_name}/pop_layout_s<simpl>_<clusters>.csv. Output ofscripts/build_clustered_population_layout.py - Population layout with energy demands:
resources/<run_name>/pop_weighted_energy_totals_s<simpl>_<clusters>.csv - District heating share:
resources/<run_name>/district_heat_share_elec_s<simpl>_<clusters>_<planning_horizons>.csv
Outputs:¶
- Existing heat generation capacities distributed to nodes:
resources/{run_name}/existing_heating_distribution_elec_s{simpl}_{clusters}_{planning_horizons}.csv
Relevant settings:¶
.. code:: yaml scenario: planning_horizons sector: existing_capacities:
Notes:¶
- Data for Albania, Montenegro and Macedonia is not included in input database and assumed 0.
- Coal and oil boilers are assimilated to oil boilers.
- All ground-source heat pumps are assumed in rural areas and all air-source heat pumps are assumed to be in urban areas.
References:¶
- "Mapping and analyses of the current and future (2020 - 2030) heating/cooling fuel deployment (fossil/renewables)" (https://energy.ec.europa.eu/publications/mapping-and-analyses-current-and-future-2020-2030-heatingcooling-fuel-deployment-fossilrenewables-1_en)
prepare_heat_data
¶
Prepare heating-sector time series and summary tables used by the PyPSA-Earth workflow.
Relevant Settings¶
None
Inputs¶
networks/{RDIR}/elec_s{simpl}_{clusters}.nc: Clustered PyPSA networkresources/{SECDIR}/energy_totals_{demand}_{planning_horizons}.csv: Energy totals for each sectorresources/{SECDIR}/population_shares/pop_layout_elec_s{simpl}_{clusteres}_{planning_horizons}.csv: Population shares indexed by noderesources/{SECDIR}/temperatures/temp_air_total_elec_s{simpl}_{clusters}_{planning_horizons}.nc: Hourly air temperature times seriesresources/{SECDIR}/cops/cop_soil_total_elec_s{simpl}_{clusters}_{planning_horizons}.nc: Ground/soil source heat pump COP time series aligned to the network snapshots.resources/{SECDIR}/cops/cop_air_total_elec_s{simpl}_{clusters}_{planning_horizons}.nc: Air source heat pump COP time series aligned to the network snapshots.resources/{SECDIR}/demand/heat/solar_thermal_total_elec_s{simpl}_{clusters}_{planning_horizons}.nc: Solar thermal irradiance or generation used to generate solar thermal time series per node.resources/{SECDIR}/demand/heat/heat_demand_total_elec_s{simpl}_{clusters}_{planning_horizons}.nc: Daily average heat demand per nodedata/heat_load_profile_BDEW.csv: Representative weekday/weekend heat load profiles by sector and use from BDEW
Outputs¶
resources/{SECDIR}/demand/heat/nodal_energy_heat_totals_{demand}_s{simpl}_{clusters}_{planning_horizons}.csv: per node annual energy totals CSVresources/{SECDIR}/demand/heat/heat_demand_{demand}_s{simpl}_{clusters}_{planning_horizons}.csv: hourly heat demand time seriesresources/{SECDIR}/demand/heat/ashp_cop_{demand}_s{simpl}_{clusters}_{planning_horizons}.csv: air source heat pump COP time series CSVresources/{SECDIR}/demand/heat/gshp_cop_{demand}_s{simpl}_{clusters}_{planning_horizons}.csv: ground source heat pump COP time series CSVresources/{SECDIR}/demand/heat/solar_thermal_{demand}_s{simpl}_{clusters}_{planning_horizons}.csv: Solar thermal demand time series CSVresources/{SECDIR}/demand/heat/district_heat_share_{demand}_s{simpl}_{clusters}_{planning_horizons}.csv: per node district heat share CSV
Description¶
This module builds nodal heating energy totals, hourly heat demand time series, coefficient of performance (COP) profiles for air-source and ground-source heat pumps, solar thermal time series and the district heating share per node.
generate_periodic_profiles(dt_index, nodes, weekly_profile, localize=None)
¶
Create per node hourly profiles from a 7-day (168 hour) template.
The provided weekly_profile is a list or sequence of 168 hourly values
(24 * 7). For each node the function converts the provided UTC-aware
dt_index to the node's local timezone and maps each timestamp to the corresponding hour in the
weekly profile. The resulting DataFrame is indexed by dt_index and has
a column per node containing the hourly profile values localized for that node.
Parameters¶
dt_index : pd.DatetimeIndex Time index for the target period (should be timezone-aware in UTC). nodes : list[str] Iterable of node identifiers where the first two characters are an ISO2 country code used to determine the node timezone. weekly_profile : list Iterable of 168 hourly values representing a typical week (24 * 7 hours). localize : str, optional Optional timezone string to localize the final DataFrame to
Returns¶
pd.DataFrame
DataFrame indexed by dt_index with one column per node containing
the localized hourly profile values.
prepare_heat_data(n)
¶
Prepare heating sector inputs for a PyPSA network.
Parameters¶
n : pypsa.Network
The PyPSA Network object whose snapshots and other metadata are
used to align time series and perform reindexing.
Returns¶
tuple A tuple with the following elements in order: nodal_energy_totals: pd.DataFrame per-node annual energy totals heat_demand: pd.DataFrame hourly heat demand time series ashp_cop: pd.DataFrame air-source heat pump COP time series gshp_cop: pd.DataFrame ground-source heat pump COP time series solar_thermal:pd.DataFrame solar thermal generation time series district_heat_share: float per-node fraction of heat served by district heat
build_temperature_profiles
¶
Build temperature profiles.
build_cop_profiles
¶
Build COP time series for air- or ground-sourced heat pumps.
coefficient_of_performance(delta_T, source='air')
¶
COP is function of temp difference source to sink.
The quadratic regression is based on Staffell et al. (2012) https://doi.org/10.1039/C2EE22653G.
build_solar_thermal_profiles
¶
Build solar thermal collector time series.
Transport¶
prepare_transport_data
¶
transport_degree_factor(temperature, deadband_lower=15, deadband_upper=20, lower_degree_factor=0.5, upper_degree_factor=1.6)
¶
Work out how much energy demand in vehicles increases due to heating and cooling.
There is a deadband where there is no increase. Degree factors are % increase in demand compared to no heating/cooling fuel consumption. Returns per unit increase in demand for each place and time
generate_periodic_profiles(dt_index, nodes, weekly_profile, localize=None)
¶
Give a 24*7 long list of weekly hourly profiles, generate this for each country for the period dt_index, taking account of time zones and summer time.
prepare_transport_data(n)
¶
Function to prepare the data required for the (land) transport sector.
prepare_airports
¶
prepare_ports
¶
download_ports()
¶
Downloads the world ports index csv File and NOT as shape or other because it is updated on a monthly basis.
The following csv file was downloaded from the webpage https://msi.nga.mil/Publications/WPI as a csv file that is updated monthly as mentioned on the webpage. The dataset contains 3711 ports.
filter_ports(dataframe)
¶
Filters ports based on their harbor size and returns a DataFrame containing only the largest port for each country.
build_ship_profile
¶
Gas & Hydrogen¶
prepare_gas_network
¶
Prepare gas network.
Relevant Settings¶
sector:
gas:
spatial_gas:
network:
network_data:
network_data_GGIT_status:
cluster_options:
alternative_clustering:
custom_data:
gas_network:
Inputs¶
resources/{RDIR}/bus_regions/regions_onshore_elec_s{simpl}_{clusters}.geojson: path to onshore region polygons used to assign pipelines to regions.
Outputs¶
resources/{SECDIR}/gas_networks/gas_network_elec_s{simpl}_{clusters}.csv: CSV containing aggregated pipeline capacities and lengths between onshore regions.
Description¶
Utilities to download, load and cluster global natural gas pipeline datasets
for use with PyPSA-Earth. This module supports two source datasets:
GGIT and IGGIELGN. It provides helpers to normalise pipeline diameters and
capacities, clean geometry, assign pipelines to onshore regions, and aggregate
inter-state pipeline capacities.
download_IGGIELGN_gas_network()
¶
Downloads a global dataset for gas networks as .xlsx.
The following xlsx file was downloaded from the webpage https://globalenergymonitor.org/projects/global-gas-infrastructure-tracker/ The dataset contains 3144 pipelines.
download_GGIT_gas_network()
¶
Downloads a global dataset for gas networks as .xlsx.
The following xlsx file was downloaded from the webpage https://globalenergymonitor.org/projects/global-gas-infrastructure-tracker/ The dataset contains 3144 pipelines.
diameter_to_capacity(pipe_diameter_mm)
¶
Calculate pipe capacity in MW based on diameter in mm.
20 inch (500 mm) 50 bar -> 1.5 GW CH4 pipe capacity (LHV) 24 inch (600 mm) 50 bar -> 5 GW CH4 pipe capacity (LHV) 36 inch (900 mm) 50 bar -> 11.25 GW CH4 pipe capacity (LHV) 48 inch (1200 mm) 80 bar -> 21.7 GW CH4 pipe capacity (LHV)
Based on p.15 of https://gasforclimate2050.eu/wp-content/uploads/2020/07/2020_European-Hydrogen-Backbone_Report.pdf
Parameters¶
pipe_diameter_mm: int Diameter of gas pipeline in mm
Returns¶
int Pipe capacity in MW
inch_to_mm(len_inch)
¶
bcm_to_MW(cap_bcm)
¶
correct_Diameter_col(value)
¶
Parse and average compound pipeline diameter values.
Handles diameter strings containing commas, slashes or dashes by splitting the string into numeric parts and returning the mean.
prepare_GGIT_data(GGIT_gas_pipeline)
¶
load_IGGIELGN_data(fn)
¶
prepare_IGGIELGN_data(df, length_factor=1.5, correction_threshold_length=4, correction_threshold_p_nom=8, bidirectional_below=10)
¶
Process IGGIELGN pipeline data and infer missing attributes.
Parameters¶
df : geopandas.GeoDataFrame Raw IGGIELGN pipeline GeoDataFrame. length_factor : float, optional Multiplier applied to haversine-based distances when correcting reported line lengths. correction_threshold_length : float, optional Threshold ratio for when the reported length is replaced by the haversine-based length. correction_threshold_p_nom : float, optional Threshold ratio for when reported capacity is corrected using diameter-based capacity estimates. bidirectional_below : float, optional Line length (km) below which pipelines are assumed bidirectional.
Returns¶
geopandas.GeoDataFrame Cleaned pipeline GeoDataFrame with normalized capacity, length, and bidirectionality attributes.
load_bus_region(onshore_path, pipelines)
¶
Load pypsa-earth-sec onshore regions.
TODO: Think about including Offshore regions but only for states that have offshore pipelines. Parameters
onshore_path: str Path to the onshore regions shapefile. pipelines: gpd.GeoDataFrame GeoDataFrame of the pipeline data.
Returns:
bus_regions_onshore: gpd.GeoDataFrame
GeoDataFrame of onshore bus regions with a gadm_id column.
country_borders: gpd.GeoDataFrame
Merged onshore region geodataframe.
get_states_in_order(pipeline, bus_regions_onshore)
¶
Determine the ordered onshore regions traversed by a pipeline.
Parameters¶
pipeline : shapely.geometry.LineString or MultiLineString
Pipeline geometry to sample along its route.
bus_regions_onshore : geopandas.GeoDataFrame
Onshore region geometries with a gadm_id column.
Returns¶
list[str]
Ordered list of gadm_id values for the regions intersected by the
pipeline geometry.
parse_states(pipelines, bus_regions_onshore)
¶
Parse which onshore regions each pipeline traverses.
Parameters¶
pipelines : geopandas.GeoDataFrame
Pipeline geometries with a geometry column.
bus_regions_onshore : geopandas.GeoDataFrame
Onshore regions with a gadm_id column.
Returns¶
geopandas.GeoDataFrame
Input pipeline GeoDataFrame augmented with states_passed,
amount_states_passed, and nodes columns.
cluster_gas_network(pipelines, bus_regions_onshore, length_factor)
¶
Aggregate interstate gas pipelines to bus-region clusters.
This function drops purely intrastatal pipelines, splits interstate pipelines by region overlay, aggregates capacity by region pairs, and computes a representative line length and GWkm metric.
Parameters¶
pipelines : geopandas.GeoDataFrame
Pipeline GeoDataFrame with states_passed and amount_states_passed.
bus_regions_onshore : geopandas.GeoDataFrame
Onshore region geometries used for overlay.
length_factor : float
Multiplier applied to the haversine distance between region centroids
to estimate pipeline length.
Returns¶
pandas.DataFrame
Aggregated pipeline table with columns bus0, bus1, capacity,
length, and GWKm.
add_export
¶
Proposed code structure: X read network (.nc-file) X add export bus X connect hydrogen buses (advanced: only ports, not all) to export bus X add store and connect to export bus X (add load and connect to export bus) only required if the "store" option fails
Possible improvements: - Select port buses automatically (with both voronoi and gadm clustering). Use data/ports.csv?
Sector Network¶
prepare_sector_network
¶
Adds sector based technologies to the PyPSA network
Relevant Settings¶
sector:
enable:
heat:
biomass:
industry:
shipping:
aviation:
land_transport:
rail_transport:
agriculture:
residential:
services:
gas:
spatial_gas:
network:
network_data:
network_data_GGIT_status:
hydrogen:
network:
H2_retrofit_capacity_per_CH4:
network_limit:
network_routes:
gas_network_repurposing:
underground_storage:
hydrogen_colors:
set_color_shares:
blue_share:
pink_share:
production_technologies:
coal:
spatial_coal:
shift_to_elec:
lignite:
spatial_lignite:
oil:
spatial_oil:
ammonia:
enable:
spatial_ammonia:
production_year:
gas_MWh_per_tNH3:
elec_MWh_per_tNH3:
co2_t_per_tNH3:
# ------------------- HEAT SECTOR -------------------
district_heating:
potential:
progress:
district_heating_loss:
reduce_space_heat_exogenously:
reduce_space_heat_exogenously_factor:
space_heat_share:
tes:
tes_tau:
decentral:
central:
boilers:
oil_boilers:
chp:
micro_chp:
solar_thermal:
heat_pump_sink_T:
time_dep_hp_cop:
solar_cf_correction:
# ------------------- LAND TRANSPORT SECTOR -------------------
bev_plug_to_wheel_efficiency:
bev_charge_efficiency:
transport_heating_deadband_upper:
transport_heating_deadband_lower:
ICE_lower_degree_factor:
ICE_upper_degree_factor:
EV_lower_degree_factor:
EV_upper_degree_factor:
bev_avail_max:
bev_avail_mean:
bev_dsm_restriction_value:
bev_dsm_restriction_time:
v2g:
bev_dsm:
bev_energy:
bev_availability:
transport_fuel_cell_efficiency:
transport_internal_combustion_efficiency:
land_transport_fuel_cell_share:
land_transport_electric_share:
dynamic_transport
enable:
land_transport_fuel_cell_share
land_transport_electric_share
# ------------------- BIOMASS SECTOR -------------------
biomass_transport:
biomass_transport_default_cost:
solid_biomass_potential:
biogas_potential:
# ------------------- ELECTRICITY DISTRIBUTION GRID -------------------
electricity_distribution_grid:
enable_electricity_connection_cost:
solar_rooftop:
enable:
kW_per_m2:
m2_per_person:
use_building_size:
tolerance:
home_battery:
transmission_efficiency
electricity distribution grid
efficiency_static:
H2 pipeline
efficiency_per_1000km:
compression_per_1000km:
# ------------------- SHIPPING & AVIATION SECTOR -------------------
shipping_hydrogen_liquefaction:
shipping_average_efficiency:
shipping_hydrogen_share:
airport_sizing_factor:
international_bunkers:
# ------------------- CCUS & CONVERSION OPTIONS -------------------
co2_network:
co2_sequestration_potential:
co2_sequestration_cost:
methanation:
helmeth:
dac:
cc_fraction:
cc:
fischer_tropsch:
min_part_load_fischer_tropsch:
# ------------------- INDUSTRY OPTIONS -------------------
industry_util_factor:
efficiency_heat_oil_to_elec:
efficiency_heat_biomass_to_elec:
efficiency_heat_gas_to_elec:
# ------------------- POWERPLANTS OPTIONS -------------------
conventional_generation:
keep_existing_capacities:
marginal_cost_storage:
Inputs¶
resources/{SECDIR}/demand/transport_{demand}_s{simpl}_{clusters}_{planning_horizons}.csv: Transport demand per node and carrier for transport sectors (road, rail, aviation, shipping) if enabled.resources/{SECDIR}/pattern_profiles/avail_profile_{demand}_s{simpl}_{clusters}_{planning_horizons}.csv: Availability profiles for the transport sector if enabled.resources/{SECDIR}/pattern_profiles/dsm_profile_{demand}_s{simpl}_{clusters}_{planning_horizons}.csv: Demand-side management profiles for the transport sector if enabled.-
resources/{SECDIR}/demand/nodal_transport_data_{demand}_s{simpl}_{clusters}_{planning_horizons}.csv: Nodal transport demand data for transport sectors if enabled. -
resources/{SECDIR}/demand/heat/heat_demand_{demand}_s{simpl}_{clusters}_{planning_horizons}_{demand}.csv: Heat demand per node for heat sector if enabled. resources/{SECDIR}/demand/heat/ashp_cop_{demand}_s{simpl}_{clusters}_{planning_horizons}.csv: Coefficient of performance for air source heat pumps for heat sector if enabled.resources/{SECDIR}/demand/heat/gshp_cop_{demand}_s{simpl}_{clusters}_{planning_horizons}.csv: Coefficient of performance for ground source heat pumps for heat sector if enabled.resources/{SECDIR}/demand/heat/solar_thermal_{demand}_s{simpl}_{clusters}_{planning_horizons}.csv: Solar thermal availability profiles for heat sector if enabled.-
resources/{SECDIR}/demand/heat/district_heat_share_{demand}_s{simpl}_{clusters}_{planning_horizons}.csv: District heat share per node for heat sector if enabled. -
resources/{RDIR}/solar_rooftop/solar_rooftop_layout_elec_s{simpl}_{clusters}_{country}.csv: Solar rooftop layout per country if enabled. -
networks/{RDIR}/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}.nc: PyPSA network file for electricity sector. -
resources/{RDIR}/costs_{planning_horizons}_sec.csv: Cost parameters for sector technologies. -
data/hydrogen_salt_cavern_potentials.csv: Hydrogen salt cavern potentials per country. -
resources/{SECDIR}/demand/heat/nodal_energy_heat_totals_{demand}_s{simpl}_{clusters}_{planning_horizons}.csv: Nodal energy totals if rail transport or agriculture sector is enabled. -
resources/{SECDIR}/population_shares/pop_layout_elec_s{simpl}_{clusters}_{planning_horizons}.csv: Population layout per node. -
resources/{SECDIR}/demand/industrial_energy_demand_per_node_elec_s{simpl}_{clusters}_{planning_horizons}_{demand}.csv: Industrial energy demand per node if industry sector is enabled. -
resources/{SECDIR}/energy_totals_{demand}_{planning_horizons}.csv: Energy totals per sector -
resources/{SECDIR}/airports.csv: Airport locations if aviation sector is enabled. -
resources/{SECDIR}/ports.csv: Port locations if shipping sector is enabled. -
data/temp_hard_coded/biomass_transport_costs.csv: Biomass transport costs if biomass sector is enabled. -
resources/{RDIR}/bus_regions/regions_onshore_elec_s{simpl}_{clusters}.geojson: GeoJSON file containing onshore regions. -
resources/{SECDIR}/gas_network/gas_network_elec_s{simpl}_{clusters}.csv: Gas network data if gas sector is enabled.
Outputs¶
{RESDIR}/prenetworks/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}_{sopts}_{planning_horizons}_{discountrate}_{demand}.nc: Prepared network file after adding sectoral technologies,
Description¶
Add sector based technologies to the PyPSA network, including: - Carrier buses for fossil fuels (coal, oil, gas) and nuclear. - Electricity grid connection costs for solar and wind generators. - Hydrogen as an energy carrier, including production technologies, storage options, and a potential hydrogen network. - Battery storage and other storage technologies if enabled. - Rail transport technologies (e.g. electric and diesel trains) if the rail transport sector is enabled. - Land transport technologies (e.g. electric vehicles) if the land transport sectors are enabled. - Shipping and aviation sectors if enabled - Heat sector technologies (e.g. heat pumps, solar thermal) if the heat sector is enabled. - Industrial sector technologies if the industry sector is enabled. - Agriculture sector technologies if the agriculture sector is enabled. - Biomass supply chain technologies if biomass is used in any sector. - CO2 storage and direct air capture technologies if carbon capture or negative emissions are enabled.
add_carrier_buses(n, carrier, nodes=None)
¶
Add buses to connect e.g. coal, nuclear and oil plants.
Parameters¶
n: PyPSA Network Network to which the carrier and buses will be added. carrier: str Name of the carrier to be added (e.g. 'coal', 'nuclear', 'oil'). nodes: list or pd.Index, optional List of nodes to which the carrier buses will be added. If None, uses all nodes from spatial data for the given carrier.
add_electricity_grid_connection(n, costs)
¶
H2_liquid_fossil_conversions(n, costs)
¶
Function to add conversions between H2 and liquid fossil Carrier and bus is added in add_oil, which later on might be switched to add_generation.
Parameters¶
n: PyPSA Network Network to which the conversions will be added. costs: pd.DataFrame DataFrame containing the cost and efficiency parameters for the conversions.
Returns¶
None
add_hydrogen(n, costs)
¶
Function to add hydrogen as an energy carrier with its conversion technologies from and to AC.
Parameters¶
n : pypsa.Network The PyPSA network to which hydrogen components will be added. costs : pd.DataFrame DataFrame containing the cost and efficiency parameters for hydrogen technologies.
Returns¶
None
define_spatial(nodes, options)
¶
Namespace for spatial.
Parameters¶
nodes : list List of nodes in the model. options: dict Dictionary containing the options for spatially resolved carriers and technologies.
Returns¶
spatial : SimpleNamespace Namespace containing the spatial attributes for the model, including nodes and spatially resolved carriers and technologies.
add_biomass(n, costs)
¶
add_co2(n, costs, co2_network)
¶
Add carbon carrier, its networks and storage units
Parameters¶
n : pypsa.Network The PyPSA network to which the carbon carrier, its networks and storage units will be added. costs : pd.DataFrame DataFrame containing the costs for the carbon carrier, its networks and storage units. co2_network : bool Whether to add CO2 network components.
Returns¶
None
add_aviation(n, costs, energy_totals, airports_fn)
¶
Add aviation demand and emissions to the sector network.
Parameters¶
n : pypsa.Network The PyPSA network to which aviation demand and emissions will be added. costs : pd.DataFrame DataFrame containing the costs for aviation technologies. energy_totals : pd.DataFrame DataFrame containing energy total values for different sectors. airports_fn : str File path to the airports data file.
Returns¶
None
add_storage(n, costs)
¶
Function to add battery storage to the sector network, including carry-over of existing capacities from the electricity network.
This function performs the following steps: 1. Retrieves existing battery storage units from the electricity network, if available. 2. Removes existing battery storage units and stores from the electricity network to avoid double counting. 3. Adds a new "battery" carrier to the network. 4. Adds new battery storage units and corresponding charger/discharger links for each node in the spatial network, using the existing capacities as a starting point. 5. Configures the new battery storage units to be extendable for future capacity additions
Parameters¶
n : pypsa.Network The PyPSA network to which battery storage will be added. costs : pd.DataFrame A DataFrame containing cost parameters for the battery storage technologies.
Returns¶
None
h2_hc_conversions(n, costs)
¶
add_shipping(n, costs, energy_totals, ports_fn)
¶
Add shipping technologies to the sector model
Parameters¶
n: pypsa.Network PyPSA Network to which the shipping technologies will be added costs: pd.DataFrame DataFrame containing the costs for the shipping technologies energy_totals: pd.DataFrame DataFrame containing energy total values for different sectors ports_fn: str File path to the ports data file
Returns¶
None
add_industry(n, costs, industrial_demand_fn)
¶
Add industrial technologies and industrial demands to the sector network
Parameters¶
n: pypsa.Network PyPSA Network to which industrial demands will be added costs: pd.DataFrame DataFrame containing the costs for industrial technologies industrial_demand_fn: str File path to the industrial demand data file
Returns¶
None
add_ammonia(n, costs, industrial_demand_fn)
¶
Add conventional Haber-Bosch ammonia production and demand to the network.
Parameters¶
n : pypsa.Network The PyPSA network to which ammonia production and demand will be added. costs : pd.DataFrame DataFrame containing cost information for ammonia production technologies. industrial_demand_fn : str Path to the industrial demand CSV file. Must contain an 'ammonia' column in MWh/year, indexed by spatial nodes.
Returns¶
None
get(item, investment_year=None)
¶
Check whether item depends on investment year.
add_land_transport(n, costs, transport_fn, avail_profile_fn, dsm_profile_fn, nodal_transport_data_fn)
¶
Function to add land transport to network.
Parameters¶
n: pypsa.Network The PyPSA network to which land transport will be added. costs: pd.DataFrame DataFrame containing cost information for land transport technologies. transport_fn: str File path to the transport demand data file. avail_profile_fn: str File path to the availability profile data file for electric vehicles. dsm_profile_fn: str File path to the demand-side management profile data file for electric vehicles. nodal_transport_data_fn: str File path to the nodal transport data file containing information such as the number of cars.
Returns¶
None
create_nodes_for_heat_sector(district_heat_share)
¶
Create nodes for the heat sector based on population layout and district heating share.
Parameters¶
district_heat_share : pd.DataFrame DataFrame containing the share of district heating at each node.
Returns¶
h_nodes : dict Dictionary containing the nodes for each heat sector. dist_fraction_node : pd.Series Series containing the district heating share at each node. urban_fraction : pd.Series Series containing the urban fraction at each node.
add_heat(n, costs, heat_demand_fn, solar_thermal_fn, gshp_cop_fn, ashp_cop_fn, district_heat_share_fn)
¶
Add heat sector to the network
Parameters¶
n: pypsa.Network The PyPSA network to which the heat sector will be added. costs: pd.DataFrame DataFrame containing cost information for heat sector technologies. heat_demand_fn: str File path to the heat demand data file. solar_thermal_fn: str File path to the solar thermal availability profiles data file. gshp_cop_fn: str File path to the ground-sourced heat pump coefficient of performance data file. ashp_cop_fn: str File path to the air-sourced heat pump coefficient of performance data file. district_heat_share_fn: str File path to the district heating share data file.
Returns¶
None
average_every_nhours(n, offset)
¶
Resample the network to a lower temporal resolution by averaging every n hours.
Parameters¶
n : pypsa.Network The PyPSA network to be resampled. offset : str The offset string representing the new temporal resolution (e.g., '2H' for 2 hours).
Returns¶
pypsa.Network A new PyPSA network resampled to the specified temporal resolution.
add_dac(n, costs)
¶
add_services(n, costs, energy_totals)
¶
Add services sector to the network.
Parameters¶
n : pypsa.Network PyPSA network to which the services sector will be added. costs : pd.DataFrame DataFrame containing cost information for services sector technologies. energy_totals : pd.DataFrame DataFrame containing energy total information for the services sector.
Returns¶
None
add_agriculture(n, costs, nodal_energy_totals_fn)
¶
Add agriculture to the pypsa network.
Parameters¶
n: pypsa.Network The PyPSA network to which agriculture technologies will be added costs: pd.DataFrame DataFrame containing cost information for agriculture technologies nodal_energy_totals_fn: str File path to the nodal energy totals data file
Returns¶
None
normalize_by_country(df, droplevel=False)
¶
Auxiliary function to normalize a dataframe by the country.
If droplevel is False (default), the country level is added to the column index If droplevel is True, the original column format is preserved
group_by_node(df, multiindex=False)
¶
Auxiliary function to group a dataframe by the node name.
normalize_and_group(df, multiindex=False)
¶
Function to concatenate normalize_by_country and group_by_node.
p_set_from_scaling(col, scaling, energy_totals, nhours)
¶
Function to create p_set from energy_totals, using the per-unit scaling dataframe.
add_residential(n, costs, energy_totals)
¶
Add residential sector to the network
Parameters¶
n: pypsa.Network The PyPSA Network to which the residential sector will be added costs: pd.DataFrame DataFrame containing cost information for residential sector technologies energy_totals: pd.DataFrame DataFrame containing energy total information for the residential sector
Returns¶
None
add_electricity_distribution_grid(n, costs)
¶
add_co2_budget(n, co2, investment_year, elec_opts=None)
¶
Add CO2 budget constraint to the network based on the specified co2_budget parameters.
Parameters¶
n: pypsa.Network The PyPSA network to which the CO2 budget constraint will be added. co2: dict Dictionary containing CO2 budget parameters investment_year: int The year for which the CO2 budget constraint is being added elec_opts: dict Dictionary containing electricity options, used if co2base_value is 'co2limit' or 'co2base'
Returns¶
None
add_custom_water_cost(n)
¶
add_rail_transport(n, costs, nodal_energy_totals_fn)
¶
Add rail transport sector to the network based on nodal energy totals for rail transport.
Parameters¶
n: pypsa.Network The PyPSA network to which the rail transport sector will be added. costs: pd.DataFrame DataFrame containing cost information for rail transport technologies. nodal_energy_totals_fn: str File path to the nodal energy totals data file for rail transport.
Returns¶
None
convert_conventional_generators_to_links(n, costs)
¶
Convert conventional generators from electricity network to Link components in sector network, preserving existing capacities, efficiencies, build_year, lifetime, and extendability.
The function: 1. Extracts existing generator data 2. Removes original generators and their carriers (to avoid name collision) 3. Adds fuel carrier buses (gas, coal, oil, etc.) 4. Adds generators as Links
Parameters¶
n : pypsa.Network The PyPSA network object to modify. costs : pd.DataFrame DataFrame containing cost data.
Returns¶
None
remove_carrier_related_components(n, carriers_to_drop)
¶
add_brownfield
¶
Prepares brownfield data from previous planning horizon.
Relevant Settings¶
sector:
hydrogen:
network:
H2_retrofit_capacity_per_CH4:
network_limit:
network_routes:
gas_network_repurposing:
underground_storage:
hydrogen_colors:
set_color_shares:
blue_share:
pink_share:
production_technologies:
existing_capacities
grouping_years_power:
grouping_years_heat:
threshold_capacity:
default_heating_lifetime:
conventional_carriers:
snapshots:
start:
end:
inclusive:
electricity:
renewable_carriers:
resources/{RDIR}/bus_regions/busmap_elec_s{simpl}.csv: Busmap after simplifying the networkresources/{RDIR}/bus_regions/busmap_elec_s{simpl}_{clusters}.csv: Busmap after clustering the network{RESDIR}/prenetworks/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}_{sopts}_{planning_horizons}_{discountrate}_{demand}_{h2export}export.nc: prenetwork file obtained prior to solvingsolved_previous_horizon: Network solved at previous time stepresources/{RDIR}/costs_{planning_horizons}_sec.csv: Technology costs dataresources/{SECDIR}/cops/cop_soil_total_elec_s{simpl}_{clusters}_{planning_horizons}.nc: Ground/soil source heat pump COP time series aligned to the network snapshotsresources/{SECDIR}/cops/cop_air_total_elec_s{simpl}_{clusters}_{planning_horizons}.nc: Air source heat pump COP time series aligned to the network snapshots
Output¶
{RESDIR}/prenetworks-brownfield/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sopts}_{planning_horizons}_{discountrate}_{demand}_{h2export}export.nc: Brownfield prenetwork file
Description¶
To prepare network for brownfield expansion
add_brownfield(n, n_p, year)
¶
Adds brownfield assets from the previous planning horizon to the network.
Parameters¶
n : pypsa.Network The new PyPSA network to which brownfield assets will be added. n_p : pypsa.Network The previous PyPSA network from which brownfield assets will be sourced. year : int The planning horizon year for which brownfield assets are being prepared.
Returns¶
None
disable_grid_expansion_if_limit_hit(n)
¶
Check if transmission expansion limit is already reached; then turn off.
In particular, this function checks if the total transmission capital cost or volume implied by s_nom_min and p_nom_min are numerically close to the respective global limit set in n.global_constraints. If so, the nominal capacities are set to the minimum and extendable is turned off; the corresponding global constraint is then dropped.
Parameters¶
n : pypsa.Network The PyPSA network to check and adjust for transmission expansion limits.
Returns¶
None
add_existing_baseyear
¶
Adds existing power and heat generation capacities for initial planning horizon.
add_build_year_to_new_assets(n, baseyear)
¶
add_heating_capacities_installed_before_baseyear(n, baseyear, grouping_years, ashp_cop, gshp_cop, time_dep_hp_cop, costs, default_lifetime)
¶
Parameters¶
n : pypsa.Network baseyear : last year covered in the existing capacities database grouping_years : intervals to group existing capacities linear decommissioning of heating capacities from 2020 to 2045 is currently assumed heating capacities split between residential and services proportional to heating load in both 50% capacities in rural busess 50% in urban buses