diff --git a/rules/solve_myopic.smk b/rules/solve_myopic.smk index 87379b08b6..503a9ce01f 100644 --- a/rules/solve_myopic.smk +++ b/rules/solve_myopic.smk @@ -71,6 +71,7 @@ rule add_brownfield: "sector", "H2_retrofit_capacity_per_CH4" ), threshold_capacity=config_provider("existing_capacities", "threshold_capacity"), + h2_topology_tyndp=config_provider("sector", "h2_topology_tyndp"), snapshots=config_provider("snapshots"), drop_leap_day=config_provider("enable", "drop_leap_day"), carriers=config_provider("electricity", "renewable_carriers"), diff --git a/scripts/add_brownfield.py b/scripts/add_brownfield.py index 1e92d6558c..17cf545e61 100644 --- a/scripts/add_brownfield.py +++ b/scripts/add_brownfield.py @@ -33,6 +33,7 @@ def add_brownfield( h2_retrofit=False, h2_retrofit_capacity_per_ch4=None, capacity_threshold=None, + h2_topology_tyndp=False, ): """ Add brownfield capacity from previous network. @@ -51,6 +52,8 @@ def add_brownfield( Ratio of hydrogen to methane capacity for pipeline retrofitting capacity_threshold : float Threshold for removing assets with low capacity + h2_topology_tyndp : bool + Whether to TYNDP H2 topology is used """ logger.info(f"Preparing brownfield for the year {year}") @@ -110,6 +113,36 @@ def add_brownfield( for tattr in n.component_attrs[c.name].index[selection]: n.import_series_from_dataframe(c.pnl[tattr], c.name, tattr) + # adjust TYNDP H2 pipeline expansion by subtracting existing capacity from previous years from current year total capacity and potential + if h2_topology_tyndp: + h2_pipelines_fixed_i = n.links[ + (n.links.carrier == "H2 pipeline") & (n.links.build_year != year) + ].index + h2_pipelines = n.links[ + (n.links.carrier == "H2 pipeline") & (n.links.build_year == year) + ].index + + h2_pipe_capacity = n.links.loc[h2_pipelines, "p_nom"] + h2_pipe_potential = n.links.loc[h2_pipelines, "p_nom_max"] + existing_capacity_p = ( + n.links.loc[h2_pipelines_fixed_i, "p_nom_opt"] + .rename(lambda x: x.split("-2")[0] + f"-{year}") + .groupby(level=0) + .sum() + ) + remaining_capacity = ( + h2_pipe_capacity + - existing_capacity_p.reindex(index=h2_pipe_capacity.index).fillna(0) + ).clip(lower=0) + remaining_potential = ( + h2_pipe_potential + - existing_capacity_p.reindex(index=h2_pipe_capacity.index).fillna(0) + ).clip( + lower=0 + ) # this should anyway never be negative. We will still clip to account for rounding errors + n.links.loc[h2_pipelines, ["p_nom_min", "p_nom"]] = remaining_capacity + n.links.loc[h2_pipelines, "p_nom_max"] = remaining_potential + # deal with gas network if h2_retrofit: # subtract the already retrofitted from the maximum capacity @@ -367,6 +400,7 @@ def update_dynamic_ptes_capacity( h2_retrofit=snakemake.params.H2_retrofit, h2_retrofit_capacity_per_ch4=snakemake.params.H2_retrofit_capacity_per_CH4, capacity_threshold=snakemake.params.threshold_capacity, + h2_topology_tyndp=snakemake.params.h2_topology_tyndp, ) disable_grid_expansion_if_limit_hit(n)