add multiyear support

This commit is contained in:
Fabian Neumann 2020-11-10 09:52:06 +01:00
parent 59cb036122
commit df94ea1c8b
6 changed files with 153 additions and 130 deletions

244
Snakefile
View File

@ -2,8 +2,8 @@
configfile: "config.yaml" configfile: "config.yaml"
wildcard_constraints: wildcard_constraints:
year="[0-9]*",
lv="[a-z0-9\.]+", lv="[a-z0-9\.]+",
network="[a-zA-Z0-9]*",
simpl="[a-zA-Z0-9]*", simpl="[a-zA-Z0-9]*",
clusters="[0-9]+m?", clusters="[0-9]+m?",
sectors="[+a-zA-Z0-9]+", sectors="[+a-zA-Z0-9]+",
@ -25,17 +25,17 @@ rule all:
rule solve_all_networks: rule solve_all_networks:
input: input:
expand(config['results_dir'] + config['run'] + "/postnetworks/elec_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}_{co2_budget_name}_{planning_horizons}.nc", expand(config['results_dir'] + config['run'] + "/postnetworks/elec{year}_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}_{co2_budget_name}_{planning_horizons}.nc",
**config['scenario']) **config['scenario'])
rule test_script: rule test_script:
input: input:
expand("resources/heat_demand_urban_elec_s_{clusters}.nc", expand("resources/heat_demand_urban_elec{year}_s_{clusters}.nc",
**config['scenario']) **config['scenario'])
rule prepare_sector_networks: rule prepare_sector_networks:
input: input:
expand(config['results_dir'] + config['run'] + "/prenetworks/elec_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}_{co2_budget_name}_{planning_horizons}.nc", expand(config['results_dir'] + config['run'] + "/prenetworks/elec{year}_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}_{co2_budget_name}_{planning_horizons}.nc",
**config['scenario']) **config['scenario'])
@ -44,96 +44,96 @@ rule build_population_layouts:
nuts3_shapes=pypsaeur('resources/nuts3_shapes.geojson'), nuts3_shapes=pypsaeur('resources/nuts3_shapes.geojson'),
urban_percent="data/urban_percent.csv" urban_percent="data/urban_percent.csv"
output: output:
pop_layout_total="resources/pop_layout_total.nc", pop_layout_total="resources/pop_layout{year}_total.nc",
pop_layout_urban="resources/pop_layout_urban.nc", pop_layout_urban="resources/pop_layout{year}_urban.nc",
pop_layout_rural="resources/pop_layout_rural.nc" pop_layout_rural="resources/pop_layout{year}_rural.nc"
resources: mem_mb=20000 resources: mem_mb=20000
script: "scripts/build_population_layouts.py" script: "scripts/build_population_layouts.py"
rule build_clustered_population_layouts: rule build_clustered_population_layouts:
input: input:
pop_layout_total="resources/pop_layout_total.nc", pop_layout_total="resources/pop_layout{year}_total.nc",
pop_layout_urban="resources/pop_layout_urban.nc", pop_layout_urban="resources/pop_layout{year}_urban.nc",
pop_layout_rural="resources/pop_layout_rural.nc", pop_layout_rural="resources/pop_layout{year}_rural.nc",
regions_onshore=pypsaeur('resources/regions_onshore_{network}_s{simpl}_{clusters}.geojson') regions_onshore=pypsaeur('resources/regions_onshore_elec{year}_s{simpl}_{clusters}.geojson')
output: output:
clustered_pop_layout="resources/pop_layout_{network}_s{simpl}_{clusters}.csv" clustered_pop_layout="resources/pop_layout_elec{year}_s{simpl}_{clusters}.csv"
resources: mem_mb=10000 resources: mem_mb=10000
script: "scripts/build_clustered_population_layouts.py" script: "scripts/build_clustered_population_layouts.py"
rule build_simplified_population_layouts: rule build_simplified_population_layouts:
input: input:
pop_layout_total="resources/pop_layout_total.nc", pop_layout_total="resources/pop_layout{year}_total.nc",
pop_layout_urban="resources/pop_layout_urban.nc", pop_layout_urban="resources/pop_layout{year}_urban.nc",
pop_layout_rural="resources/pop_layout_rural.nc", pop_layout_rural="resources/pop_layout{year}_rural.nc",
regions_onshore=pypsaeur('resources/regions_onshore_{network}_s{simpl}.geojson') regions_onshore=pypsaeur('resources/regions_onshore_elec{year}_s{simpl}.geojson')
output: output:
clustered_pop_layout="resources/pop_layout_{network}_s{simpl}.csv" clustered_pop_layout="resources/pop_layout_elec{year}_s{simpl}.csv"
resources: mem_mb=10000 resources: mem_mb=10000
script: "scripts/build_clustered_population_layouts.py" script: "scripts/build_clustered_population_layouts.py"
rule build_heat_demands: rule build_heat_demands:
input: input:
pop_layout_total="resources/pop_layout_total.nc", pop_layout_total="resources/pop_layout{year}_total.nc",
pop_layout_urban="resources/pop_layout_urban.nc", pop_layout_urban="resources/pop_layout{year}_urban.nc",
pop_layout_rural="resources/pop_layout_rural.nc", pop_layout_rural="resources/pop_layout{year}_rural.nc",
regions_onshore=pypsaeur("resources/regions_onshore_{network}_s{simpl}_{clusters}.geojson") regions_onshore=pypsaeur("resources/regions_onshore_elec{year}_s{simpl}_{clusters}.geojson")
output: output:
heat_demand_urban="resources/heat_demand_urban_{network}_s{simpl}_{clusters}.nc", heat_demand_urban="resources/heat_demand_urban_elec{year}_s{simpl}_{clusters}.nc",
heat_demand_rural="resources/heat_demand_rural_{network}_s{simpl}_{clusters}.nc", heat_demand_rural="resources/heat_demand_rural_elec{year}_s{simpl}_{clusters}.nc",
heat_demand_total="resources/heat_demand_total_{network}_s{simpl}_{clusters}.nc" heat_demand_total="resources/heat_demand_total_elec{year}_s{simpl}_{clusters}.nc"
resources: mem_mb=20000 resources: mem_mb=20000
script: "scripts/build_heat_demand.py" script: "scripts/build_heat_demand.py"
rule build_temperature_profiles: rule build_temperature_profiles:
input: input:
pop_layout_total="resources/pop_layout_total.nc", pop_layout_total="resources/pop_layout{year}_total.nc",
pop_layout_urban="resources/pop_layout_urban.nc", pop_layout_urban="resources/pop_layout{year}_urban.nc",
pop_layout_rural="resources/pop_layout_rural.nc", pop_layout_rural="resources/pop_layout{year}_rural.nc",
regions_onshore=pypsaeur("resources/regions_onshore_{network}_s{simpl}_{clusters}.geojson") regions_onshore=pypsaeur("resources/regions_onshore_elec{year}_s{simpl}_{clusters}.geojson")
output: output:
temp_soil_total="resources/temp_soil_total_{network}_s{simpl}_{clusters}.nc", temp_soil_total="resources/temp_soil_total_elec{year}_s{simpl}_{clusters}.nc",
temp_soil_rural="resources/temp_soil_rural_{network}_s{simpl}_{clusters}.nc", temp_soil_rural="resources/temp_soil_rural_elec{year}_s{simpl}_{clusters}.nc",
temp_soil_urban="resources/temp_soil_urban_{network}_s{simpl}_{clusters}.nc", temp_soil_urban="resources/temp_soil_urban_elec{year}_s{simpl}_{clusters}.nc",
temp_air_total="resources/temp_air_total_{network}_s{simpl}_{clusters}.nc", temp_air_total="resources/temp_air_total_elec{year}_s{simpl}_{clusters}.nc",
temp_air_rural="resources/temp_air_rural_{network}_s{simpl}_{clusters}.nc", temp_air_rural="resources/temp_air_rural_elec{year}_s{simpl}_{clusters}.nc",
temp_air_urban="resources/temp_air_urban_{network}_s{simpl}_{clusters}.nc" temp_air_urban="resources/temp_air_urban_elec{year}_s{simpl}_{clusters}.nc"
resources: mem_mb=20000 resources: mem_mb=20000
script: "scripts/build_temperature_profiles.py" script: "scripts/build_temperature_profiles.py"
rule build_cop_profiles: rule build_cop_profiles:
input: input:
temp_soil_total="resources/temp_soil_total_{network}_s{simpl}_{clusters}.nc", temp_soil_total="resources/temp_soil_total_elec{year}_s{simpl}_{clusters}.nc",
temp_soil_rural="resources/temp_soil_rural_{network}_s{simpl}_{clusters}.nc", temp_soil_rural="resources/temp_soil_rural_elec{year}_s{simpl}_{clusters}.nc",
temp_soil_urban="resources/temp_soil_urban_{network}_s{simpl}_{clusters}.nc", temp_soil_urban="resources/temp_soil_urban_elec{year}_s{simpl}_{clusters}.nc",
temp_air_total="resources/temp_air_total_{network}_s{simpl}_{clusters}.nc", temp_air_total="resources/temp_air_total_elec{year}_s{simpl}_{clusters}.nc",
temp_air_rural="resources/temp_air_rural_{network}_s{simpl}_{clusters}.nc", temp_air_rural="resources/temp_air_rural_elec{year}_s{simpl}_{clusters}.nc",
temp_air_urban="resources/temp_air_urban_{network}_s{simpl}_{clusters}.nc" temp_air_urban="resources/temp_air_urban_elec{year}_s{simpl}_{clusters}.nc"
output: output:
cop_soil_total="resources/cop_soil_total_{network}_s{simpl}_{clusters}.nc", cop_soil_total="resources/cop_soil_total_elec{year}_s{simpl}_{clusters}.nc",
cop_soil_rural="resources/cop_soil_rural_{network}_s{simpl}_{clusters}.nc", cop_soil_rural="resources/cop_soil_rural_elec{year}_s{simpl}_{clusters}.nc",
cop_soil_urban="resources/cop_soil_urban_{network}_s{simpl}_{clusters}.nc", cop_soil_urban="resources/cop_soil_urban_elec{year}_s{simpl}_{clusters}.nc",
cop_air_total="resources/cop_air_total_{network}_s{simpl}_{clusters}.nc", cop_air_total="resources/cop_air_total_elec{year}_s{simpl}_{clusters}.nc",
cop_air_rural="resources/cop_air_rural_{network}_s{simpl}_{clusters}.nc", cop_air_rural="resources/cop_air_rural_elec{year}_s{simpl}_{clusters}.nc",
cop_air_urban="resources/cop_air_urban_{network}_s{simpl}_{clusters}.nc" cop_air_urban="resources/cop_air_urban_elec{year}_s{simpl}_{clusters}.nc"
resources: mem_mb=20000 resources: mem_mb=20000
script: "scripts/build_cop_profiles.py" script: "scripts/build_cop_profiles.py"
rule build_solar_thermal_profiles: rule build_solar_thermal_profiles:
input: input:
pop_layout_total="resources/pop_layout_total.nc", pop_layout_total="resources/pop_layout{year}_total.nc",
pop_layout_urban="resources/pop_layout_urban.nc", pop_layout_urban="resources/pop_layout{year}_urban.nc",
pop_layout_rural="resources/pop_layout_rural.nc", pop_layout_rural="resources/pop_layout{year}_rural.nc",
regions_onshore=pypsaeur("resources/regions_onshore_{network}_s{simpl}_{clusters}.geojson") regions_onshore=pypsaeur("resources/regions_onshore_elec{year}_s{simpl}_{clusters}.geojson")
output: output:
solar_thermal_total="resources/solar_thermal_total_{network}_s{simpl}_{clusters}.nc", solar_thermal_total="resources/solar_thermal_total_elec{year}_s{simpl}_{clusters}.nc",
solar_thermal_urban="resources/solar_thermal_urban_{network}_s{simpl}_{clusters}.nc", solar_thermal_urban="resources/solar_thermal_urban_elec{year}_s{simpl}_{clusters}.nc",
solar_thermal_rural="resources/solar_thermal_rural_{network}_s{simpl}_{clusters}.nc" solar_thermal_rural="resources/solar_thermal_rural_elec{year}_s{simpl}_{clusters}.nc"
resources: mem_mb=20000 resources: mem_mb=20000
script: "scripts/build_solar_thermal_profiles.py" script: "scripts/build_solar_thermal_profiles.py"
@ -204,12 +204,12 @@ rule build_industrial_production_per_country_tomorrow:
rule build_industrial_distribution_key: rule build_industrial_distribution_key:
input: input:
clustered_pop_layout="resources/pop_layout_{network}_s{simpl}_{clusters}.csv", clustered_pop_layout="resources/pop_layout_elec{year}_s{simpl}_{clusters}.csv",
europe_shape=pypsaeur('resources/europe_shape.geojson'), europe_shape=pypsaeur('resources/europe_shape.geojson'),
hotmaps_industrial_database="data/Industrial_Database.csv", hotmaps_industrial_database="data/Industrial_Database.csv",
network=pypsaeur('networks/{network}_s{simpl}_{clusters}.nc') network=pypsaeur('networks/elec{year}_s{simpl}_{clusters}.nc')
output: output:
industrial_distribution_key="resources/industrial_distribution_key_{network}_s{simpl}_{clusters}.csv" industrial_distribution_key="resources/industrial_distribution_key_elec{year}_s{simpl}_{clusters}.csv"
threads: 1 threads: 1
resources: mem_mb=1000 resources: mem_mb=1000
script: 'scripts/build_industrial_distribution_key.py' script: 'scripts/build_industrial_distribution_key.py'
@ -218,10 +218,10 @@ rule build_industrial_distribution_key:
rule build_industrial_production_per_node: rule build_industrial_production_per_node:
input: input:
industrial_distribution_key="resources/industrial_distribution_key_{network}_s{simpl}_{clusters}.csv", industrial_distribution_key="resources/industrial_distribution_key_elec{year}_s{simpl}_{clusters}.csv",
industrial_production_per_country_tomorrow="resources/industrial_production_per_country_tomorrow.csv" industrial_production_per_country_tomorrow="resources/industrial_production_per_country_tomorrow.csv"
output: output:
industrial_production_per_node="resources/industrial_production_{network}_s{simpl}_{clusters}.csv" industrial_production_per_node="resources/industrial_production_elec{year}_s{simpl}_{clusters}.csv"
threads: 1 threads: 1
resources: mem_mb=1000 resources: mem_mb=1000
script: 'scripts/build_industrial_production_per_node.py' script: 'scripts/build_industrial_production_per_node.py'
@ -230,10 +230,10 @@ rule build_industrial_production_per_node:
rule build_industrial_energy_demand_per_node: rule build_industrial_energy_demand_per_node:
input: input:
industry_sector_ratios="resources/industry_sector_ratios.csv", industry_sector_ratios="resources/industry_sector_ratios.csv",
industrial_production_per_node="resources/industrial_production_{network}_s{simpl}_{clusters}.csv", industrial_production_per_node="resources/industrial_production_elec{year}_s{simpl}_{clusters}.csv",
industrial_energy_demand_per_node_today="resources/industrial_energy_demand_today_{network}_s{simpl}_{clusters}.csv" industrial_energy_demand_per_node_today="resources/industrial_energy_demand_today_elec{year}_s{simpl}_{clusters}.csv"
output: output:
industrial_energy_demand_per_node="resources/industrial_energy_demand_{network}_s{simpl}_{clusters}.csv" industrial_energy_demand_per_node="resources/industrial_energy_demand_elec{year}_s{simpl}_{clusters}.csv"
threads: 1 threads: 1
resources: mem_mb=1000 resources: mem_mb=1000
script: 'scripts/build_industrial_energy_demand_per_node.py' script: 'scripts/build_industrial_energy_demand_per_node.py'
@ -252,10 +252,10 @@ rule build_industrial_energy_demand_per_country_today:
rule build_industrial_energy_demand_per_node_today: rule build_industrial_energy_demand_per_node_today:
input: input:
industrial_distribution_key="resources/industrial_distribution_key_{network}_s{simpl}_{clusters}.csv", industrial_distribution_key="resources/industrial_distribution_key_elec{year}_s{simpl}_{clusters}.csv",
industrial_energy_demand_per_country_today="resources/industrial_energy_demand_per_country_today.csv" industrial_energy_demand_per_country_today="resources/industrial_energy_demand_per_country_today.csv"
output: output:
industrial_energy_demand_per_node_today="resources/industrial_energy_demand_today_{network}_s{simpl}_{clusters}.csv" industrial_energy_demand_per_node_today="resources/industrial_energy_demand_today_elec{year}_s{simpl}_{clusters}.csv"
threads: 1 threads: 1
resources: mem_mb=1000 resources: mem_mb=1000
script: 'scripts/build_industrial_energy_demand_per_node_today.py' script: 'scripts/build_industrial_energy_demand_per_node_today.py'
@ -275,10 +275,10 @@ rule build_industrial_energy_demand_per_country:
rule build_industrial_demand: rule build_industrial_demand:
input: input:
clustered_pop_layout="resources/pop_layout_{network}_s{simpl}_{clusters}.csv", clustered_pop_layout="resources/pop_layout_elec{year}_s{simpl}_{clusters}.csv",
industrial_demand_per_country="resources/industrial_energy_demand_per_country.csv" industrial_demand_per_country="resources/industrial_energy_demand_per_country.csv"
output: output:
industrial_demand="resources/industrial_demand_{network}_s{simpl}_{clusters}.csv" industrial_demand="resources/industrial_demand_elec{year}_s{simpl}_{clusters}.csv"
threads: 1 threads: 1
resources: mem_mb=1000 resources: mem_mb=1000
script: 'scripts/build_industrial_demand.py' script: 'scripts/build_industrial_demand.py'
@ -286,7 +286,7 @@ rule build_industrial_demand:
rule prepare_sector_network: rule prepare_sector_network:
input: input:
network=pypsaeur('networks/{network}_s{simpl}_{clusters}_ec_lv{lv}_{opts}.nc'), network=pypsaeur('networks/elec{year}_s{simpl}_{clusters}_ec_lv{lv}_{opts}.nc'),
energy_totals_name='resources/energy_totals.csv', energy_totals_name='resources/energy_totals.csv',
co2_totals_name='resources/co2_totals.csv', co2_totals_name='resources/co2_totals.csv',
transport_name='resources/transport_data.csv', transport_name='resources/transport_data.csv',
@ -296,45 +296,45 @@ rule prepare_sector_network:
costs=config['costs_dir'] + "costs_{planning_horizons}.csv", costs=config['costs_dir'] + "costs_{planning_horizons}.csv",
h2_cavern = "data/hydrogen_salt_cavern_potentials.csv", h2_cavern = "data/hydrogen_salt_cavern_potentials.csv",
co2_budget="data/co2_budget.csv", co2_budget="data/co2_budget.csv",
profile_offwind_ac=pypsaeur("resources/profile_offwind-ac.nc"), profile_offwind_ac=pypsaeur("resources/profile{year}_offwind-ac.nc"),
profile_offwind_dc=pypsaeur("resources/profile_offwind-dc.nc"), profile_offwind_dc=pypsaeur("resources/profile{year}_offwind-dc.nc"),
busmap_s=pypsaeur("resources/busmap_{network}_s{simpl}.csv"), busmap_s=pypsaeur("resources/busmap_elec{year}_s{simpl}.csv"),
busmap=pypsaeur("resources/busmap_{network}_s{simpl}_{clusters}.csv"), busmap=pypsaeur("resources/busmap_elec{year}_s{simpl}_{clusters}.csv"),
clustered_pop_layout="resources/pop_layout_{network}_s{simpl}_{clusters}.csv", clustered_pop_layout="resources/pop_layout_elec{year}_s{simpl}_{clusters}.csv",
simplified_pop_layout="resources/pop_layout_{network}_s{simpl}.csv", simplified_pop_layout="resources/pop_layout_elec{year}_s{simpl}.csv",
industrial_demand="resources/industrial_energy_demand_{network}_s{simpl}_{clusters}.csv", industrial_demand="resources/industrial_energy_demand_elec{year}_s{simpl}_{clusters}.csv",
heat_demand_urban="resources/heat_demand_urban_{network}_s{simpl}_{clusters}.nc", heat_demand_urban="resources/heat_demand_urban_elec{year}_s{simpl}_{clusters}.nc",
heat_demand_rural="resources/heat_demand_rural_{network}_s{simpl}_{clusters}.nc", heat_demand_rural="resources/heat_demand_rural_elec{year}_s{simpl}_{clusters}.nc",
heat_demand_total="resources/heat_demand_total_{network}_s{simpl}_{clusters}.nc", heat_demand_total="resources/heat_demand_total_elec{year}_s{simpl}_{clusters}.nc",
temp_soil_total="resources/temp_soil_total_{network}_s{simpl}_{clusters}.nc", temp_soil_total="resources/temp_soil_total_elec{year}_s{simpl}_{clusters}.nc",
temp_soil_rural="resources/temp_soil_rural_{network}_s{simpl}_{clusters}.nc", temp_soil_rural="resources/temp_soil_rural_elec{year}_s{simpl}_{clusters}.nc",
temp_soil_urban="resources/temp_soil_urban_{network}_s{simpl}_{clusters}.nc", temp_soil_urban="resources/temp_soil_urban_elec{year}_s{simpl}_{clusters}.nc",
temp_air_total="resources/temp_air_total_{network}_s{simpl}_{clusters}.nc", temp_air_total="resources/temp_air_total_elec{year}_s{simpl}_{clusters}.nc",
temp_air_rural="resources/temp_air_rural_{network}_s{simpl}_{clusters}.nc", temp_air_rural="resources/temp_air_rural_elec{year}_s{simpl}_{clusters}.nc",
temp_air_urban="resources/temp_air_urban_{network}_s{simpl}_{clusters}.nc", temp_air_urban="resources/temp_air_urban_elec{year}_s{simpl}_{clusters}.nc",
cop_soil_total="resources/cop_soil_total_{network}_s{simpl}_{clusters}.nc", cop_soil_total="resources/cop_soil_total_elec{year}_s{simpl}_{clusters}.nc",
cop_soil_rural="resources/cop_soil_rural_{network}_s{simpl}_{clusters}.nc", cop_soil_rural="resources/cop_soil_rural_elec{year}_s{simpl}_{clusters}.nc",
cop_soil_urban="resources/cop_soil_urban_{network}_s{simpl}_{clusters}.nc", cop_soil_urban="resources/cop_soil_urban_elec{year}_s{simpl}_{clusters}.nc",
cop_air_total="resources/cop_air_total_{network}_s{simpl}_{clusters}.nc", cop_air_total="resources/cop_air_total_elec{year}_s{simpl}_{clusters}.nc",
cop_air_rural="resources/cop_air_rural_{network}_s{simpl}_{clusters}.nc", cop_air_rural="resources/cop_air_rural_elec{year}_s{simpl}_{clusters}.nc",
cop_air_urban="resources/cop_air_urban_{network}_s{simpl}_{clusters}.nc", cop_air_urban="resources/cop_air_urban_elec{year}_s{simpl}_{clusters}.nc",
solar_thermal_total="resources/solar_thermal_total_{network}_s{simpl}_{clusters}.nc", solar_thermal_total="resources/solar_thermal_total_elec{year}_s{simpl}_{clusters}.nc",
solar_thermal_urban="resources/solar_thermal_urban_{network}_s{simpl}_{clusters}.nc", solar_thermal_urban="resources/solar_thermal_urban_elec{year}_s{simpl}_{clusters}.nc",
solar_thermal_rural="resources/solar_thermal_rural_{network}_s{simpl}_{clusters}.nc" solar_thermal_rural="resources/solar_thermal_rural_elec{year}_s{simpl}_{clusters}.nc"
output: config['results_dir'] + config['run'] + '/prenetworks/{network}_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}_{co2_budget_name}_{planning_horizons}.nc' output: config['results_dir'] + config['run'] + '/prenetworks/elec{year}_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}_{co2_budget_name}_{planning_horizons}.nc'
threads: 1 threads: 1
resources: mem_mb=2000 resources: mem_mb=2000
benchmark: config['results_dir'] + config['run'] + "/benchmarks/prepare_network/{network}_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}_{co2_budget_name}_{planning_horizons}" benchmark: config['results_dir'] + config['run'] + "/benchmarks/prepare_network/elec{year}_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}_{co2_budget_name}_{planning_horizons}"
script: "scripts/prepare_sector_network.py" script: "scripts/prepare_sector_network.py"
rule plot_network: rule plot_network:
input: input:
network=config['results_dir'] + config['run'] + "/postnetworks/elec_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}_{co2_budget_name}_{planning_horizons}.nc" network=config['results_dir'] + config['run'] + "/postnetworks/elec{year}_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}_{co2_budget_name}_{planning_horizons}.nc"
output: output:
map=config['results_dir'] + config['run'] + "/maps/elec_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}-costs-all_{co2_budget_name}_{planning_horizons}.pdf", map=config['results_dir'] + config['run'] + "/maps/elec{year}_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}-costs-all_{co2_budget_name}_{planning_horizons}.pdf",
today=config['results_dir'] + config['run'] + "/maps/elec_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}_{co2_budget_name}_{planning_horizons}-today.pdf" today=config['results_dir'] + config['run'] + "/maps/elec{year}_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}_{co2_budget_name}_{planning_horizons}-today.pdf"
threads: 2 threads: 2
resources: mem_mb=10000 resources: mem_mb=10000
script: "scripts/plot_network.py" script: "scripts/plot_network.py"
@ -351,10 +351,10 @@ rule copy_config:
rule make_summary: rule make_summary:
input: input:
networks=expand(config['results_dir'] + config['run'] + "/postnetworks/elec_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}_{co2_budget_name}_{planning_horizons}.nc", networks=expand(config['results_dir'] + config['run'] + "/postnetworks/elec{year}_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}_{co2_budget_name}_{planning_horizons}.nc",
**config['scenario']), **config['scenario']),
costs=config['costs_dir'] + "costs_{}.csv".format(config['scenario']['planning_horizons'][0]), costs=config['costs_dir'] + "costs_{}.csv".format(config['scenario']['planning_horizons'][0]),
plots=expand(config['results_dir'] + config['run'] + "/maps/elec_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}-costs-all_{co2_budget_name}_{planning_horizons}.pdf", plots=expand(config['results_dir'] + config['run'] + "/maps/elec{year}_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}-costs-all_{co2_budget_name}_{planning_horizons}.pdf",
**config['scenario']) **config['scenario'])
#heat_demand_name='data/heating/daily_heat_demand.h5' #heat_demand_name='data/heating/daily_heat_demand.h5'
output: output:
@ -397,16 +397,16 @@ if config["foresight"] == "overnight":
rule solve_network: rule solve_network:
input: input:
network=config['results_dir'] + config['run'] + "/prenetworks/{network}_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}_{co2_budget_name}_{planning_horizons}.nc", network=config['results_dir'] + config['run'] + "/prenetworks/elec{year}_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}_{co2_budget_name}_{planning_horizons}.nc",
costs=config['costs_dir'] + "costs_{planning_horizons}.csv", costs=config['costs_dir'] + "costs_{planning_horizons}.csv",
config=config['summary_dir'] + '/' + config['run'] + '/configs/config.yaml' config=config['summary_dir'] + '/' + config['run'] + '/configs/config.yaml'
output: config['results_dir'] + config['run'] + "/postnetworks/{network}_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}_{co2_budget_name}_{planning_horizons}.nc" output: config['results_dir'] + config['run'] + "/postnetworks/elec{year}_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}_{co2_budget_name}_{planning_horizons}.nc"
shadow: "shallow" shadow: "shallow"
log: log:
solver=config['results_dir'] + config['run'] + "/logs/{network}_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}_{co2_budget_name}_{planning_horizons}_solver.log", solver=config['results_dir'] + config['run'] + "/logs/elec{year}_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}_{co2_budget_name}_{planning_horizons}_solver.log",
python=config['results_dir'] + config['run'] + "/logs/{network}_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}_{co2_budget_name}_{planning_horizons}_python.log", python=config['results_dir'] + config['run'] + "/logs/elec{year}_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}_{co2_budget_name}_{planning_horizons}_python.log",
memory=config['results_dir'] + config['run'] + "/logs/{network}_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}_{co2_budget_name}_{planning_horizons}_memory.log" memory=config['results_dir'] + config['run'] + "/logs/elec{year}_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}_{co2_budget_name}_{planning_horizons}_memory.log"
benchmark: config['results_dir'] + config['run'] + "/benchmarks/solve_network/{network}_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}_{co2_budget_name}_{planning_horizons}" benchmark: config['results_dir'] + config['run'] + "/benchmarks/solve_network/elec{year}_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}_{co2_budget_name}_{planning_horizons}"
threads: 4 threads: 4
resources: mem_mb=config['solving']['mem'] resources: mem_mb=config['solving']['mem']
# group: "solve" # with group, threads is ignored https://bitbucket.org/snakemake/snakemake/issues/971/group-job-description-does-not-contain # group: "solve" # with group, threads is ignored https://bitbucket.org/snakemake/snakemake/issues/971/group-job-description-does-not-contain
@ -417,15 +417,15 @@ if config["foresight"] == "myopic":
rule add_existing_baseyear: rule add_existing_baseyear:
input: input:
network=config['results_dir'] + config['run'] + '/prenetworks/{network}_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}_{co2_budget_name}_{planning_horizons}.nc', network=config['results_dir'] + config['run'] + '/prenetworks/elec{year}_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}_{co2_budget_name}_{planning_horizons}.nc',
powerplants=pypsaeur('resources/powerplants.csv'), powerplants=pypsaeur('resources/powerplants.csv'),
busmap_s=pypsaeur("resources/busmap_{network}_s{simpl}.csv"), busmap_s=pypsaeur("resources/busmap_elec{year}_s{simpl}.csv"),
busmap=pypsaeur("resources/busmap_{network}_s{simpl}_{clusters}.csv"), busmap=pypsaeur("resources/busmap_elec{year}_s{simpl}_{clusters}.csv"),
clustered_pop_layout="resources/pop_layout_{network}_s{simpl}_{clusters}.csv", clustered_pop_layout="resources/pop_layout_elec{year}_s{simpl}_{clusters}.csv",
costs=config['costs_dir'] + "costs_{}.csv".format(config['scenario']['planning_horizons'][0]), costs=config['costs_dir'] + "costs_{}.csv".format(config['scenario']['planning_horizons'][0]),
cop_soil_total="resources/cop_soil_total_{network}_s{simpl}_{clusters}.nc", cop_soil_total="resources/cop_soil_total_elec{year}_s{simpl}_{clusters}.nc",
cop_air_total="resources/cop_air_total_{network}_s{simpl}_{clusters}.nc" cop_air_total="resources/cop_air_total_elec{year}_s{simpl}_{clusters}.nc"
output: config['results_dir'] + config['run'] + '/prenetworks-brownfield/{network}_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}_{co2_budget_name}_{planning_horizons}.nc' output: config['results_dir'] + config['run'] + '/prenetworks-brownfield/elec{year}_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}_{co2_budget_name}_{planning_horizons}.nc'
wildcard_constraints: wildcard_constraints:
planning_horizons=config['scenario']['planning_horizons'][0] #only applies to baseyear planning_horizons=config['scenario']['planning_horizons'][0] #only applies to baseyear
threads: 1 threads: 1
@ -434,18 +434,18 @@ if config["foresight"] == "myopic":
def process_input(wildcards): def process_input(wildcards):
i = config["scenario"]["planning_horizons"].index(int(wildcards.planning_horizons)) i = config["scenario"]["planning_horizons"].index(int(wildcards.planning_horizons))
return config['results_dir'] + config['run'] + "/postnetworks/{network}_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}_{co2_budget_name}_" + str(config["scenario"]["planning_horizons"][i-1]) + ".nc" return config['results_dir'] + config['run'] + "/postnetworks/elec{year}_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}_{co2_budget_name}_" + str(config["scenario"]["planning_horizons"][i-1]) + ".nc"
rule add_brownfield: rule add_brownfield:
input: input:
network=config['results_dir'] + config['run'] + '/prenetworks/{network}_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}_{co2_budget_name}_{planning_horizons}.nc', network=config['results_dir'] + config['run'] + '/prenetworks/elec{year}_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}_{co2_budget_name}_{planning_horizons}.nc',
network_p=process_input, #solved network at previous time step network_p=process_input, #solved network at previous time step
costs=config['costs_dir'] + "costs_{planning_horizons}.csv", costs=config['costs_dir'] + "costs_{planning_horizons}.csv",
cop_soil_total="resources/cop_soil_total_{network}_s{simpl}_{clusters}.nc", cop_soil_total="resources/cop_soil_total_elec{year}_s{simpl}_{clusters}.nc",
cop_air_total="resources/cop_air_total_{network}_s{simpl}_{clusters}.nc" cop_air_total="resources/cop_air_total_elec{year}_s{simpl}_{clusters}.nc"
output: config['results_dir'] + config['run'] + "/prenetworks-brownfield/{network}_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}_{co2_budget_name}_{planning_horizons}.nc" output: config['results_dir'] + config['run'] + "/prenetworks-brownfield/elec{year}_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}_{co2_budget_name}_{planning_horizons}.nc"
threads: 4 threads: 4
resources: mem_mb=2000 resources: mem_mb=2000
script: "scripts/add_brownfield.py" script: "scripts/add_brownfield.py"
@ -454,16 +454,16 @@ if config["foresight"] == "myopic":
rule solve_network_myopic: rule solve_network_myopic:
input: input:
network=config['results_dir'] + config['run'] + "/prenetworks-brownfield/{network}_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}_{co2_budget_name}_{planning_horizons}.nc", network=config['results_dir'] + config['run'] + "/prenetworks-brownfield/elec{year}_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}_{co2_budget_name}_{planning_horizons}.nc",
costs=config['costs_dir'] + "costs_{planning_horizons}.csv", costs=config['costs_dir'] + "costs_{planning_horizons}.csv",
config=config['summary_dir'] + '/' + config['run'] + '/configs/config.yaml' config=config['summary_dir'] + '/' + config['run'] + '/configs/config.yaml'
output: config['results_dir'] + config['run'] + "/postnetworks/{network}_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}_{co2_budget_name}_{planning_horizons}.nc" output: config['results_dir'] + config['run'] + "/postnetworks/elec{year}_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}_{co2_budget_name}_{planning_horizons}.nc"
shadow: "shallow" shadow: "shallow"
log: log:
solver=config['results_dir'] + config['run'] + "/logs/{network}_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}_{co2_budget_name}_{planning_horizons}_solver.log", solver=config['results_dir'] + config['run'] + "/logs/elec{year}_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}_{co2_budget_name}_{planning_horizons}_solver.log",
python=config['results_dir'] + config['run'] + "/logs/{network}_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}_{co2_budget_name}_{planning_horizons}_python.log", python=config['results_dir'] + config['run'] + "/logs/elec{year}_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}_{co2_budget_name}_{planning_horizons}_python.log",
memory=config['results_dir'] + config['run'] + "/logs/{network}_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}_{co2_budget_name}_{planning_horizons}_memory.log" memory=config['results_dir'] + config['run'] + "/logs/elec{year}_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}_{co2_budget_name}_{planning_horizons}_memory.log"
benchmark: config['results_dir'] + config['run'] + "/benchmarks/solve_network/{network}_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}_{co2_budget_name}_{planning_horizons}" benchmark: config['results_dir'] + config['run'] + "/benchmarks/solve_network/elec{year}_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}_{co2_budget_name}_{planning_horizons}"
threads: 4 threads: 4
resources: mem_mb=config['solving']['mem'] resources: mem_mb=config['solving']['mem']
script: "scripts/solve_network.py" script: "scripts/solve_network.py"

