-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathkz.smk
105 lines (90 loc) · 3.21 KB
/
kz.smk
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# SPDX-FileCopyrightText: pypsa-kz-data authors
#
# SPDX-License-Identifier: AGPL-3.0-or-later
if config['load_options'].get("rescale_demand", True):
rule modify_demand:
input:
network="networks/" + RDIR + "elec_s{simpl}_{clusters}_ec_l{ll}_{opts}.nc",
gadm_demand_data="pypsa-kz-data/data/official_demand.csv",
output:
network="networks/" + RDIR + "elec_s{simpl}_{clusters}_ec_l{ll}_{opts}_d.nc",
script:
"scripts/modify_demand.py"
if config["lines"]["modify_lines"].get("limit_line_capacities", True):
rule modify_lines:
input:
network="networks/" + RDIR + "elec_s{simpl}_{clusters}_ec_l{ll}_{opts}_d.nc",
output:
network="networks/" + RDIR + "elec_s{simpl}_{clusters}_ec_l{ll}_{opts}_dl.nc",
script:
"scripts/modify_lines.py"
if config['load_options'].get("external_loads", True):
rule add_exports:
input:
network="networks/" + RDIR + "elec_s{simpl}_{clusters}_ec_l{ll}_{opts}_dl.nc",
imp_exp="pypsa-kz-data/data/electricity_exp-imp.csv",
output:
network="networks/" + RDIR + "elec_s{simpl}_{clusters}_ec_l{ll}_{opts}_dle.nc",
script:
"scripts/add_exports.py"
def memory(w):
factor = 3.0
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
for o in w.opts.split("-"):
m = re.match(r"^(\d+)seg$", o, re.IGNORECASE)
if m is not None:
factor *= int(m.group(1)) / 8760
break
if w.clusters.endswith("m"):
return int(factor * (18000 + 180 * int(w.clusters[:-1])))
else:
return int(factor * (10000 + 195 * int(w.clusters)))
rule solve_network_dle:
params:
solving=config["solving"],
augmented_line_connection=config["augmented_line_connection"],
input:
"networks/" + RDIR + "elec_s{simpl}_{clusters}_ec_l{ll}_{opts}_dle.nc",
output:
"results/" + RDIR + "networks/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}_dle.nc",
log:
solver=normpath(
"logs/"
+ RDIR
+ "solve_network/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}_dle_solver.log"
),
python="logs/"
+ RDIR
+ "solve_network/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}_dle_python.log",
memory="logs/"
+ RDIR
+ "solve_network/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}_dle_memory.log",
benchmark:
(
"benchmarks/"
+ RDIR
+ "solve_network/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}_dle"
)
threads: 20
resources:
mem=memory,
shadow:
"shallow"
script:
"../scripts/solve_network.py"
rule solve_everything:
input:
expand(
["results/" + RDIR + "networks/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}_dle.nc"],
**config["scenario"]
),
rule prepare_kz_scenarios:
run:
import os
os.system("rm configs/scenarios/config.NG.yaml")
os.system("cp -r pypsa-kz-data/scenarios/ configs/")
os.system("snakemake -j1 retrieve_databundle_light")