-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSnakefile
60 lines (48 loc) · 1.93 KB
/
Snakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
configfile: "config.yaml"
subworkflow pypsaeur:
workdir: "pypsa-eur"
configfile: "config.pypsaeur.yaml"
wildcard_constraints:
clusters="[0-9]+m?|all",
opts="[-+a-zA-Z0-9\.]*",
model="(transport|lossytransport|lossless-[0-9]+|lossy-[0-9]+-[0-9]+)",
slack="(distributed|regular)"
# adapted from https://github.com/PyPSA/pypsa-eur/blob/master/Snakefile
def memory(w):
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
if "lossy-" in w.model:
factor *= 0.45 * int(w.model.split("-")[-2])
return min(245000, int(factor * (10000 + 195 * int(w.clusters))))
# SOLVING RULES
rule solve_network:
input: pypsaeur("networks/elec_s_{clusters}_ec_lcopt_{opts}.nc")
output: "results/networks/elec_s_{clusters}_ec_lcopt_{opts}_M{model}.nc"
log:
solver="logs/elec_s_{clusters}_lcopt_{opts}_M{model}_solver.log",
python="logs/elec_s_{clusters}_lcopt_{opts}_M{model}_python.log",
memory="logs/elec_s_{clusters}_lcopt_{opts}_M{model}_memory.log"
threads: 4
resources: mem=memory
script: "scripts/solve_network.py"
rule solve_all_networks:
input:
expand("results/networks/elec_s_{clusters}_ec_lcopt_{opts}_M{model}.nc",
**config["scenario"])
# POWER FLOW RULES
rule check_powerflow:
input: "results/networks/elec_s_{clusters}_ec_lcopt_{opts}_M{model}.nc"
log:
python="logs/elec_s_{clusters}_lcopt_{opts}_M{model}_S{slack}_python.log"
output:
network="results/pf/elec_s_{clusters}_ec_lcopt_{opts}_M{model}_S{slack}.nc",
pf_log="results/pf/log_elec_s_{clusters}_ec_lcopt_{opts}_M{model}_S{slack}.csv"
script: "scripts/power_flow.py"
rule check_all_powerflows:
input:
expand("results/pf/elec_s_{clusters}_ec_lcopt_{opts}_M{model}_S{slack}.nc",
**config["scenario"]),