View File

@ -5,8 +5,11 @@ import pandas as pd
import atlite import atlite
import helper import helper
year = snakemake.wildcards.year
cutout_name = snakemake.config['atlite']['cutout_name']
if year: cutout_name = cutout_name.format(year=year)
cutout = atlite.Cutout(snakemake.config['atlite']['cutout_name'], cutout = atlite.Cutout(cutout_name,
cutout_dir=snakemake.config['atlite']['cutout_dir']) cutout_dir=snakemake.config['atlite']['cutout_dir'])

View File

@ -15,10 +15,16 @@ if 'snakemake' not in globals():
snakemake.input = Dict() snakemake.input = Dict()
snakemake.output = Dict() snakemake.output = Dict()
time = pd.date_range(freq='m', **snakemake.config['snapshots']) year = snakemake.wildcards.year
snapshots = dict(start=year, end=str(int(year)+1), closed="left") if year else snakemake.config['snapshots']
time = pd.date_range(freq='m', **snapshots)
params = dict(years=slice(*time.year[[0, -1]]), months=slice(*time.month[[0, -1]])) params = dict(years=slice(*time.year[[0, -1]]), months=slice(*time.month[[0, -1]]))
cutout = atlite.Cutout(snakemake.config['atlite']['cutout_name'], cutout_name = snakemake.config['atlite']['cutout_name']
if year: cutout_name = cutout_name.format(year=year)
cutout = atlite.Cutout(cutout_name,
cutout_dir=snakemake.config['atlite']['cutout_dir'], cutout_dir=snakemake.config['atlite']['cutout_dir'],
**params) **params)

