Skip to content

Commit 0c224a1

Browse files
committed
first running version
1 parent 1aabec0 commit 0c224a1

13 files changed

+73
-194
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ repos:
3030
rev: v2.3.0
3131
hooks:
3232
- id: codespell
33-
args: ['--ignore-regex="(\b[A-Z]+\b)"', '--ignore-words-list=fom,appartment,bage,ore,setis,tabacco,berfore,vor,pris'] # Ignore capital case words, e.g. country codes
33+
args: ['--ignore-regex="(\b[A-Z]+\b)"', '--ignore-words-list=fom,appartment,bage,ore,setis,tabacco,berfore,vor,pris,Dezember,GuD,Modell'] # Ignore capital case words, e.g. country codes
3434
types_or: [python, rst, markdown]
3535
files: ^(scripts|doc)/
3636

Snakefile

Lines changed: 18 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ CDIR = "" if run["shared_cutouts"] else RDIR
4444
RESULTS = "results/" + RDIR
4545

4646

47-
data_dir = Path("data")
48-
4947
localrules:
5048
purge,
5149

@@ -151,23 +149,6 @@ rule sync:
151149
rsync -uvarh --no-g {params.cluster}/logs . || echo "No logs directory, skipping rsync"
152150
"""
153151

154-
data_dir = Path("data")
155-
156-
rule get_data:
157-
input:
158-
[p for p in data_dir.rglob("*") if p.is_file()],
159-
output:
160-
[
161-
str(Path("data") / p.relative_to(data_dir))
162-
for p in data_dir.rglob("*")
163-
if p.is_file()
164-
],
165-
shell:
166-
"""
167-
mkdir -p data
168-
cp -nR {data_dir}/. data/
169-
"""
170-
171152

172153
rule clean:
173154
message:
@@ -199,24 +180,11 @@ rule retrieve_ariadne_database:
199180
output:
200181
data=resources("ariadne_database.csv"),
201182
log:
202-
"logs/retrieve_ariadne_database.log",
183+
"logs/pypsa-de/retrieve_ariadne_database.log",
203184
resources:
204185
mem_mb=1000,
205186
script:
206-
"scripts/retrieve_ariadne_database.py"
207-
208-
209-
use rule prepare_sector_network from pypsaeur with:
210-
input:
211-
unpack(pypsaeur.input_profile_offwind),
212-
**{
213-
k: v
214-
for k, v in rules.prepare_sector_network.input.items()
215-
if k != "district_heat_share"
216-
},
217-
district_heat_share=resources(
218-
"district_heat_share_base_s_{clusters}_{planning_horizons}-modified.csv"
219-
),
187+
"scripts/pypsa-de/retrieve_ariadne_database.py"
220188

221189

222190
rule modify_cost_data:
@@ -241,7 +209,7 @@ rule modify_cost_data:
241209
log:
242210
logs("modify_cost_data_{planning_horizons}.log"),
243211
script:
244-
"scripts/modify_cost_data.py"
212+
"scripts/pypsa-de/modify_cost_data.py"
245213

246214

247215
if config["enable"]["retrieve"] and config["enable"].get("retrieve_cost_data", True):
@@ -267,7 +235,7 @@ rule build_mobility_demand:
267235
log:
268236
logs("build_mobility_demand_{clusters}_{planning_horizons}.log"),
269237
script:
270-
"scripts/build_mobility_demand.py"
238+
"scripts/pypsa-de/build_mobility_demand.py"
271239

272240

273241
rule build_egon_data:
@@ -284,7 +252,7 @@ rule build_egon_data:
284252
log:
285253
logs("build_egon_data.log"),
286254
script:
287-
"scripts/build_egon_data.py"
255+
"scripts/pypsa-de/build_egon_data.py"
288256

289257

290258
ruleorder: modify_district_heat_share > build_district_heat_share
@@ -308,7 +276,7 @@ rule modify_district_heat_share:
308276
log:
309277
logs("modify_district_heat_share_{clusters}_{planning_horizons}.log"),
310278
script:
311-
"scripts/modify_district_heat_share.py"
279+
"scripts/pypsa-de/modify_district_heat_share.py"
312280

313281

314282
rule modify_prenetwork:
@@ -380,35 +348,12 @@ rule modify_prenetwork:
380348
RESULTS
381349
+ "logs/modify_prenetwork_base_s_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}.log",
382350
script:
383-
"scripts/modify_prenetwork.py"
351+
"scripts/pypsa-de/modify_prenetwork.py"
384352

385353

386354
ruleorder: modify_industry_demand > build_industrial_production_per_country_tomorrow
387355

388356

389-
use rule solve_sector_network_myopic from pypsaeur with:
390-
params:
391-
**{
392-
k: v
393-
for k, v in rules.solve_sector_network_myopic.params.items()
394-
if k != "custom_extra_functionality"
395-
},
396-
custom_extra_functionality=os.path.join(
397-
os.path.dirname(workflow.snakefile), "scripts/additional_functionality.py"
398-
),
399-
energy_year=config_provider("energy", "energy_totals_year"),
400-
input:
401-
**{
402-
k: v
403-
for k, v in rules.solve_sector_network_myopic.input.items()
404-
if k != "network"
405-
},
406-
network=RESULTS
407-
+ "prenetworks-final/base_s_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}.nc",
408-
co2_totals_name=resources("co2_totals.csv"),
409-
energy_totals=resources("energy_totals.csv"),
410-
411-
412357
rule modify_existing_heating:
413358
params:
414359
iiasa_reference_scenario=config_provider("iiasa_database", "reference_scenario"),
@@ -426,7 +371,7 @@ rule modify_existing_heating:
426371
log:
427372
logs("modify_existing_heating.log"),
428373
script:
429-
"scripts/modify_existing_heating.py"
374+
"scripts/pypsa-de/modify_existing_heating.py"
430375

431376

432377
rule retrieve_mastr:
@@ -458,23 +403,7 @@ rule build_existing_chp_de:
458403
log:
459404
logs("build_existing_chp_de_{clusters}.log"),
460405
script:
461-
"scripts/build_existing_chp_de.py"
462-
463-
464-
use rule add_existing_baseyear from pypsaeur with:
465-
input:
466-
**rules.add_existing_baseyear.input,
467-
custom_powerplants=resources("german_chp_{clusters}.csv"),
468-
469-
470-
use rule build_existing_heating_distribution from pypsaeur with:
471-
input:
472-
**{
473-
k: v
474-
for k, v in rules.build_existing_heating_distribution.input.items()
475-
if k != "existing_heating"
476-
},
477-
existing_heating=resources("existing_heating.csv"),
406+
"scripts/pypsa-de/build_existing_chp_de.py"
478407

479408

480409
rule modify_industry_demand:
@@ -494,19 +423,7 @@ rule modify_industry_demand:
494423
log:
495424
logs("modify_industry_demand_{planning_horizons}.log"),
496425
script:
497-
"scripts/modify_industry_demand.py"
498-
499-
500-
use rule build_industrial_production_per_node from pypsaeur with:
501-
input:
502-
**{
503-
k: v
504-
for k, v in rules.build_industrial_production_per_node.input.items()
505-
if k != "industrial_production_per_country_tomorrow"
506-
},
507-
industrial_production_per_country_tomorrow=resources(
508-
"industrial_production_per_country_tomorrow_{planning_horizons}-modified.csv"
509-
),
426+
"scripts/pypsa-de/modify_industry_demand.py"
510427

511428

512429
rule build_wasserstoff_kernnetz:
@@ -537,7 +454,7 @@ rule build_wasserstoff_kernnetz:
537454
log:
538455
logs("build_wasserstoff_kernnetz.log"),
539456
script:
540-
"scripts/build_wasserstoff_kernnetz.py"
457+
"scripts/pypsa-de/build_wasserstoff_kernnetz.py"
541458

542459

543460
rule cluster_wasserstoff_kernnetz:
@@ -552,7 +469,7 @@ rule cluster_wasserstoff_kernnetz:
552469
log:
553470
logs("cluster_wasserstoff_kernnetz_{clusters}.log"),
554471
script:
555-
"scripts/cluster_wasserstoff_kernnetz.py"
472+
"scripts/pypsa-de/cluster_wasserstoff_kernnetz.py"
556473

557474

558475
rule download_ariadne_template:
@@ -622,7 +539,7 @@ rule export_ariadne_variables:
622539
log:
623540
RESULTS + "logs/export_ariadne_variables.log",
624541
script:
625-
"scripts/export_ariadne_variables.py"
542+
"scripts/pypsa-de/export_ariadne_variables.py"
626543

627544

628545
rule plot_ariadne_variables:
@@ -667,7 +584,7 @@ rule plot_ariadne_variables:
667584
log:
668585
RESULTS + "logs/plot_ariadne_variables.log",
669586
script:
670-
"scripts/plot_ariadne_variables.py"
587+
"scripts/pypsa-de/plot_ariadne_variables.py"
671588

672589

673590
rule ariadne_all:
@@ -689,7 +606,7 @@ rule ariadne_all:
689606
run=config_provider("run", "name"),
690607
),
691608
script:
692-
"scripts/plot_ariadne_scenario_comparison.py"
609+
"scripts/pypsa-de/plot_ariadne_scenario_comparison.py"
693610

694611

695612
rule build_scenarios:
@@ -705,7 +622,7 @@ rule build_scenarios:
705622
log:
706623
"logs/build_scenarios.log",
707624
script:
708-
"scripts/build_scenarios.py"
625+
"scripts/pypsa-de/build_scenarios.py"
709626

710627

711628
rule plot_hydrogen_network_incl_kernnetz:
@@ -731,7 +648,7 @@ rule plot_hydrogen_network_incl_kernnetz:
731648
+ "benchmarks/plot_hydrogen_network_incl_kernnetz/base_s_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}"
732649
)
733650
script:
734-
"scripts/plot_hydrogen_network_incl_kernnetz.py"
651+
"scripts/pypsa-de/plot_hydrogen_network_incl_kernnetz.py"
735652

736653

737654
rule plot_ariadne_report:
@@ -779,7 +696,7 @@ rule plot_ariadne_report:
779696
log:
780697
RESULTS + "logs/plot_ariadne_report.log",
781698
script:
782-
"scripts/plot_ariadne_report.py"
699+
"scripts/pypsa-de/plot_ariadne_report.py"
783700

784701

785702
rule ariadne_report_only:

config/config.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,6 @@ lines:
191191
dynamic_line_rating:
192192
cutout: europe-2019-sarah3-era5
193193

194-
# docs in https://pypsa-eur.readthedocs.io/en/latest/configuration.html#enable
195-
enable:
196-
retrieve: false # set to false once initial data is retrieved
197-
retrieve_cutout: false # set to false once initial data is retrieved
198194
clustering:
199195
# simplify_network:
200196
# to_substations: true

rules/build_sector.smk

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ rule build_industrial_production_per_node:
666666
"industrial_distribution_key_base_s_{clusters}.csv"
667667
),
668668
industrial_production_per_country_tomorrow=resources(
669-
"industrial_production_per_country_tomorrow_{planning_horizons}.csv"
669+
"industrial_production_per_country_tomorrow_{planning_horizons}-modified.csv"
670670
),
671671
output:
672672
industrial_production_per_node=resources(
@@ -905,7 +905,7 @@ rule build_existing_heating_distribution:
905905
sector=config_provider("sector"),
906906
existing_capacities=config_provider("existing_capacities"),
907907
input:
908-
existing_heating="data/existing_infrastructure/existing_heating_raw.csv",
908+
existing_heating=resources("existing_heating.csv"),
909909
clustered_pop_layout=resources("pop_layout_base_s_{clusters}.csv"),
910910
clustered_pop_energy_layout=resources(
911911
"pop_weighted_energy_totals_s_{clusters}.csv"
@@ -917,6 +917,8 @@ rule build_existing_heating_distribution:
917917
existing_heating_distribution=resources(
918918
"existing_heating_distribution_base_s_{clusters}_{planning_horizons}.csv"
919919
),
920+
wildcard_constraints:
921+
planning_horizons=config["scenario"]["planning_horizons"][0], #only applies to baseyear
920922
threads: 1
921923
resources:
922924
mem_mb=2000,
@@ -1098,7 +1100,7 @@ rule prepare_sector_network:
10981100
"industrial_production_base_s_{clusters}_{planning_horizons}.csv"
10991101
),
11001102
district_heat_share=resources(
1101-
"district_heat_share_base_s_{clusters}_{planning_horizons}.csv"
1103+
"district_heat_share_base_s_{clusters}_{planning_horizons}-modified.csv"
11021104
),
11031105
heating_efficiencies=resources("heating_efficiencies.csv"),
11041106
temp_soil_total=resources("temp_soil_total_base_s_{clusters}.nc"),

rules/solve_myopic.smk

Lines changed: 8 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,43 +3,6 @@
33
# SPDX-License-Identifier: MIT
44

55

6-
rule build_existing_heating_distribution:
7-
params:
8-
baseyear=config["scenario"]["planning_horizons"][0],
9-
sector=config["sector"],
10-
existing_capacities=config["existing_capacities"],
11-
input:
12-
existing_heating="data/existing_infrastructure/existing_heating_raw.csv",
13-
clustered_pop_layout=resources("pop_layout_base_s_{clusters}.csv"),
14-
clustered_pop_energy_layout=resources(
15-
"pop_weighted_energy_totals_s_{clusters}.csv"
16-
),
17-
district_heat_share=resources(
18-
"district_heat_share_base_s_{clusters}_{planning_horizons}.csv"
19-
),
20-
output:
21-
existing_heating_distribution=resources(
22-
"existing_heating_distribution_base_s_{clusters}_{planning_horizons}.csv"
23-
),
24-
wildcard_constraints:
25-
planning_horizons=config["scenario"]["planning_horizons"][0], #only applies to baseyear
26-
threads: 1
27-
resources:
28-
mem_mb=2000,
29-
log:
30-
logs(
31-
"build_existing_heating_distribution_base_s_{clusters}_{planning_horizons}.log"
32-
),
33-
benchmark:
34-
benchmarks(
35-
"build_existing_heating_distribution/base_s_{clusters}_{planning_horizons}"
36-
)
37-
conda:
38-
"../envs/environment.yaml"
39-
script:
40-
"../scripts/build_existing_heating_distribution.py"
41-
42-
436
rule add_existing_baseyear:
447
params:
458
baseyear=config_provider("scenario", "planning_horizons", 0),
@@ -65,6 +28,7 @@ rule add_existing_baseyear:
6528
"existing_heating_distribution_base_s_{clusters}_{planning_horizons}.csv"
6629
),
6730
heating_efficiencies=resources("heating_efficiencies.csv"),
31+
custom_powerplants=resources("german_chp_{clusters}.csv"),
6832
output:
6933
RESULTS
7034
+ "prenetworks-brownfield/base_s_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}.nc",
@@ -150,10 +114,15 @@ rule solve_sector_network_myopic:
150114
"sector", "co2_sequestration_potential", default=200
151115
),
152116
custom_extra_functionality=input_custom_extra_functionality,
117+
# custom_extra_functionality=os.path.join(
118+
# os.path.dirname(workflow.snakefile), "scripts/pypsa-de/additional_functionality.py"
119+
# ),
120+
energy_year=config_provider("energy", "energy_totals_year"),
153121
input:
154122
network=RESULTS
155-
+ "prenetworks-brownfield/base_s_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}.nc",
156-
costs=resources("costs_{planning_horizons}.csv"),
123+
+ "prenetworks-final/base_s_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}.nc",
124+
co2_totals_name=resources("co2_totals.csv"),
125+
energy_totals=resources("energy_totals.csv"),
157126
output:
158127
network=RESULTS
159128
+ "postnetworks/base_s_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}.nc",

rules/solve_perfect.smk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ rule add_existing_baseyear:
2727
),
2828
existing_heating="data/existing_infrastructure/existing_heating_raw.csv",
2929
heating_efficiencies=resources("heating_efficiencies.csv"),
30+
custom_powerplants=resources("german_chp_{clusters}.csv"),
3031
output:
3132
RESULTS
3233
+ "prenetworks-brownfield/base_s_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}.nc",

0 commit comments

Comments
 (0)