From 54c2128419d7ad21f382e00f8cfed9436ed11d7b Mon Sep 17 00:00:00 2001 From: lisazeyen Date: Mon, 4 Dec 2023 10:47:41 +0100 Subject: [PATCH 1/7] add heat vent --- config/config.default.yaml | 2 ++ config/config.perfect.yaml | 3 ++- config/test/config.perfect.yaml | 3 ++- scripts/prepare_sector_network.py | 15 +++++++++++++-- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/config/config.default.yaml b/config/config.default.yaml index 81dda14a..5a588650 100644 --- a/config/config.default.yaml +++ b/config/config.default.yaml @@ -451,6 +451,7 @@ sector: coal_cc: false dac: true co2_vent: false + central_heat_vent: false allam_cycle: false hydrogen_fuel_cell: true hydrogen_turbine: false @@ -878,6 +879,7 @@ plotting: services rural heat: '#ff9c9c' central heat: '#cc1f1f' urban central heat: '#d15959' + urban central heat vent: '#a74747' decentral heat: '#750606' residential urban decentral heat: '#a33c3c' services urban decentral heat: '#cc1f1f' diff --git a/config/config.perfect.yaml b/config/config.perfect.yaml index f355763c..51a0bcb0 100644 --- a/config/config.perfect.yaml +++ b/config/config.perfect.yaml @@ -39,5 +39,6 @@ co2_budget: sector: - min_part_load_fischer_tropsch: 0 + central_heat_vent: true + # min_part_load_fischer_tropsch: 0 min_part_load_methanolisation: 0 diff --git a/config/test/config.perfect.yaml b/config/test/config.perfect.yaml index c99f4122..d00d11ec 100644 --- a/config/test/config.perfect.yaml +++ b/config/test/config.perfect.yaml @@ -42,7 +42,8 @@ electricity: renewable_carriers: [solar, onwind, offwind-ac, offwind-dc] sector: - min_part_load_fischer_tropsch: 0 + central_heat_vent: true + # min_part_load_fischer_tropsch: 0 min_part_load_methanolisation: 0 atlite: default_cutout: be-03-2013-era5 diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index ee72042f..648fe358 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -1692,7 +1692,19 @@ def add_heat(n, costs): carrier=name + " heat", unit="MWh_th", ) - + + if (name == "urban central") & (options["central_heat_vent"]): + n.madd( + "Generator", + nodes[name] + f" {name} heat vent", + location=nodes[name], + carrier=name + " heat vent", + p_nom_extendable=True, + p_max_pu=0, + p_min_pu=-1, + unit="MWh_th", + ) + ## Add heat load for sector in sectors: @@ -3290,7 +3302,6 @@ def set_temporal_aggregation(n, opts, solver_name): break return n - if __name__ == "__main__": if "snakemake" not in globals(): from _helpers import mock_snakemake From 71dbe2aaf27057faae8cbd4ef6a3bd5871ba13a3 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 4 Dec 2023 09:52:59 +0000 Subject: [PATCH 2/7] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- scripts/prepare_sector_network.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index 648fe358..af0c98ec 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -1692,7 +1692,7 @@ def add_heat(n, costs): carrier=name + " heat", unit="MWh_th", ) - + if (name == "urban central") & (options["central_heat_vent"]): n.madd( "Generator", @@ -1704,7 +1704,7 @@ def add_heat(n, costs): p_min_pu=-1, unit="MWh_th", ) - + ## Add heat load for sector in sectors: @@ -3302,6 +3302,7 @@ def set_temporal_aggregation(n, opts, solver_name): break return n + if __name__ == "__main__": if "snakemake" not in globals(): from _helpers import mock_snakemake From 53b9e23dd8a095a49c973125cd366d69096579d2 Mon Sep 17 00:00:00 2001 From: lisazeyen Date: Mon, 4 Dec 2023 12:18:03 +0100 Subject: [PATCH 3/7] fixes for new package versions --- scripts/make_summary_perfect.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/scripts/make_summary_perfect.py b/scripts/make_summary_perfect.py index 7ca4055d..81f57c67 100644 --- a/scripts/make_summary_perfect.py +++ b/scripts/make_summary_perfect.py @@ -28,6 +28,15 @@ idx = pd.IndexSlice opt_name = {"Store": "e", "Line": "s", "Transformer": "s"} +def reindex_columns(df, cols): + investments = cols.levels[3] + if len(cols.names)!=len(df.columns.levels): + df = pd.concat([df] * len(investments), axis=1) + df.columns = cols + df = df.reindex(cols, axis=1) + + return df + def calculate_costs(n, label, costs): investments = n.investment_periods cols = pd.MultiIndex.from_product( @@ -39,7 +48,8 @@ def calculate_costs(n, label, costs): ], names=costs.columns.names[:3] + ["year"], ) - costs = costs.reindex(cols, axis=1) + + costs = reindex_columns(costs, cols) for c in n.iterate_components( n.branch_components | n.controllable_one_port_components ^ {"Load"} @@ -176,7 +186,7 @@ def calculate_capacities(n, label, capacities): ], names=capacities.columns.names[:3] + ["year"], ) - capacities = capacities.reindex(cols, axis=1) + capacities = reindex_columns(capacities, cols) for c in n.iterate_components( n.branch_components | n.controllable_one_port_components ^ {"Load"} @@ -229,7 +239,7 @@ def calculate_energy(n, label, energy): ], names=energy.columns.names[:3] + ["year"], ) - energy = energy.reindex(cols, axis=1) + energy = reindex_columns(energy, cols) for c in n.iterate_components(n.one_port_components | n.branch_components): if c.name in n.one_port_components: @@ -336,7 +346,7 @@ def calculate_supply_energy(n, label, supply_energy): ], names=supply_energy.columns.names[:3] + ["year"], ) - supply_energy = supply_energy.reindex(cols, axis=1) + supply_energy = reindex_columns(supply_energy, cols) bus_carriers = n.buses.carrier.unique() @@ -604,7 +614,7 @@ def calculate_price_statistics(n, label, price_statistics): price_statistics.at["mean", label] = n.buses_t.marginal_price[buses].mean().mean() price_statistics.at["standard_deviation", label] = ( - n.buses_t.marginal_price[buses].droplevel(0).unstack().std() + n.buses_t.marginal_price[buses].std().std() ) return price_statistics From f3fcd43eef83da3b7beca700ac15a11a3d6ce8ab Mon Sep 17 00:00:00 2001 From: lisazeyen Date: Mon, 4 Dec 2023 12:18:15 +0100 Subject: [PATCH 4/7] clean up config --- config/config.perfect.yaml | 1 - config/test/config.myopic.yaml | 3 +++ config/test/config.perfect.yaml | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/config/config.perfect.yaml b/config/config.perfect.yaml index 51a0bcb0..a146cf25 100644 --- a/config/config.perfect.yaml +++ b/config/config.perfect.yaml @@ -40,5 +40,4 @@ co2_budget: sector: central_heat_vent: true - # min_part_load_fischer_tropsch: 0 min_part_load_methanolisation: 0 diff --git a/config/test/config.myopic.yaml b/config/test/config.myopic.yaml index 0bb85ec6..cc228fc2 100644 --- a/config/test/config.myopic.yaml +++ b/config/test/config.myopic.yaml @@ -29,6 +29,9 @@ countries: ['BE'] snapshots: start: "2013-03-01" end: "2013-03-08" + +sector: + central_heat_vent: true electricity: co2limit: 100.e+6 diff --git a/config/test/config.perfect.yaml b/config/test/config.perfect.yaml index d00d11ec..9fc51c5c 100644 --- a/config/test/config.perfect.yaml +++ b/config/test/config.perfect.yaml @@ -42,9 +42,9 @@ electricity: renewable_carriers: [solar, onwind, offwind-ac, offwind-dc] sector: - central_heat_vent: true - # min_part_load_fischer_tropsch: 0 + min_part_load_fischer_tropsch: 0 min_part_load_methanolisation: 0 + atlite: default_cutout: be-03-2013-era5 cutouts: From 92ccb517f3ecb8ceaf0a6a58c97d27ae055cd40a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 4 Dec 2023 11:20:38 +0000 Subject: [PATCH 5/7] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- config/test/config.myopic.yaml | 2 +- config/test/config.perfect.yaml | 2 +- scripts/make_summary_perfect.py | 9 +++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/config/test/config.myopic.yaml b/config/test/config.myopic.yaml index cc228fc2..d566c6cb 100644 --- a/config/test/config.myopic.yaml +++ b/config/test/config.myopic.yaml @@ -29,7 +29,7 @@ countries: ['BE'] snapshots: start: "2013-03-01" end: "2013-03-08" - + sector: central_heat_vent: true diff --git a/config/test/config.perfect.yaml b/config/test/config.perfect.yaml index 9fc51c5c..49886b26 100644 --- a/config/test/config.perfect.yaml +++ b/config/test/config.perfect.yaml @@ -44,7 +44,7 @@ electricity: sector: min_part_load_fischer_tropsch: 0 min_part_load_methanolisation: 0 - + atlite: default_cutout: be-03-2013-era5 cutouts: diff --git a/scripts/make_summary_perfect.py b/scripts/make_summary_perfect.py index 81f57c67..c387c6cf 100644 --- a/scripts/make_summary_perfect.py +++ b/scripts/make_summary_perfect.py @@ -30,13 +30,14 @@ opt_name = {"Store": "e", "Line": "s", "Transformer": "s"} def reindex_columns(df, cols): investments = cols.levels[3] - if len(cols.names)!=len(df.columns.levels): + if len(cols.names) != len(df.columns.levels): df = pd.concat([df] * len(investments), axis=1) - df.columns = cols + df.columns = cols df = df.reindex(cols, axis=1) - + return df + def calculate_costs(n, label, costs): investments = n.investment_periods cols = pd.MultiIndex.from_product( @@ -48,7 +49,7 @@ def calculate_costs(n, label, costs): ], names=costs.columns.names[:3] + ["year"], ) - + costs = reindex_columns(costs, cols) for c in n.iterate_components( From 7b24557bd31e8463b2ccabec21ad5c329b6cd9c5 Mon Sep 17 00:00:00 2001 From: lisazeyen Date: Mon, 4 Dec 2023 12:27:34 +0100 Subject: [PATCH 6/7] remove minimum part load again for perfect --- config/config.perfect.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/config.perfect.yaml b/config/config.perfect.yaml index a146cf25..f355763c 100644 --- a/config/config.perfect.yaml +++ b/config/config.perfect.yaml @@ -39,5 +39,5 @@ co2_budget: sector: - central_heat_vent: true + min_part_load_fischer_tropsch: 0 min_part_load_methanolisation: 0 From b8e72683cb129d54448acc951ab5d58fadb6e86d Mon Sep 17 00:00:00 2001 From: lisazeyen <35347358+lisazeyen@users.noreply.github.com> Date: Mon, 4 Dec 2023 12:28:54 +0100 Subject: [PATCH 7/7] improve style 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 af0c98ec..f585ad04 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -1693,7 +1693,7 @@ def add_heat(n, costs): unit="MWh_th", ) - if (name == "urban central") & (options["central_heat_vent"]): + if name == "urban central" and options.get("central_heat_vent"): n.madd( "Generator", nodes[name] + f" {name} heat vent",