From 55ffaf7eb8c53e28cb16f640bf61e507e6b66f68 Mon Sep 17 00:00:00 2001 From: Michael Lindner Date: Thu, 10 Oct 2024 16:01:43 +0200 Subject: [PATCH 1/2] adapt to store lifetime in pypsa-eur --- workflow/scripts/modify_prenetwork.py | 12 +++++++----- workflow/submodules/pypsa-eur | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/workflow/scripts/modify_prenetwork.py b/workflow/scripts/modify_prenetwork.py index d3d38af6..80e9d0f4 100644 --- a/workflow/scripts/modify_prenetwork.py +++ b/workflow/scripts/modify_prenetwork.py @@ -410,10 +410,11 @@ def unravel_carbonaceous_fuels(n): ) # add stores - EU_oil_store = n.stores.loc["EU oil Store"].copy() + current_year = int(snakemake.wildcards.planning_horizons) + EU_oil_store = n.stores.loc[f"EU oil Store-{current_year}"].copy() n.add( "Store", - "DE oil Store", + f"DE oil Store-{current_year}", bus="DE oil", carrier="oil", e_nom_extendable=EU_oil_store.e_nom_extendable, @@ -472,10 +473,10 @@ def unravel_carbonaceous_fuels(n): ) # add stores - EU_meoh_store = n.stores.loc["EU methanol Store"].copy() + EU_meoh_store = n.stores.loc[f"EU methanol Store-{current_year}"].copy() n.add( "Store", - "DE methanol Store", + f"DE methanol Store-{current_year}", bus="DE methanol", carrier="methanol", e_nom_extendable=EU_meoh_store.e_nom_extendable, @@ -612,9 +613,10 @@ def unravel_gasbus(n, costs): carrier="gas", marginal_cost=costs.at["gas", "fuel"], ) + current_year = int(snakemake.wildcards.planning_horizons) n.add( "Store", - "DE gas Store", + f"DE gas Store-{current_year}", bus="DE gas", carrier="gas", e_nom_extendable=True, diff --git a/workflow/submodules/pypsa-eur b/workflow/submodules/pypsa-eur index 3e3f36db..222caa63 160000 --- a/workflow/submodules/pypsa-eur +++ b/workflow/submodules/pypsa-eur @@ -1 +1 @@ -Subproject commit 3e3f36db7e16869c47428dfec65fb9586cc29514 +Subproject commit 222caa632ba8509b0560234cc2aa38faf71dd150 From fd731288f0d691e56fe0838b3aaf54d4ae9402c7 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 10 Oct 2024 14:04:15 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- workflow/scripts/export_ariadne_variables.py | 51 +++++++++++--------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/workflow/scripts/export_ariadne_variables.py b/workflow/scripts/export_ariadne_variables.py index 963f6701..e1d8d1b6 100644 --- a/workflow/scripts/export_ariadne_variables.py +++ b/workflow/scripts/export_ariadne_variables.py @@ -1105,20 +1105,22 @@ def get_primary_energy(n, region): # btl_efficiency = n.links.query( # "carrier == 'biomass to liquid' and (build_year == 2020)" # ).efficiency.unique().item() - - unsus_btl_secondary = n.statistics.supply( + + unsus_btl_secondary = ( + n.statistics.supply( bus_carrier=["renewable oil"], **kwargs, - ).filter( - like=region - ).groupby("carrier").sum().multiply(MWh2PJ).get( - "unsustainable bioliquids", 0 - ) - + ) + .filter(like=region) + .groupby("carrier") + .sum() + .multiply(MWh2PJ) + .get("unsustainable bioliquids", 0) + ) + var["Primary Energy|Biomass|Liquids"] = ( - biomass_usage.filter( - like="biomass to liquid" - ).sum() + unsus_btl_secondary / 0.35 # BtL efficiency 2020 + biomass_usage.filter(like="biomass to liquid").sum() + + unsus_btl_secondary / 0.35 # BtL efficiency 2020 ) var["Primary Energy|Biomass|w/ CCS"] = biomass_usage[ @@ -2117,14 +2119,14 @@ def get_final_energy( energy_totals["total domestic navigation"] + energy_totals["total international navigation"] ) - var["Final Energy|Transportation|Domestic Aviation"] = \ - var["Final Energy|Transportation|Domestic Aviation|Liquids"] = ( - sum_load(n, "kerosene for aviation", region) * (1 - international_aviation_fraction) - ) - var["Final Energy|Transportation|Domestic Navigation"] = \ - var["Final Energy|Transportation|Domestic Navigation|Liquids"] = ( - sum_load(n, "shipping oil", region) * (1 - international_navigation_fraction) + var["Final Energy|Transportation|Domestic Aviation"] = var[ + "Final Energy|Transportation|Domestic Aviation|Liquids" + ] = sum_load(n, "kerosene for aviation", region) * ( + 1 - international_aviation_fraction ) + var["Final Energy|Transportation|Domestic Navigation"] = var[ + "Final Energy|Transportation|Domestic Navigation|Liquids" + ] = sum_load(n, "shipping oil", region) * (1 - international_navigation_fraction) var["Final Energy|Transportation|Liquids"] = ( sum_load(n, "land transport oil", region) @@ -2154,7 +2156,9 @@ def get_final_energy( "Final Energy|Bunkers|Aviation|Liquids" ] = (sum_load(n, "kerosene for aviation", region) * international_aviation_fraction) - for var_key, fraction_key in zip(["Petroleum", "Efuel", "Biomass"], oil_fractions.index): + for var_key, fraction_key in zip( + ["Petroleum", "Efuel", "Biomass"], oil_fractions.index + ): var[f"Final Energy|Bunkers|Aviation|Liquids|{var_key}"] = ( var["Final Energy|Bunkers|Aviation|Liquids"] * oil_fractions[fraction_key] ) @@ -2164,7 +2168,9 @@ def get_final_energy( sum_load(n, "shipping oil", region) * international_navigation_fraction ) - for var_key, fraction_key in zip(["Petroleum", "Efuel", "Biomass"], oil_fractions.index): + for var_key, fraction_key in zip( + ["Petroleum", "Efuel", "Biomass"], oil_fractions.index + ): var[f"Final Energy|Bunkers|Navigation|Liquids|{var_key}"] = ( var["Final Energy|Bunkers|Navigation|Liquids"] * oil_fractions[fraction_key] ) @@ -2636,7 +2642,8 @@ def get_emissions(n, region, _energy_totals, industry_demand): ) var["Emissions|CO2|Energy|Demand|Transportation|Domestic Navigation"] = ( - co2_emissions.filter(like="shipping").sum() * (1 - international_navigation_fraction) + co2_emissions.filter(like="shipping").sum() + * (1 - international_navigation_fraction) ) var["Emissions|CO2|Energy|Demand|Transportation"] = ( @@ -2645,8 +2652,6 @@ def get_emissions(n, region, _energy_totals, industry_demand): + var["Emissions|CO2|Energy|Demand|Transportation|Domestic Navigation"] ) - - var["Emissions|CO2|Energy|Demand|Bunkers|Aviation"] = ( co2_emissions.get("kerosene for aviation") * international_aviation_fraction )