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
¶
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.
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.
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
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.
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
¶
add_carrier_buses(n, carrier, nodes=None)
¶
Add buses to connect e.g. coal, nuclear and oil plants.
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.
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
add_co2(n, costs, co2_network)
¶
add carbon carrier, it's networks and storage units
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)
¶
function to add the conversion technologies between H2 and hydrocarbons
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.
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.
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.
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