View File

@ -21,7 +21,11 @@ if 'snakemake' not in globals():
snakemake.input["urban_percent"] = "data/urban_percent.csv" snakemake.input["urban_percent"] = "data/urban_percent.csv"
cutout = atlite.Cutout(snakemake.config['atlite']['cutout_name'], year = snakemake.wildcards.year
cutout_name = snakemake.config['atlite']['cutout_name']
if year: cutout_name = cutout_name.format(year=year)
cutout = atlite.Cutout(cutout_name,
cutout_dir=snakemake.config['atlite']['cutout_dir']) cutout_dir=snakemake.config['atlite']['cutout_dir'])
grid_cells = cutout.grid_cells() grid_cells = cutout.grid_cells()

View File

@ -15,12 +15,17 @@ if 'snakemake' not in globals():
snakemake.input = Dict() snakemake.input = Dict()
snakemake.output = Dict() snakemake.output = Dict()
time = pd.date_range(freq='m', **snakemake.config['snapshots']) year = snakemake.wildcards.year
snapshots = dict(start=year, end=str(int(year)+1), closed="left") if year else snakemake.config['snapshots']
time = pd.date_range(freq='m', **snapshots)
params = dict(years=slice(*time.year[[0, -1]]), months=slice(*time.month[[0, -1]])) params = dict(years=slice(*time.year[[0, -1]]), months=slice(*time.month[[0, -1]]))
cutout_name = snakemake.config['atlite']['cutout_name']
if year: cutout_name = cutout_name.format(year=year)
cutout = atlite.Cutout(snakemake.config['atlite']['cutout_name'], cutout = atlite.Cutout(cutout_name,
cutout_dir=snakemake.config['atlite']['cutout_dir'], cutout_dir=snakemake.config['atlite']['cutout_dir'],
**params) **params)

View File

@ -15,11 +15,16 @@ if 'snakemake' not in globals():
snakemake.input = Dict() snakemake.input = Dict()
snakemake.output = Dict() snakemake.output = Dict()
time = pd.date_range(freq='m', **snakemake.config['snapshots']) year = snakemake.wildcards.year
snapshots = dict(start=year, end=str(int(year)+1), closed="left") if year else snakemake.config['snapshots']
time = pd.date_range(freq='m', **snapshots)
params = dict(years=slice(*time.year[[0, -1]]), months=slice(*time.month[[0, -1]])) params = dict(years=slice(*time.year[[0, -1]]), months=slice(*time.month[[0, -1]]))
cutout_name = snakemake.config['atlite']['cutout_name']
if year: cutout_name = cutout_name.format(year=year)
cutout = atlite.Cutout(snakemake.config['atlite']['cutout_name'], cutout = atlite.Cutout(cutout_name,
cutout_dir=snakemake.config['atlite']['cutout_dir'], cutout_dir=snakemake.config['atlite']['cutout_dir'],
**params) **params)