From ec4e9aa548fce44109d851bf6f33070395d10787 Mon Sep 17 00:00:00 2001 From: JulianGeis Date: Wed, 17 Jan 2024 11:23:29 +0100 Subject: [PATCH 1/5] wasserstoff kernnetz --- scripts/prepare_sector_network.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index b57b832c..ba3f24c6 100755 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -1324,6 +1324,18 @@ def add_storage_and_grids(n, costs): n, "H2 pipeline ", carriers=["DC", "gas pipeline"] ) + h2_pipes["p_nom"] = 0. + + if snakemake.input.get("custom_h2_pipelines"): + fn = snakemake.input.custom_h2_pipelines + wkn = pd.read_csv(fn, index_col=0) + + h2_pipes = pd.concat([h2_pipes, wkn]) + + # drop duplicates according to buses (order can be different) and keep pipe with highest p_nom + h2_pipes['buses_sorted'] = h2_pipes.apply(lambda row: tuple(sorted([row['bus0'], row['bus1']])), axis=1) + h2_pipes = h2_pipes.sort_values('p_nom').drop_duplicates(subset=['buses_sorted'], keep='last').drop(columns = 'buses_sorted') + # TODO Add efficiency losses n.madd( "Link", @@ -1332,6 +1344,7 @@ def add_storage_and_grids(n, costs): bus1=h2_pipes.bus1.values + " H2", p_min_pu=-1, p_nom_extendable=True, + p_nom_min=h2_pipes.p_nom.values, length=h2_pipes.length.values, capital_cost=costs.at["H2 (g) pipeline", "fixed"] * h2_pipes.length.values, carrier="H2 pipeline", From 446b0b37227111e49fa3e4e566b68b031f558e28 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 17 Jan 2024 10:36:13 +0000 Subject: [PATCH 2/5] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- scripts/build_transport_demand.py | 10 +++++----- scripts/prepare_sector_network.py | 12 +++++++++--- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/scripts/build_transport_demand.py b/scripts/build_transport_demand.py index be8ad414..33c8faae 100644 --- a/scripts/build_transport_demand.py +++ b/scripts/build_transport_demand.py @@ -13,9 +13,7 @@ import logging import numpy as np import pandas as pd import xarray as xr - -from _helpers import configure_logging -from _helpers import generate_periodic_profiles +from _helpers import configure_logging, generate_periodic_profiles logger = logging.getLogger(__name__) @@ -137,8 +135,10 @@ def bev_availability_profile(fn, snapshots, nodes, options): ) if not avail[avail < 0].empty: - logger.warning("The BEV availability weekly profile has negative values which can " - "lead to infeasibility.") + logger.warning( + "The BEV availability weekly profile has negative values which can " + "lead to infeasibility." + ) return generate_periodic_profiles( dt_index=snapshots, diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index ba3f24c6..8bb9089b 100755 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -1324,7 +1324,7 @@ def add_storage_and_grids(n, costs): n, "H2 pipeline ", carriers=["DC", "gas pipeline"] ) - h2_pipes["p_nom"] = 0. + h2_pipes["p_nom"] = 0.0 if snakemake.input.get("custom_h2_pipelines"): fn = snakemake.input.custom_h2_pipelines @@ -1333,8 +1333,14 @@ def add_storage_and_grids(n, costs): h2_pipes = pd.concat([h2_pipes, wkn]) # drop duplicates according to buses (order can be different) and keep pipe with highest p_nom - h2_pipes['buses_sorted'] = h2_pipes.apply(lambda row: tuple(sorted([row['bus0'], row['bus1']])), axis=1) - h2_pipes = h2_pipes.sort_values('p_nom').drop_duplicates(subset=['buses_sorted'], keep='last').drop(columns = 'buses_sorted') + h2_pipes["buses_sorted"] = h2_pipes.apply( + lambda row: tuple(sorted([row["bus0"], row["bus1"]])), axis=1 + ) + h2_pipes = ( + h2_pipes.sort_values("p_nom") + .drop_duplicates(subset=["buses_sorted"], keep="last") + .drop(columns="buses_sorted") + ) # TODO Add efficiency losses n.madd( From 88ba4af9ad4ee9d874416c3c4ddd69aa62730a27 Mon Sep 17 00:00:00 2001 From: Julian Geis Date: Fri, 19 Jan 2024 09:56:52 +0100 Subject: [PATCH 3/5] Update scripts/prepare_sector_network.py Co-authored-by: Fabian Neumann --- scripts/prepare_sector_network.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index 8bb9089b..8648a4ce 100755 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -1326,7 +1326,7 @@ def add_storage_and_grids(n, costs): h2_pipes["p_nom"] = 0.0 - if snakemake.input.get("custom_h2_pipelines"): + if "custom_h2_pipelines" in snakemake.input: fn = snakemake.input.custom_h2_pipelines wkn = pd.read_csv(fn, index_col=0) From 9c56c1e929d8bd27c8d6ac10d45dbc4d7716f4f4 Mon Sep 17 00:00:00 2001 From: Julian Geis Date: Fri, 19 Jan 2024 09:57:26 +0100 Subject: [PATCH 4/5] Update scripts/prepare_sector_network.py Co-authored-by: Fabian Neumann --- scripts/prepare_sector_network.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index 8648a4ce..292814b2 100755 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -1328,9 +1328,9 @@ def add_storage_and_grids(n, costs): if "custom_h2_pipelines" in snakemake.input: fn = snakemake.input.custom_h2_pipelines - wkn = pd.read_csv(fn, index_col=0) + custom_pipes = pd.read_csv(fn, index_col=0) - h2_pipes = pd.concat([h2_pipes, wkn]) + h2_pipes = pd.concat([h2_pipes, custom_pipes]) # drop duplicates according to buses (order can be different) and keep pipe with highest p_nom h2_pipes["buses_sorted"] = h2_pipes.apply( From 128e1afc0072ddb21d01ce58137e3823f81f7c4e Mon Sep 17 00:00:00 2001 From: Julian Geis Date: Fri, 19 Jan 2024 10:01:11 +0100 Subject: [PATCH 5/5] Update scripts/prepare_sector_network.py Co-authored-by: Fabian Neumann --- scripts/prepare_sector_network.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index 292814b2..4c47b91a 100755 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -1333,9 +1333,7 @@ def add_storage_and_grids(n, costs): h2_pipes = pd.concat([h2_pipes, custom_pipes]) # drop duplicates according to buses (order can be different) and keep pipe with highest p_nom - h2_pipes["buses_sorted"] = h2_pipes.apply( - lambda row: tuple(sorted([row["bus0"], row["bus1"]])), axis=1 - ) + h2_pipes["buses_sorted"] = h2_pipes[["bus0", "bus1"]].apply(sorted, axis=1) h2_pipes = ( h2_pipes.sort_values("p_nom") .drop_duplicates(subset=["buses_sorted"], keep="last")