Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions rules/solve_myopic.smk
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
34 changes: 34 additions & 0 deletions scripts/add_brownfield.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Whether to TYNDP H2 topology is used
Whether TYNDP H2 topology is used

"""
logger.info(f"Preparing brownfield for the year {year}")

Expand Down Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# adjust TYNDP H2 pipeline expansion by subtracting existing capacity from previous years from current year total capacity and potential
# 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
Comment on lines +118 to +123
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably too restrictive, given that the maximum capacity of the electrolysers is also specified in the Investment Datasets/TRAJECTORY.xlsx file.


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
Comment on lines +133 to +142
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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
# values should be non-negative; clipping applied to handle rounding errors
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
)

n.links.loc[h2_pipelines, ["p_nom_min", "p_nom"]] = remaining_capacity
Comment on lines +127 to +143
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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
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()
.reindex(index=h2_pipelines, fill_value=0)
)
# this should anyway never be negative. We will still clip to account for rounding errors
remaining_capacity = (h2_pipe_capacity - existing_capacity_p).clip(lower=0)
remaining_potential = (h2_pipe_potential - existing_capacity_p).clip(lower=0)
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
Expand Down Expand Up @@ -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)
Expand Down
Loading