From e891305c9dd30fd6d09884f071f2f05ac8a5d023 Mon Sep 17 00:00:00 2001 From: Koen van Greevenbroek Date: Fri, 1 Mar 2024 14:37:16 +0100 Subject: [PATCH] Add selection of cutouts for heat to config --- config/config.default.yaml | 2 ++ rules/build_sector.smk | 45 ++++++++++++++++--------- scripts/build_solar_thermal_profiles.py | 1 + 3 files changed, 33 insertions(+), 15 deletions(-) diff --git a/config/config.default.yaml b/config/config.default.yaml index 60c492b1..bb714027 100644 --- a/config/config.default.yaml +++ b/config/config.default.yaml @@ -359,6 +359,7 @@ solar_thermal: orientation: slope: 45. azimuth: 180. + cutout: default # docs in https://pypsa-eur.readthedocs.io/en/latest/configuration.html#existing-capacities existing_capacities: @@ -391,6 +392,7 @@ sector: 2050: 1.0 district_heating_loss: 0.15 cluster_heat_buses: true + heat_demand_cutout: default bev_dsm_restriction_value: 0.75 bev_dsm_restriction_time: 7 transport_heating_deadband_upper: 20. diff --git a/rules/build_sector.smk b/rules/build_sector.smk index 9fb6876b..e8af7f7b 100644 --- a/rules/build_sector.smk +++ b/rules/build_sector.smk @@ -151,6 +151,19 @@ rule cluster_gas_network: "../scripts/cluster_gas_network.py" +def heat_demand_cutout(wildcards): + c = config_provider("sector", "heat_demand_cutout")(wildcards) + if c == "default": + return ( + "cutouts/" + + CDIR + + config_provider("atlite", "default_cutout")(wildcards) + + ".nc" + ) + else: + return "cutouts/" + CDIR + c + ".nc" + + rule build_daily_heat_demand: params: snapshots=config_provider("snapshots"), @@ -160,12 +173,7 @@ rule build_daily_heat_demand: regions_onshore=resources( "regions_onshore_elec{weather_year}_s{simpl}_{clusters}.geojson" ), - cutout=( - lambda w: "cutouts/" - + CDIR - + config_provider("atlite", "default_cutout")(w) - + ".nc", - ), + cutout=heat_demand_cutout, output: heat_demand=resources( "daily_heat_demand_{scope}_elec{weather_year}_s{simpl}_{clusters}.nc" @@ -217,10 +225,7 @@ rule build_temperature_profiles: regions_onshore=resources( "regions_onshore_elec{weather_year}_s{simpl}_{clusters}.geojson" ), - cutout=lambda w: "cutouts/" - + CDIR - + config_provider("atlite", "default_cutout")(w) - + ".nc", + cutout=heat_demand_cutout, output: temp_soil=resources( "temp_soil_{scope}_elec{weather_year}_s{simpl}_{clusters}.nc" @@ -294,6 +299,19 @@ rule build_cop_profiles: "../scripts/build_cop_profiles.py" +def solar_thermal_cutout(wildcards): + c = config_provider("solar_thermal", "cutout")(wildcards) + if c == "default": + return ( + "cutouts/" + + CDIR + + config_provider("atlite", "default_cutout")(wildcards) + + ".nc" + ) + else: + return "cutouts/" + CDIR + c + ".nc" + + rule build_solar_thermal_profiles: params: snapshots=config_provider("snapshots"), @@ -304,10 +322,7 @@ rule build_solar_thermal_profiles: regions_onshore=resources( "regions_onshore_elec{weather_year}_s{simpl}_{clusters}.geojson" ), - cutout=lambda w: "cutouts/" - + CDIR - + config_provider("atlite", "default_cutout")(w) - + ".nc", + cutout=solar_thermal_cutout, output: solar_thermal=resources( "solar_thermal_{scope}_elec{weather_year}_s{simpl}_{clusters}.nc" @@ -949,7 +964,7 @@ rule build_existing_heating_distribution: def input_profile_offwind(w): return { - f"profile_{tech}": resources(f"profile{weather_year}_{tech}.nc") + f"profile_{tech}": resources(f"profile{{weather_year}}_{tech}.nc") for tech in ["offwind-ac", "offwind-dc"] if (tech in config_provider("electricity", "renewable_carriers")(w)) } diff --git a/scripts/build_solar_thermal_profiles.py b/scripts/build_solar_thermal_profiles.py index b0896fa7..db56a401 100644 --- a/scripts/build_solar_thermal_profiles.py +++ b/scripts/build_solar_thermal_profiles.py @@ -31,6 +31,7 @@ if __name__ == "__main__": client = Client(cluster, asynchronous=True) config = snakemake.params.solar_thermal + config.pop("cutout", None) cutout_name = snakemake.input.cutout year = snakemake.wildcards.weather_year