2017-12-18 19:34:15 +00:00
|
|
|
configfile: "config.yaml"
|
|
|
|
|
|
|
|
wildcard_constraints:
|
2018-09-24 16:33:04 +00:00
|
|
|
lv="[0-9\.]+|inf",
|
2018-01-30 22:11:16 +00:00
|
|
|
simpl="[a-zA-Z0-9]*",
|
2018-02-19 09:03:25 +00:00
|
|
|
clusters="[0-9]+m?",
|
2017-12-18 19:34:15 +00:00
|
|
|
sectors="[+a-zA-Z0-9]+",
|
2018-07-10 13:57:51 +00:00
|
|
|
opts="[-+a-zA-Z0-9]*"
|
2017-12-18 19:34:15 +00:00
|
|
|
|
2018-10-22 21:27:18 +00:00
|
|
|
rule cluster_all_elec_networks:
|
|
|
|
input:
|
|
|
|
expand("networks/elec_s{simpl}_{clusters}_lv{lv}_{opts}.nc",
|
|
|
|
**config['scenario'])
|
2017-12-18 19:34:15 +00:00
|
|
|
|
2018-01-30 22:48:29 +00:00
|
|
|
rule solve_all_elec_networks:
|
|
|
|
input:
|
|
|
|
expand("results/networks/elec_s{simpl}_{clusters}_lv{lv}_{opts}.nc",
|
2018-02-10 16:19:46 +00:00
|
|
|
**config['scenario'])
|
2018-01-30 22:48:29 +00:00
|
|
|
|
2018-08-13 12:09:20 +00:00
|
|
|
if config['enable']['prepare_links_p_nom']:
|
|
|
|
rule prepare_links_p_nom:
|
|
|
|
output: 'data/links_p_nom.csv'
|
|
|
|
threads: 1
|
2018-09-20 12:26:38 +00:00
|
|
|
resources: mem=500
|
2018-09-03 22:23:43 +00:00
|
|
|
group: 'nonfeedin_preparation'
|
2018-08-13 12:09:20 +00:00
|
|
|
script: 'scripts/prepare_links_p_nom.py'
|
|
|
|
|
|
|
|
if config['enable']['powerplantmatching']:
|
|
|
|
rule build_powerplants:
|
|
|
|
input: base_network="networks/base.nc"
|
|
|
|
output: "resources/powerplants.csv"
|
|
|
|
threads: 1
|
2018-09-20 12:26:38 +00:00
|
|
|
resources: mem=500
|
2018-09-03 22:23:43 +00:00
|
|
|
group: 'nonfeedin_preparation'
|
2018-08-13 12:09:20 +00:00
|
|
|
script: "scripts/build_powerplants.py"
|
2017-12-18 19:34:15 +00:00
|
|
|
|
|
|
|
rule base_network:
|
|
|
|
input:
|
|
|
|
eg_buses='data/entsoegridkit/buses.csv',
|
|
|
|
eg_lines='data/entsoegridkit/lines.csv',
|
|
|
|
eg_links='data/entsoegridkit/links.csv',
|
|
|
|
eg_converters='data/entsoegridkit/converters.csv',
|
|
|
|
eg_transformers='data/entsoegridkit/transformers.csv',
|
|
|
|
parameter_corrections='data/parameter_corrections.yaml',
|
2018-08-03 09:49:23 +00:00
|
|
|
links_p_nom='data/links_p_nom.csv',
|
2018-09-24 18:19:47 +00:00
|
|
|
links_tyndp='data/links_tyndp.csv',
|
2018-08-03 09:49:23 +00:00
|
|
|
country_shapes='resources/country_shapes.geojson',
|
|
|
|
offshore_shapes='resources/offshore_shapes.geojson',
|
|
|
|
europe_shape='resources/europe_shape.geojson'
|
2018-01-29 21:28:33 +00:00
|
|
|
output: "networks/base.nc"
|
|
|
|
benchmark: "benchmarks/base_network"
|
2017-12-18 19:34:15 +00:00
|
|
|
threads: 1
|
2018-09-20 12:26:38 +00:00
|
|
|
resources: mem=500
|
2018-09-03 22:23:43 +00:00
|
|
|
group: 'nonfeedin_preparation'
|
2017-12-18 19:34:15 +00:00
|
|
|
script: "scripts/base_network.py"
|
|
|
|
|
2018-08-03 09:49:23 +00:00
|
|
|
rule build_shapes:
|
|
|
|
input:
|
|
|
|
naturalearth='data/bundle/naturalearth/ne_10m_admin_0_countries.shp',
|
|
|
|
eez='data/bundle/eez/World_EEZ_v8_2014.shp',
|
|
|
|
nuts3='data/bundle/NUTS_2013_60M_SH/data/NUTS_RG_60M_2013.shp',
|
|
|
|
nuts3pop='data/bundle/nama_10r_3popgdp.tsv.gz',
|
|
|
|
nuts3gdp='data/bundle/nama_10r_3gdp.tsv.gz',
|
|
|
|
ch_cantons='data/bundle/ch_cantons.csv',
|
|
|
|
ch_popgdp='data/bundle/je-e-21.03.02.xls'
|
|
|
|
output:
|
|
|
|
country_shapes='resources/country_shapes.geojson',
|
|
|
|
offshore_shapes='resources/offshore_shapes.geojson',
|
|
|
|
europe_shape='resources/europe_shape.geojson',
|
|
|
|
nuts3_shapes='resources/nuts3_shapes.geojson'
|
|
|
|
threads: 1
|
2018-09-20 12:26:38 +00:00
|
|
|
resources: mem=500
|
2018-09-03 22:23:43 +00:00
|
|
|
group: 'nonfeedin_preparation'
|
2018-08-03 09:49:23 +00:00
|
|
|
script: "scripts/build_shapes.py"
|
|
|
|
|
2018-01-29 21:28:33 +00:00
|
|
|
rule build_bus_regions:
|
2017-12-18 19:34:15 +00:00
|
|
|
input:
|
2018-08-03 09:49:23 +00:00
|
|
|
country_shapes='resources/country_shapes.geojson',
|
|
|
|
offshore_shapes='resources/offshore_shapes.geojson',
|
2018-01-29 21:28:33 +00:00
|
|
|
base_network="networks/base.nc"
|
|
|
|
output:
|
|
|
|
regions_onshore="resources/regions_onshore.geojson",
|
|
|
|
regions_offshore="resources/regions_offshore.geojson"
|
2018-09-20 12:26:38 +00:00
|
|
|
resources: mem=1000
|
2018-09-03 22:23:43 +00:00
|
|
|
group: 'nonfeedin_preparation'
|
2018-01-29 21:28:33 +00:00
|
|
|
script: "scripts/build_bus_regions.py"
|
|
|
|
|
2018-08-03 09:54:28 +00:00
|
|
|
rule build_cutout:
|
|
|
|
output: "cutouts/{cutout}"
|
2018-09-20 12:26:38 +00:00
|
|
|
resources: mem=5000
|
2018-08-03 09:54:28 +00:00
|
|
|
threads: config['atlite'].get('nprocesses', 4)
|
|
|
|
benchmark: "benchmarks/build_cutout_{cutout}"
|
2018-09-03 22:23:43 +00:00
|
|
|
group: 'feedin_preparation'
|
2018-08-03 09:54:28 +00:00
|
|
|
script: "scripts/build_cutout.py"
|
|
|
|
|
2018-09-24 16:26:31 +00:00
|
|
|
def memory_build_renewable_potentials(wildcards):
|
|
|
|
corine_config = config["renewable"][wildcards.technology]["corine"]
|
|
|
|
return 12000 if corine_config.get("distance") is None else 24000
|
|
|
|
|
2018-01-29 21:28:33 +00:00
|
|
|
rule build_renewable_potentials:
|
2018-08-03 09:53:14 +00:00
|
|
|
input:
|
2018-08-03 09:54:28 +00:00
|
|
|
cutout=lambda wildcards: "cutouts/" + config["renewable"][wildcards.technology]['cutout'],
|
2018-08-03 09:53:14 +00:00
|
|
|
corine="data/bundle/corine/g250_clc06_V18_5.tif",
|
|
|
|
natura="data/bundle/natura/Natura2000_end2015.shp"
|
2018-01-29 21:28:33 +00:00
|
|
|
output: "resources/potentials_{technology}.nc"
|
2018-09-24 16:26:31 +00:00
|
|
|
resources: mem=memory_build_renewable_potentials
|
2018-03-14 10:48:14 +00:00
|
|
|
benchmark: "benchmarks/build_renewable_potentials_{technology}"
|
2018-09-03 22:23:43 +00:00
|
|
|
group: 'feedin_preparation'
|
2018-03-14 10:48:14 +00:00
|
|
|
script: "scripts/build_renewable_potentials.py"
|
2017-12-18 19:34:15 +00:00
|
|
|
|
2018-01-29 21:28:33 +00:00
|
|
|
rule build_renewable_profiles:
|
2017-12-18 19:34:15 +00:00
|
|
|
input:
|
2018-01-29 21:28:33 +00:00
|
|
|
base_network="networks/base.nc",
|
|
|
|
potentials="resources/potentials_{technology}.nc",
|
|
|
|
regions=lambda wildcards: ("resources/regions_onshore.geojson"
|
|
|
|
if wildcards.technology in ('onwind', 'solar')
|
2018-08-03 09:54:28 +00:00
|
|
|
else "resources/regions_offshore.geojson"),
|
2018-08-06 19:38:36 +00:00
|
|
|
cutout=lambda wildcards: "cutouts/" + config["renewable"][wildcards.technology]['cutout']
|
2017-12-18 19:34:15 +00:00
|
|
|
output:
|
2018-01-29 21:28:33 +00:00
|
|
|
profile="resources/profile_{technology}.nc",
|
2018-09-20 12:26:38 +00:00
|
|
|
resources: mem=5000
|
2018-02-19 09:16:29 +00:00
|
|
|
benchmark: "benchmarks/build_renewable_profiles_{technology}"
|
2018-09-03 22:23:43 +00:00
|
|
|
group: 'feedin_preparation'
|
2018-01-29 21:28:33 +00:00
|
|
|
script: "scripts/build_renewable_profiles.py"
|
2017-12-18 19:34:15 +00:00
|
|
|
|
2018-01-29 21:28:33 +00:00
|
|
|
rule build_hydro_profile:
|
2018-08-03 09:53:14 +00:00
|
|
|
input:
|
|
|
|
country_shapes='resources/country_shapes.geojson',
|
2018-08-06 19:38:36 +00:00
|
|
|
eia_hydro_generation='data/bundle/EIA_hydro_generation_2000_2014.csv',
|
|
|
|
cutout="cutouts/" + config["renewable"]['hydro']['cutout']
|
2018-01-29 21:28:33 +00:00
|
|
|
output: 'resources/profile_hydro.nc'
|
2018-09-20 12:26:38 +00:00
|
|
|
resources: mem=5000
|
2018-09-03 22:23:43 +00:00
|
|
|
group: 'feedin_preparation'
|
2018-01-29 21:28:33 +00:00
|
|
|
script: 'scripts/build_hydro_profile.py'
|
2017-12-18 19:34:15 +00:00
|
|
|
|
|
|
|
rule add_electricity:
|
|
|
|
input:
|
2018-01-29 21:28:33 +00:00
|
|
|
base_network='networks/base.nc',
|
2018-07-10 15:20:27 +00:00
|
|
|
tech_costs='data/costs.csv',
|
2018-01-29 21:28:33 +00:00
|
|
|
regions="resources/regions_onshore.geojson",
|
2018-02-10 16:16:20 +00:00
|
|
|
powerplants='resources/powerplants.csv',
|
2018-08-03 09:53:14 +00:00
|
|
|
hydro_capacities='data/bundle/hydro_capacities.csv',
|
|
|
|
opsd_load='data/bundle/time_series_60min_singleindex_filtered.csv',
|
|
|
|
nuts3_shapes='resources/nuts3_shapes.geojson',
|
2018-01-29 21:28:33 +00:00
|
|
|
**{'profile_' + t: "resources/profile_" + t + ".nc"
|
|
|
|
for t in config['renewable']}
|
|
|
|
output: "networks/elec.nc"
|
|
|
|
benchmark: "benchmarks/add_electricity"
|
2017-12-18 19:34:15 +00:00
|
|
|
threads: 1
|
2018-09-20 12:26:38 +00:00
|
|
|
resources: mem=3000
|
2018-09-03 22:23:43 +00:00
|
|
|
group: 'build_pypsa_networks'
|
2017-12-18 19:34:15 +00:00
|
|
|
script: "scripts/add_electricity.py"
|
|
|
|
|
2018-01-30 22:11:16 +00:00
|
|
|
rule simplify_network:
|
2018-01-29 21:28:33 +00:00
|
|
|
input:
|
|
|
|
network='networks/{network}.nc',
|
|
|
|
regions_onshore="resources/regions_onshore.geojson",
|
|
|
|
regions_offshore="resources/regions_offshore.geojson"
|
|
|
|
output:
|
2018-01-30 22:11:16 +00:00
|
|
|
network='networks/{network}_s{simpl}.nc',
|
|
|
|
regions_onshore="resources/regions_onshore_{network}_s{simpl}.geojson",
|
2018-07-10 14:31:57 +00:00
|
|
|
regions_offshore="resources/regions_offshore_{network}_s{simpl}.geojson",
|
|
|
|
clustermaps='resources/clustermaps_{network}_s{simpl}.h5'
|
2018-01-30 22:11:16 +00:00
|
|
|
benchmark: "benchmarks/simplify_network/{network}_s{simpl}"
|
|
|
|
threads: 1
|
2018-09-20 12:26:38 +00:00
|
|
|
resources: mem=4000
|
2018-09-03 22:23:43 +00:00
|
|
|
group: 'build_pypsa_networks'
|
2018-01-30 22:11:16 +00:00
|
|
|
script: "scripts/simplify_network.py"
|
|
|
|
|
|
|
|
rule cluster_network:
|
|
|
|
input:
|
|
|
|
network='networks/{network}_s{simpl}.nc',
|
|
|
|
regions_onshore="resources/regions_onshore_{network}_s{simpl}.geojson",
|
2018-07-10 14:31:57 +00:00
|
|
|
regions_offshore="resources/regions_offshore_{network}_s{simpl}.geojson",
|
2018-10-22 21:27:18 +00:00
|
|
|
clustermaps=ancient('resources/clustermaps_{network}_s{simpl}.h5')
|
2018-01-30 22:11:16 +00:00
|
|
|
output:
|
|
|
|
network='networks/{network}_s{simpl}_{clusters}.nc',
|
|
|
|
regions_onshore="resources/regions_onshore_{network}_s{simpl}_{clusters}.geojson",
|
2018-03-13 10:50:06 +00:00
|
|
|
regions_offshore="resources/regions_offshore_{network}_s{simpl}_{clusters}.geojson",
|
|
|
|
clustermaps='resources/clustermaps_{network}_s{simpl}_{clusters}.h5'
|
2018-01-30 22:11:16 +00:00
|
|
|
benchmark: "benchmarks/cluster_network/{network}_s{simpl}_{clusters}"
|
2018-01-29 21:28:33 +00:00
|
|
|
threads: 1
|
2018-09-20 12:26:38 +00:00
|
|
|
resources: mem=3000
|
2018-09-03 22:23:43 +00:00
|
|
|
group: 'build_pypsa_networks'
|
2018-01-29 21:28:33 +00:00
|
|
|
script: "scripts/cluster_network.py"
|
|
|
|
|
2018-07-10 15:41:59 +00:00
|
|
|
# rule add_sectors:
|
|
|
|
# input:
|
|
|
|
# network="networks/elec_{cost}_{resarea}_{opts}.nc",
|
|
|
|
# emobility="data/emobility"
|
|
|
|
# output: "networks/sector_{cost}_{resarea}_{sectors}_{opts}.nc"
|
|
|
|
# benchmark: "benchmarks/add_sectors/sector_{resarea}_{sectors}_{opts}"
|
|
|
|
# threads: 1
|
2018-09-20 12:26:38 +00:00
|
|
|
# resources: mem=1000
|
2018-07-10 15:41:59 +00:00
|
|
|
# script: "scripts/add_sectors.py"
|
2017-12-18 19:34:15 +00:00
|
|
|
|
2018-01-29 21:28:33 +00:00
|
|
|
rule prepare_network:
|
2018-10-22 21:22:34 +00:00
|
|
|
input: 'networks/{network}_s{simpl}_{clusters}.nc', tech_costs='data/costs.csv'
|
2018-01-30 22:11:16 +00:00
|
|
|
output: 'networks/{network}_s{simpl}_{clusters}_lv{lv}_{opts}.nc'
|
2018-01-29 21:28:33 +00:00
|
|
|
threads: 1
|
2018-09-20 12:26:38 +00:00
|
|
|
resources: mem=1000
|
2018-02-10 16:19:46 +00:00
|
|
|
benchmark: "benchmarks/prepare_network/{network}_s{simpl}_{clusters}_lv{lv}_{opts}"
|
2018-01-29 21:28:33 +00:00
|
|
|
script: "scripts/prepare_network.py"
|
|
|
|
|
2018-02-19 09:03:25 +00:00
|
|
|
def memory(w):
|
2018-10-22 21:28:56 +00:00
|
|
|
factor = 3.
|
|
|
|
for o in w.opts.split('-'):
|
|
|
|
m = re.match(r'^(\d+)h$', o, re.IGNORECASE)
|
|
|
|
if m is not None:
|
|
|
|
factor /= int(m.group(1))
|
|
|
|
break
|
2018-02-19 09:03:25 +00:00
|
|
|
if w.clusters.endswith('m'):
|
2018-10-22 21:28:56 +00:00
|
|
|
return int(factor * (18000 + 180 * int(w.clusters[:-1])))
|
2018-02-19 09:03:25 +00:00
|
|
|
else:
|
2018-10-22 21:28:56 +00:00
|
|
|
return int(factor * (10000 + 190 * int(w.clusters)))
|
2018-03-09 14:43:55 +00:00
|
|
|
# return 4890+310 * int(w.clusters)
|
2018-02-10 16:19:46 +00:00
|
|
|
|
2017-12-18 19:34:15 +00:00
|
|
|
rule solve_network:
|
2018-01-30 22:11:16 +00:00
|
|
|
input: "networks/{network}_s{simpl}_{clusters}_lv{lv}_{opts}.nc"
|
|
|
|
output: "results/networks/{network}_s{simpl}_{clusters}_lv{lv}_{opts}.nc"
|
2017-12-18 19:34:15 +00:00
|
|
|
shadow: "shallow"
|
|
|
|
log:
|
2018-09-14 09:22:13 +00:00
|
|
|
solver="logs/{network}_s{simpl}_{clusters}_lv{lv}_{opts}_solver.log",
|
2018-02-10 16:19:46 +00:00
|
|
|
python="logs/{network}_s{simpl}_{clusters}_lv{lv}_{opts}_python.log",
|
|
|
|
memory="logs/{network}_s{simpl}_{clusters}_lv{lv}_{opts}_memory.log"
|
2018-01-30 22:11:16 +00:00
|
|
|
benchmark: "benchmarks/solve_network/{network}_s{simpl}_{clusters}_lv{lv}_{opts}"
|
2017-12-18 19:34:15 +00:00
|
|
|
threads: 4
|
2018-09-20 12:26:38 +00:00
|
|
|
resources: mem=memory
|
2018-09-24 16:26:31 +00:00
|
|
|
# group: "solve" # with group, threads is ignored https://bitbucket.org/snakemake/snakemake/issues/971/group-job-description-does-not-contain
|
2017-12-18 19:34:15 +00:00
|
|
|
script: "scripts/solve_network.py"
|
|
|
|
|
2018-02-19 09:17:49 +00:00
|
|
|
rule solve_operations_network:
|
|
|
|
input:
|
|
|
|
unprepared="networks/{network}_s{simpl}_{clusters}.nc",
|
|
|
|
optimized="results/networks/{network}_s{simpl}_{clusters}_lv{lv}_{opts}.nc"
|
|
|
|
output: "results/networks/{network}_s{simpl}_{clusters}_lv{lv}_{opts}_op.nc"
|
|
|
|
shadow: "shallow"
|
|
|
|
log:
|
2018-09-14 09:22:13 +00:00
|
|
|
solver="logs/solve_operations_network/{network}_s{simpl}_{clusters}_lv{lv}_{opts}_op_solver.log",
|
2018-03-13 09:47:47 +00:00
|
|
|
python="logs/solve_operations_network/{network}_s{simpl}_{clusters}_lv{lv}_{opts}_op_python.log",
|
|
|
|
memory="logs/solve_operations_network/{network}_s{simpl}_{clusters}_lv{lv}_{opts}_op_memory.log"
|
|
|
|
benchmark: "benchmarks/solve_operations_network/{network}_s{simpl}_{clusters}_lv{lv}_{opts}"
|
2018-02-19 09:17:49 +00:00
|
|
|
threads: 4
|
2018-09-20 12:26:38 +00:00
|
|
|
resources: mem=(lambda w: 5000 + 372 * int(w.clusters))
|
|
|
|
group: "solve_operations"
|
2018-02-19 09:17:49 +00:00
|
|
|
script: "scripts/solve_operations_network.py"
|
|
|
|
|
2017-12-18 19:34:15 +00:00
|
|
|
rule plot_network:
|
|
|
|
input:
|
2018-10-22 21:31:13 +00:00
|
|
|
network="results/networks/{network}_s{simpl}_{clusters}_lv{lv}_{opts}.nc",
|
|
|
|
costs='data/costs.csv'
|
2017-12-18 19:34:15 +00:00
|
|
|
output:
|
2018-10-22 21:31:13 +00:00
|
|
|
only_map="results/plots/{network}_s{simpl}_{clusters}_lv{lv}_{opts}_{attr}.pdf",
|
|
|
|
ext="results/plots/{network}_s{simpl}_{clusters}_lv{lv}_{opts}_{attr}_ext.pdf"
|
2017-12-18 19:34:15 +00:00
|
|
|
script: "scripts/plot_network.py"
|
|
|
|
|
|
|
|
# rule plot_costs:
|
|
|
|
# input: 'results/summaries/costs2-summary.csv'
|
|
|
|
# output:
|
|
|
|
# expand('results/plots/costs_{cost}_{resarea}_{sectors}_{opt}',
|
|
|
|
# **dict(chain(config['scenario'].items(), (('{param}')))
|
|
|
|
# touch('results/plots/scenario_plots')
|
|
|
|
# params:
|
|
|
|
# tmpl="results/plots/costs_[cost]_[resarea]_[sectors]_[opt]"
|
|
|
|
# exts=["pdf", "png"]
|
|
|
|
# scripts: "scripts/plot_costs.py"
|
|
|
|
|
2018-01-29 21:28:33 +00:00
|
|
|
# rule scenario_comparison:
|
|
|
|
# input:
|
|
|
|
# expand('results/plots/network_{cost}_{sectors}_{opts}_{attr}.pdf',
|
|
|
|
# version=config['version'],
|
|
|
|
# attr=['p_nom'],
|
|
|
|
# **config['scenario'])
|
|
|
|
# output:
|
|
|
|
# html='results/plots/scenario_{param}.html'
|
|
|
|
# params:
|
|
|
|
# tmpl="network_[cost]_[resarea]_[sectors]_[opts]_[attr]",
|
|
|
|
# plot_dir='results/plots'
|
|
|
|
# script: "scripts/scenario_comparison.py"
|
|
|
|
|
|
|
|
# rule extract_summaries:
|
|
|
|
# input:
|
|
|
|
# expand("results/networks/{cost}_{sectors}_{opts}.nc",
|
|
|
|
# **config['scenario'])
|
|
|
|
# output:
|
|
|
|
# **{n: "results/summaries/{}-summary.csv".format(n)
|
|
|
|
# for n in ['costs', 'costs2', 'e_curtailed', 'e_nom_opt', 'e', 'p_nom_opt']}
|
|
|
|
# params:
|
|
|
|
# scenario_tmpl="[cost]_[resarea]_[sectors]_[opts]",
|
|
|
|
# scenarios=config['scenario']
|
|
|
|
# script: "scripts/extract_summaries.py"
|
2017-12-18 19:34:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
# Local Variables:
|
|
|
|
# mode: python
|
|
|
|
# End:
|