From d78fcf7ab0815b12611551e41c5e27a0582a3615 Mon Sep 17 00:00:00 2001 From: Michael Lindner Date: Thu, 23 Jan 2025 10:31:04 +0100 Subject: [PATCH 01/20] restrict RES buildout --- config/config.yaml | 16 ++++++++-------- config/scenarios.manual.yaml | 4 ---- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/config/config.yaml b/config/config.yaml index 43c3e19a2..ae67e6b62 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -4,7 +4,7 @@ # docs in https://pypsa-eur.readthedocs.io/en/latest/configuration.html#run run: - prefix: 20241203-force-onwind-south + prefix: 20250123-restrict_res_buildout name: # - CurrentPolicies - KN2045_Bal_v4 @@ -436,8 +436,8 @@ solving: DE: 2020: 54.5 2025: 69 - 2030: 157 # EEG2023 Ziel für 2035 - 2035: 250 + 2030: 115 # EEG2023 Ziel für 2030 + 2035: 160 # EEG2023 Ziel für 2040 2040: 250 2045: 250 offwind: @@ -445,16 +445,16 @@ solving: 2020: 7.8 2025: 11.3 2030: 29.3 # uba Projektionsbericht and NEP without delayed BalWin 3 - 2035: 70 - 2040: 70 + 2035: 40 + 2040: 60 2045: 70 solar: DE: 2020: 53.7 2025: 110 # EEG2023; assumes for 2026: 128 GW, assuming a fair share reached by end of 2025 - 2030: 309 # EEG2023 Ziel für 2035 - 2035: 1000 - 2040: 1000 + 2030: 235 # PV Ziel 2030 + 20 GW + 2035: 400 + 2040: 800 2045: 1000 Store: co2 sequestered: diff --git a/config/scenarios.manual.yaml b/config/scenarios.manual.yaml index e568d7f0c..2831de9ee 100644 --- a/config/scenarios.manual.yaml +++ b/config/scenarios.manual.yaml @@ -58,8 +58,6 @@ CurrentPolicies: 2025: 11.3 2030: 17.3 # 12 less than NEP, because of 1 year delay 2035: 35 # 29.3 + a little extra - 2040: 70 - 2045: 70 onwind: DE: 2030: 94.5 # uba Projektionsbericht @@ -591,8 +589,6 @@ KN2045minus_WorstCase: 2025: 11.3 2030: 17.3 # 12 less than NEP, because of 1 year delay 2035: 35 # 29.3 + a little extra - 2040: 70 - 2045: 70 onwind: DE: 2030: 94.5 # uba Projektionsbericht From 14df88bca221f3f17513cd2dfaaac1ccc6efae7b Mon Sep 17 00:00:00 2001 From: Michael Lindner Date: Thu, 23 Jan 2025 10:36:56 +0100 Subject: [PATCH 02/20] decrease FT efficiency --- scripts/pypsa-de/modify_cost_data.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/pypsa-de/modify_cost_data.py b/scripts/pypsa-de/modify_cost_data.py index 22dbefe82..55c5fcda4 100644 --- a/scripts/pypsa-de/modify_cost_data.py +++ b/scripts/pypsa-de/modify_cost_data.py @@ -150,4 +150,9 @@ def carbon_component_fossils(costs, co2_price): f"Setting lifetime of central gas CHP to {costs.at[("central gas CHP" , "lifetime") , "value"]} {costs.at[("central gas CHP" , "lifetime") , "unit"]}." ) + # decrease Fischer-Tropsch efficiency + costs.at[("Fischer-Tropsch", "efficiency"), "value"] = 1 / costs.at[("Fischer-Tropsch", "hydrogen-input"), "value"] + + + costs.to_csv(snakemake.output[0]) From c978b43613282e547fb3dc985b1446dfe45fd6fe Mon Sep 17 00:00:00 2001 From: Michael Lindner Date: Thu, 23 Jan 2025 10:48:02 +0100 Subject: [PATCH 03/20] forbid net export of H2 and Efuels --- scripts/pypsa-de/additional_functionality.py | 24 ++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/scripts/pypsa-de/additional_functionality.py b/scripts/pypsa-de/additional_functionality.py index 38d8e017d..b36d8ef6a 100644 --- a/scripts/pypsa-de/additional_functionality.py +++ b/scripts/pypsa-de/additional_functionality.py @@ -208,6 +208,18 @@ def h2_import_limits(n, investment_year, limits_volume_max): carrier_attribute="", ) + logger.info("Adding H2 export ban") + + cname = f"H2_export_ban-{ct}" + + n.model.add_constraints(lhs >= 0, name=f"GlobalConstraint-{cname}") + + if cname in n.global_constraints.index: + logger.warning( + f"Global constraint {cname} already exists. Dropping and adding it again." + ) + n.global_constraints.drop(cname, inplace=True) + def h2_production_limits(n, investment_year, limits_volume_min, limits_volume_max): for ct in limits_volume_max["electrolysis"]: @@ -647,6 +659,18 @@ def add_h2_derivate_limit(n, investment_year, limits_volume_max): carrier_attribute="", ) + logger.info("Adding H2 derivate export ban") + + cname = f"H2_derivate_export_ban-{ct}" + + n.model.add_constraints(lhs >= 0, name=f"GlobalConstraint-{cname}") + + if cname in n.global_constraints.index: + logger.warning( + f"Global constraint {cname} already exists. Dropping and adding it again." + ) + n.global_constraints.drop(cname, inplace=True) + def adapt_nuclear_output(n): logger.info( From 35b4598159170a603d38d253cc20514abcf60c4e Mon Sep 17 00:00:00 2001 From: Michael Lindner Date: Thu, 23 Jan 2025 10:49:15 +0100 Subject: [PATCH 04/20] allow BEV DSM only after 2025 --- config/config.default.yaml | 2 +- scripts/prepare_sector_network.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/config.default.yaml b/config/config.default.yaml index c2ec2ce4f..51eb7088f 100644 --- a/config/config.default.yaml +++ b/config/config.default.yaml @@ -498,7 +498,7 @@ sector: ICE_upper_degree_factor: 1.6 EV_lower_degree_factor: 0.98 EV_upper_degree_factor: 0.63 - bev_dsm: true + bev_dsm_startyear: 2030 bev_availability: 0.5 bev_energy: 0.05 bev_charge_efficiency: 0.9 diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index 628acaac9..442a90ae2 100755 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -2029,7 +2029,7 @@ def add_EVs( efficiency=options["bev_charge_efficiency"], ) - if options["bev_dsm"]: + if options["bev_dsm_startyear"] <= investment_year: e_nom = ( number_cars * options["bev_energy"] From 1159f391b7e8b168714e2e8cb99a286b5255d3f7 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 23 Jan 2025 10:31:29 +0000 Subject: [PATCH 05/20] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- README.md | 2 +- scripts/pypsa-de/modify_cost_data.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index a2da05ca1..de06f833f 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ Before running any analysis with scenarios, the rule `build_scenarios` must be e snakemake -call build_scenarios -f or in case of using the public database - + snakemake -call build_scenarios --configfile=config/config.public.yaml -f Note that the hierarchy of scenario files is the following: `scenarios.automated.yaml` > (any `explicitly specified --configfiles`) > `config.yaml `> `config.default.yaml `Changes in the file `scenarios.manual.yaml `are only taken into account if the rule `build_scenarios` is executed. diff --git a/scripts/pypsa-de/modify_cost_data.py b/scripts/pypsa-de/modify_cost_data.py index 55c5fcda4..a6d352412 100644 --- a/scripts/pypsa-de/modify_cost_data.py +++ b/scripts/pypsa-de/modify_cost_data.py @@ -151,8 +151,8 @@ def carbon_component_fossils(costs, co2_price): ) # decrease Fischer-Tropsch efficiency - costs.at[("Fischer-Tropsch", "efficiency"), "value"] = 1 / costs.at[("Fischer-Tropsch", "hydrogen-input"), "value"] - - + costs.at[("Fischer-Tropsch", "efficiency"), "value"] = ( + 1 / costs.at[("Fischer-Tropsch", "hydrogen-input"), "value"] + ) costs.to_csv(snakemake.output[0]) From 9e590a94ac0927f20dfaba12a50e0b939ba7a462 Mon Sep 17 00:00:00 2001 From: Michael Lindner Date: Thu, 23 Jan 2025 15:52:42 +0100 Subject: [PATCH 06/20] consider SMR CC as fossil hydrogen --- scripts/pypsa-de/export_ariadne_variables.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/pypsa-de/export_ariadne_variables.py b/scripts/pypsa-de/export_ariadne_variables.py index dcb3724ff..62af10012 100644 --- a/scripts/pypsa-de/export_ariadne_variables.py +++ b/scripts/pypsa-de/export_ariadne_variables.py @@ -248,7 +248,7 @@ def _get_h2_fossil_fraction(n): .sum() ) - h2_fossil_fraction = total_h2_supply.get("SMR") / total_h2_supply.sum() + h2_fossil_fraction = total_h2_supply.filter(like="SMR").sum() / total_h2_supply.sum() return h2_fossil_fraction From 350b0fef8b2d7794c705451dae0dc992ca2b02f0 Mon Sep 17 00:00:00 2001 From: Michael Lindner Date: Thu, 23 Jan 2025 15:52:53 +0100 Subject: [PATCH 07/20] increase offwind-connection FOM --- scripts/pypsa-de/modify_cost_data.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scripts/pypsa-de/modify_cost_data.py b/scripts/pypsa-de/modify_cost_data.py index a6d352412..ba588e754 100644 --- a/scripts/pypsa-de/modify_cost_data.py +++ b/scripts/pypsa-de/modify_cost_data.py @@ -154,5 +154,15 @@ def carbon_component_fossils(costs, co2_price): costs.at[("Fischer-Tropsch", "efficiency"), "value"] = ( 1 / costs.at[("Fischer-Tropsch", "hydrogen-input"), "value"] ) + + # increase FOM of offshore wind connection (fix for costs.csv) + costs.loc[("offwind-dc-connection-submarine", "FOM"), "value"] = 0.35 + costs.loc[("offwind-dc-connection-submarine", "FOM"), "unit"] = costs.at[("offwind", "FOM"), "unit"] + costs.loc[("offwind-dc-connection-underground", "FOM"), "value"] = 0.35 + costs.loc[("offwind-dc-connection-underground", "FOM"), "unit"] = costs.at[("offwind", "FOM"), "unit"] + costs.loc[("offwind-ac-connection-submarine", "FOM"), "value"] = 0.35 + costs.loc[("offwind-ac-connection-submarine", "FOM"), "unit"] = costs.at[("offwind", "FOM"), "unit"] + costs.loc[("offwind-ac-connection-underground", "FOM"), "value"] = 0.35 + costs.loc[("offwind-ac-connection-underground", "FOM"), "unit"] = costs.at[("offwind", "FOM"), "unit"] costs.to_csv(snakemake.output[0]) From d4b6071561ecaabe84710180f457126697c388a5 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 23 Jan 2025 14:53:18 +0000 Subject: [PATCH 08/20] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- scripts/pypsa-de/export_ariadne_variables.py | 4 +++- scripts/pypsa-de/modify_cost_data.py | 18 +++++++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/scripts/pypsa-de/export_ariadne_variables.py b/scripts/pypsa-de/export_ariadne_variables.py index 62af10012..6eda64c51 100644 --- a/scripts/pypsa-de/export_ariadne_variables.py +++ b/scripts/pypsa-de/export_ariadne_variables.py @@ -248,7 +248,9 @@ def _get_h2_fossil_fraction(n): .sum() ) - h2_fossil_fraction = total_h2_supply.filter(like="SMR").sum() / total_h2_supply.sum() + h2_fossil_fraction = ( + total_h2_supply.filter(like="SMR").sum() / total_h2_supply.sum() + ) return h2_fossil_fraction diff --git a/scripts/pypsa-de/modify_cost_data.py b/scripts/pypsa-de/modify_cost_data.py index ba588e754..c4746d40b 100644 --- a/scripts/pypsa-de/modify_cost_data.py +++ b/scripts/pypsa-de/modify_cost_data.py @@ -154,15 +154,23 @@ def carbon_component_fossils(costs, co2_price): costs.at[("Fischer-Tropsch", "efficiency"), "value"] = ( 1 / costs.at[("Fischer-Tropsch", "hydrogen-input"), "value"] ) - + # increase FOM of offshore wind connection (fix for costs.csv) costs.loc[("offwind-dc-connection-submarine", "FOM"), "value"] = 0.35 - costs.loc[("offwind-dc-connection-submarine", "FOM"), "unit"] = costs.at[("offwind", "FOM"), "unit"] + costs.loc[("offwind-dc-connection-submarine", "FOM"), "unit"] = costs.at[ + ("offwind", "FOM"), "unit" + ] costs.loc[("offwind-dc-connection-underground", "FOM"), "value"] = 0.35 - costs.loc[("offwind-dc-connection-underground", "FOM"), "unit"] = costs.at[("offwind", "FOM"), "unit"] + costs.loc[("offwind-dc-connection-underground", "FOM"), "unit"] = costs.at[ + ("offwind", "FOM"), "unit" + ] costs.loc[("offwind-ac-connection-submarine", "FOM"), "value"] = 0.35 - costs.loc[("offwind-ac-connection-submarine", "FOM"), "unit"] = costs.at[("offwind", "FOM"), "unit"] + costs.loc[("offwind-ac-connection-submarine", "FOM"), "unit"] = costs.at[ + ("offwind", "FOM"), "unit" + ] costs.loc[("offwind-ac-connection-underground", "FOM"), "value"] = 0.35 - costs.loc[("offwind-ac-connection-underground", "FOM"), "unit"] = costs.at[("offwind", "FOM"), "unit"] + costs.loc[("offwind-ac-connection-underground", "FOM"), "unit"] = costs.at[ + ("offwind", "FOM"), "unit" + ] costs.to_csv(snakemake.output[0]) From 308bbcbdd8b8226d585b8f9f08e873b52cd138e6 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 23 Jan 2025 15:03:00 +0000 Subject: [PATCH 09/20] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- scripts/pypsa-de/plot_ariadne_report.py | 1 - scripts/pypsa-de/plot_ariadne_variables.py | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/pypsa-de/plot_ariadne_report.py b/scripts/pypsa-de/plot_ariadne_report.py index d72016454..471f58d0c 100644 --- a/scripts/pypsa-de/plot_ariadne_report.py +++ b/scripts/pypsa-de/plot_ariadne_report.py @@ -2449,7 +2449,6 @@ def plot_elec_map_de( frameon=True, facecolor="white", fontsize=14, - ) add_legend_patches(ax, colors, labels, legend_kw=legend_kw_patches) diff --git a/scripts/pypsa-de/plot_ariadne_variables.py b/scripts/pypsa-de/plot_ariadne_variables.py index 0f40c71af..760b9b0d5 100644 --- a/scripts/pypsa-de/plot_ariadne_variables.py +++ b/scripts/pypsa-de/plot_ariadne_variables.py @@ -6,13 +6,14 @@ import pandas as pd from scripts._helpers import mock_snakemake + TWh2PJ = 3.6 def plot_trade( df, savepath, -): +): # WARNING CODE DUPLICATION # WARNING i just asked COPILOT to reformat the two plots below # load data and convert to TWh From def78e58344299f5f4594d449d41be03fbd6285e Mon Sep 17 00:00:00 2001 From: Michael Lindner Date: Thu, 23 Jan 2025 16:27:37 +0100 Subject: [PATCH 10/20] fix imports paths --- scripts/pypsa-de/plot_ariadne_report.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/pypsa-de/plot_ariadne_report.py b/scripts/pypsa-de/plot_ariadne_report.py index 471f58d0c..2ef96ed10 100644 --- a/scripts/pypsa-de/plot_ariadne_report.py +++ b/scripts/pypsa-de/plot_ariadne_report.py @@ -22,11 +22,11 @@ from pypsa.plot import add_legend_lines from scripts._helpers import configure_logging, mock_snakemake, set_scenario_config -from scripts.export_ariadne_variables import get_discretized_value, process_postnetworks +from export_ariadne_variables import get_discretized_value, process_postnetworks from scripts.plot_power_network import load_projection from scripts.plot_summary import preferred_order, rename_techs from scripts.prepare_sector_network import prepare_costs -from scripts.pypsa.plot import add_legend_circles, add_legend_lines, add_legend_patches +from pypsa.plot import add_legend_circles, add_legend_lines, add_legend_patches logger = logging.getLogger(__name__) From 72c3f73730a9aed40c45bd4ca20e0470de0c44c4 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 23 Jan 2025 15:28:10 +0000 Subject: [PATCH 11/20] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- scripts/pypsa-de/plot_ariadne_report.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/scripts/pypsa-de/plot_ariadne_report.py b/scripts/pypsa-de/plot_ariadne_report.py index 2ef96ed10..806a1c83d 100644 --- a/scripts/pypsa-de/plot_ariadne_report.py +++ b/scripts/pypsa-de/plot_ariadne_report.py @@ -16,17 +16,16 @@ import numpy as np import pandas as pd import pypsa +from export_ariadne_variables import get_discretized_value, process_postnetworks from matplotlib.lines import Line2D from matplotlib.patches import Patch from matplotlib.ticker import FuncFormatter -from pypsa.plot import add_legend_lines +from pypsa.plot import add_legend_circles, add_legend_lines, add_legend_patches from scripts._helpers import configure_logging, mock_snakemake, set_scenario_config -from export_ariadne_variables import get_discretized_value, process_postnetworks from scripts.plot_power_network import load_projection from scripts.plot_summary import preferred_order, rename_techs from scripts.prepare_sector_network import prepare_costs -from pypsa.plot import add_legend_circles, add_legend_lines, add_legend_patches logger = logging.getLogger(__name__) From 9804b6f7b73aa1a4bd7eaa328b8d840cc79ae0a1 Mon Sep 17 00:00:00 2001 From: Michael Lindner Date: Fri, 24 Jan 2025 11:33:38 +0100 Subject: [PATCH 12/20] further refine offwind buildout --- config/config.yaml | 6 +++--- config/scenarios.manual.yaml | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/config/config.yaml b/config/config.yaml index ae67e6b62..baddd8794 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -445,9 +445,9 @@ solving: 2020: 7.8 2025: 11.3 2030: 29.3 # uba Projektionsbericht and NEP without delayed BalWin 3 - 2035: 40 - 2040: 60 - 2045: 70 + 2035: 51.3 # Planned projects until 2035 -> offshore_connection_points.csv + 2040: 65 # Planned projects until 2040 -1.5 GW for potential retirments + 2045: 70 solar: DE: 2020: 53.7 diff --git a/config/scenarios.manual.yaml b/config/scenarios.manual.yaml index 2831de9ee..8a4ae8978 100644 --- a/config/scenarios.manual.yaml +++ b/config/scenarios.manual.yaml @@ -57,7 +57,7 @@ CurrentPolicies: 2020: 7.8 2025: 11.3 2030: 17.3 # 12 less than NEP, because of 1 year delay - 2035: 35 # 29.3 + a little extra + 2035: 40 # 29.3 + half of extra projects onwind: DE: 2030: 94.5 # uba Projektionsbericht @@ -588,7 +588,7 @@ KN2045minus_WorstCase: 2020: 7.8 2025: 11.3 2030: 17.3 # 12 less than NEP, because of 1 year delay - 2035: 35 # 29.3 + a little extra + 2035: 40 # 29.3 + half of extra projects onwind: DE: 2030: 94.5 # uba Projektionsbericht From e82cd2294d6f2f152aa6bf826774b723c4d5f3bb Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 24 Jan 2025 10:34:03 +0000 Subject: [PATCH 13/20] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- config/config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/config.yaml b/config/config.yaml index baddd8794..ab72e919a 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -447,7 +447,7 @@ solving: 2030: 29.3 # uba Projektionsbericht and NEP without delayed BalWin 3 2035: 51.3 # Planned projects until 2035 -> offshore_connection_points.csv 2040: 65 # Planned projects until 2040 -1.5 GW for potential retirments - 2045: 70 + 2045: 70 solar: DE: 2020: 53.7 From 8a6e002123b7bf62dc35ca43e18bb453c2811237 Mon Sep 17 00:00:00 2001 From: Michael Lindner Date: Fri, 24 Jan 2025 11:34:29 +0100 Subject: [PATCH 14/20] add to previous commit (further refine offwind buildout) --- config/config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/config.yaml b/config/config.yaml index baddd8794..dd732c07f 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -445,7 +445,7 @@ solving: 2020: 7.8 2025: 11.3 2030: 29.3 # uba Projektionsbericht and NEP without delayed BalWin 3 - 2035: 51.3 # Planned projects until 2035 -> offshore_connection_points.csv + 2035: 50 # Planned projects until 2035 (offshore_connection_points.csv) -1.3 GW for potential delays 2040: 65 # Planned projects until 2040 -1.5 GW for potential retirments 2045: 70 solar: From 98444861ad694b8a9cd1051b0f6afbb169418b7e Mon Sep 17 00:00:00 2001 From: Michael Lindner Date: Fri, 24 Jan 2025 11:46:41 +0100 Subject: [PATCH 15/20] improve the bev_dsm config option --- config/config.default.yaml | 2 +- doc/configtables/sector.csv | 2 +- scripts/prepare_sector_network.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config/config.default.yaml b/config/config.default.yaml index 12e690f16..57faeb9e0 100644 --- a/config/config.default.yaml +++ b/config/config.default.yaml @@ -498,7 +498,7 @@ sector: ICE_upper_degree_factor: 1.6 EV_lower_degree_factor: 0.98 EV_upper_degree_factor: 0.63 - bev_dsm_startyear: 2030 + bev_dsm: 2030 bev_availability: 0.5 bev_energy: 0.05 bev_charge_efficiency: 0.9 diff --git a/doc/configtables/sector.csv b/doc/configtables/sector.csv index eeee192eb..96ebe8ab3 100644 --- a/doc/configtables/sector.csv +++ b/doc/configtables/sector.csv @@ -38,7 +38,7 @@ ICE_lower_degree_factor,--,float,Share increase in energy demand in internal com ICE_upper_degree_factor,--,float,Share increase in energy demand in internal combustion engine (ICE) for each degree difference between the hot environment and the maximum temperature. EV_lower_degree_factor,--,float,Share increase in energy demand in electric vehicles (EV) for each degree difference between the cold environment and the minimum temperature. EV_upper_degree_factor,--,float,Share increase in energy demand in electric vehicles (EV) for each degree difference between the hot environment and the maximum temperature. -bev_dsm,--,"{true, false}",Add the option for battery electric vehicles (BEV) to participate in demand-side management (DSM) +bev_dsm,--,"{true, false} or startyear as int",Add the option for battery electric vehicles (BEV) to participate in demand-side management (DSM). If an int is passed it is interpreted as the year from which on BEV DSM is available. ,,, bev_availability,--,float,The share for battery electric vehicles (BEV) that are able to do demand side management (DSM) bev_energy,--,float,The average size of battery electric vehicles (BEV) in MWh diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index 442a90ae2..7508e4faa 100755 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -2029,7 +2029,7 @@ def add_EVs( efficiency=options["bev_charge_efficiency"], ) - if options["bev_dsm_startyear"] <= investment_year: + if options["bev_dsm"] and options["bev_dsm"] <= investment_year: e_nom = ( number_cars * options["bev_energy"] From 15d332032e38aa51da64a3a44090fa60b5a0638f Mon Sep 17 00:00:00 2001 From: Michael Lindner Date: Fri, 24 Jan 2025 12:09:38 +0100 Subject: [PATCH 16/20] generalize mock_snakemake --- scripts/_helpers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/_helpers.py b/scripts/_helpers.py index c65e9e59e..f2bb56f9b 100644 --- a/scripts/_helpers.py +++ b/scripts/_helpers.py @@ -471,7 +471,7 @@ def mock_snakemake( else: root_dir = Path(root_dir).resolve() - user_in_script_dir = Path.cwd().resolve() == script_dir + user_in_script_dir = Path.cwd().resolve().is_relative_to(Path(script_dir)) if str(submodule_dir) in __file__: # the submodule_dir path is only need to locate the project dir os.chdir(Path(__file__[: __file__.find(str(submodule_dir))])) From 125037ff0fd416d6b94457241c4a64e32dd2d807 Mon Sep 17 00:00:00 2001 From: Michael Lindner Date: Fri, 24 Jan 2025 12:09:58 +0100 Subject: [PATCH 17/20] hotfix mock_snakemake for this script --- scripts/pypsa-de/export_ariadne_variables.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/pypsa-de/export_ariadne_variables.py b/scripts/pypsa-de/export_ariadne_variables.py index c3ed19207..b068f5a9c 100644 --- a/scripts/pypsa-de/export_ariadne_variables.py +++ b/scripts/pypsa-de/export_ariadne_variables.py @@ -5,6 +5,9 @@ import os import re import sys + +sys.path.insert(0, os.path.abspath(os.path.dirname(__file__) + "/../..")) + from functools import reduce import numpy as np From f20236d5f99c7a3d926a0bc9f876b102d4adaf2d Mon Sep 17 00:00:00 2001 From: Michael Lindner Date: Fri, 24 Jan 2025 12:17:56 +0100 Subject: [PATCH 18/20] add description to modified costs.csv --- scripts/pypsa-de/modify_cost_data.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/pypsa-de/modify_cost_data.py b/scripts/pypsa-de/modify_cost_data.py index c4746d40b..56b6a8308 100644 --- a/scripts/pypsa-de/modify_cost_data.py +++ b/scripts/pypsa-de/modify_cost_data.py @@ -154,6 +154,7 @@ def carbon_component_fossils(costs, co2_price): costs.at[("Fischer-Tropsch", "efficiency"), "value"] = ( 1 / costs.at[("Fischer-Tropsch", "hydrogen-input"), "value"] ) + costs.at[("Fischer-Tropsch", "efficiency"), "source"] = "inverse of hydrogen-input" # increase FOM of offshore wind connection (fix for costs.csv) costs.loc[("offwind-dc-connection-submarine", "FOM"), "value"] = 0.35 From e96f6f969428fa04d272a969f094a56c84b7e356 Mon Sep 17 00:00:00 2001 From: Michael Lindner Date: Fri, 24 Jan 2025 13:31:10 +0100 Subject: [PATCH 19/20] split efuel export bans by carrier --- scripts/pypsa-de/additional_functionality.py | 40 +++++++++++++++++++- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/scripts/pypsa-de/additional_functionality.py b/scripts/pypsa-de/additional_functionality.py index 07a0b930b..5c3bf0b21 100644 --- a/scripts/pypsa-de/additional_functionality.py +++ b/scripts/pypsa-de/additional_functionality.py @@ -219,6 +219,15 @@ def h2_import_limits(n, investment_year, limits_volume_max): f"Global constraint {cname} already exists. Dropping and adding it again." ) n.global_constraints.drop(cname, inplace=True) + + n.add( + "GlobalConstraint", + cname, + constant=0, + sense=">=", + type="", + carrier_attribute="", + ) def h2_production_limits(n, investment_year, limits_volume_min, limits_volume_max): @@ -659,9 +668,27 @@ def add_h2_derivate_limit(n, investment_year, limits_volume_max): carrier_attribute="", ) - logger.info("Adding H2 derivate export ban") + # The following export bans for DE are added unconditionally, independent of config + ct = "DE" + logger.info("Adding net export bans for H2 derivatives in DE") + + for incarrier, outcarrier in [ + ("EU methanol -> DE methanol", "DE methanol -> EU methanol"), + ("EU renewable gas -> DE gas", "DE renewable gas -> EU gas"), + ("EU renewable oil -> DE oil", "DE renewable oil -> EU oil"), + ]: + incoming = n.links.index[n.links.index == incarrier] + outgoing = n.links.index[n.links.index == outcarrier] + incoming_p = ( + n.model["Link-p"].loc[:, incoming] * n.snapshot_weightings.generators + ).sum() + outgoing_p = ( + n.model["Link-p"].loc[:, outgoing] * n.snapshot_weightings.generators + ).sum() + + lhs = incoming_p - outgoing_p - cname = f"H2_derivate_export_ban-{ct}" + cname = f"renewable{incarrier.split()[-1]}_export_ban-{ct}" n.model.add_constraints(lhs >= 0, name=f"GlobalConstraint-{cname}") @@ -671,6 +698,15 @@ def add_h2_derivate_limit(n, investment_year, limits_volume_max): ) n.global_constraints.drop(cname, inplace=True) + n.add( + "GlobalConstraint", + cname, + constant=0, + sense=">=", + type="", + carrier_attribute="", + ) + def adapt_nuclear_output(n): logger.info( From 603a3cd6ad3a4d0d073db7245fdad6a392a3616c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 24 Jan 2025 12:32:37 +0000 Subject: [PATCH 20/20] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- scripts/pypsa-de/additional_functionality.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/pypsa-de/additional_functionality.py b/scripts/pypsa-de/additional_functionality.py index 5c3bf0b21..e5a1b347b 100644 --- a/scripts/pypsa-de/additional_functionality.py +++ b/scripts/pypsa-de/additional_functionality.py @@ -219,7 +219,7 @@ def h2_import_limits(n, investment_year, limits_volume_max): f"Global constraint {cname} already exists. Dropping and adding it again." ) n.global_constraints.drop(cname, inplace=True) - + n.add( "GlobalConstraint", cname,