Skip to content

Commit ccac88c

Browse files
author
Micha
authored
Merge branch 'main' into refining-scenarios
2 parents 603a3cd + 4ea3133 commit ccac88c

File tree

8 files changed

+259
-41
lines changed

8 files changed

+259
-41
lines changed

README.md

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ This repository contains the entire scientific project, including data sources a
66

77
## Getting ready
88

9-
You need conda or [mamba](https://mamba.readthedocs.io/en/latest/) to run the analysis. Using mamba, you can create an environment from within you can run it:
9+
You need `conda` or `mamba` to run the analysis. Using conda, you can create an environment from within which you can run the analysis:
1010

11-
mamba env create -f environment.yaml
11+
conda env create -f envs/environment.yaml
1212

1313
## For external users: Use config.public.yaml
1414

@@ -40,40 +40,33 @@ To switch between internal and public use, the command `ixmp4 logout` may be nec
4040

4141
Before running any analysis with scenarios, the rule `build_scenarios` must be executed. This will create the file `config/scenarios.automated.yaml` which includes input data and CO2 targets from the IIASA Ariadne database as well as the specifications from the manual scenario file. [This file is specified in the default config.yaml via they key `run:scenarios:manual_file` (by default located at `config/scenarios.manual.yaml`)].
4242

43-
snakemake -call build_scenarios -f
43+
snakemake build_scenarios -f
4444
or in case of using the public database
4545

46-
snakemake -call build_scenarios --configfile=config/config.public.yaml -f
46+
snakemake build_scenarios --configfile=config/config.public.yaml -f
4747

4848
Note that the hierarchy of scenario files is the following: `scenarios.automated.yaml` > (any `explicitly specified --configfiles`) > `config.yaml `> `config.default.yaml `Changes in the file `scenarios.manual.yaml `are only taken into account if the rule `build_scenarios` is executed.
4949

50-
For the first run, open config.yaml and set
50+
To run the analysis use
5151

52-
enable:
53-
retrieve: true # set to false once initial data is retrieved
54-
retrieve_cutout: true # set to false once initial data is retrieved
52+
snakemake ariadne_all
5553

56-
and then run from main repository
54+
This will run all analysis steps to reproduce results. If computational resources on your local machine are limit you may decrease the number of cores by adding, e.g. `-c4` to the call.
5755

58-
snakemake -call
59-
60-
This will run all analysis steps to reproduce results.
61-
62-
To generate a PDF of the dependency graph of all steps `build/dag.pdf` run:
63-
64-
snakemake -c1 --use-conda -f dag
6556

6657
## Repo structure
6758

6859
* `config`: configuration files
6960
* `ariadne-data`: Germany specific data from the Ariadne project
70-
* `workflow`: contains the Snakemake workflow, including the submodule PyPSA-Eur and specific scripts for Germany
61+
* `scripts`: contains the Python scripts for the workflow, the Germany specific code needed to run this repo is contained in `scripts/pypsa-de`
7162
* `cutouts`: very large weather data cutouts supplied by atlite library (does not exist initially)
7263
* `data`: place for raw data (does not exist initially)
7364
* `resources`: place for intermediate/processing data for the workflow (does not exist initially)
7465
* `results`: will contain all results (does not exist initially)
66+
* `logs` and `benchmarks`
67+
* The `Snakefile` contains the snakemake workflow
7568

76-
## Differences to PyPSA-EUR
69+
## Some notable differences to PyPSA-EUR
7770

7871
- Specific cost assumption for Germany:
7972
- Gas, Oil, Coal prices
@@ -90,6 +83,9 @@ To generate a PDF of the dependency graph of all steps `build/dag.pdf` run:
9083
- Renewable build out according to the Wind-an-Land, Wind-auf-See and Solarstrategie laws
9184
- A comprehensive reporting module that exports Capacity Expansion, Primary/Secondary/Final Energy, CO2 Emissions per Sector, Trade, Investments, ...
9285
- Plotting functionality to compare different scenarios
86+
- Electricity Network development until 2030 (and for AC beyond) according to the Netzentwicklungsplan
87+
- Offshore development until 2030 according to the Offshore Netzentwicklungsplan
88+
- Hydrogen network development until 2028 according to the Wasserstoffkernnetz. PCI / IPCEI projects for later years are included as well.
9389

9490
## License
9591

Snakefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,7 @@ rule build_existing_chp_de:
409409
rule modify_industry_demand:
410410
params:
411411
db_name=config_provider("iiasa_database", "db_name"),
412+
reference_scenario=config_provider("iiasa_database", "reference_scenario"),
412413
input:
413414
ariadne=resources("ariadne_database.csv"),
414415
industrial_production_per_country_tomorrow=resources(

config/config.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
# docs in https://pypsa-eur.readthedocs.io/en/latest/configuration.html#run
66
run:
7-
prefix: 20250123-restrict_res_buildout
7+
prefix: 20250124-finalfixes
88
name:
99
# - CurrentPolicies
1010
- KN2045_Bal_v4
@@ -14,6 +14,8 @@ run:
1414
# - KN2045plus_LowDemand
1515
# - KN2045minus_WorstCase
1616
# - KN2045minus_SupplyFocus
17+
# - KN2045_Bal_LowDemand
18+
# - KN2045_Bal_HighDemand
1719
scenarios:
1820
enable: true
1921
manual_file: config/scenarios.manual.yaml
@@ -250,7 +252,7 @@ wasserstoff_kernnetz:
250252
enable: true
251253
reload_locations: false
252254
divide_pipes: true
253-
pipes_segment_length: 10
255+
pipes_segment_length: 50
254256
border_crossing: true
255257
aggregate_build_years: "mean"
256258
recalculate_length: true

config/scenarios.manual.yaml

Lines changed: 194 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,14 @@ KN2045plus_EasyRide:
415415
steam_biomass_fraction: 0.4
416416
steam_hydrogen_fraction: 0.3
417417
steam_electricity_fraction: 0.3
418-
418+
sector:
419+
reduce_space_heat_exogenously_factor:
420+
2020: 0.0
421+
2025: 0.08
422+
2030: 0.16
423+
2035: 0.25
424+
2040: 0.34
425+
2045: 0.43
419426

420427
KN2045plus_LowDemand:
421428
# Im Vergleich zu Easy Ride eher knappe EE Erzeugung
@@ -485,6 +492,14 @@ KN2045plus_LowDemand:
485492
steam_biomass_fraction: 0.4
486493
steam_hydrogen_fraction: 0.3
487494
steam_electricity_fraction: 0.3
495+
sector:
496+
reduce_space_heat_exogenously_factor:
497+
2020: 0.0
498+
2025: 0.08
499+
2030: 0.16
500+
2035: 0.25
501+
2040: 0.34
502+
2045: 0.43
488503

489504
KN2045minus_WorstCase:
490505
# Nachfrage nach Endenergie ist höher als in den Szenarien 1-3
@@ -603,7 +618,13 @@ KN2045minus_WorstCase:
603618
sector:
604619
district_heating:
605620
potential: 0.1
606-
621+
reduce_space_heat_exogenously_factor:
622+
2020: 0.0
623+
2025: 0.06
624+
2030: 0.12
625+
2035: 0.18
626+
2040: 0.24
627+
2045: 0.29
607628
offshore_nep_force:
608629
cutin_year: 2025
609630
cutout_year: 2035 # Hackily reduced to 2030 if delay_years: 1
@@ -705,3 +726,174 @@ KN2045minus_SupplyFocus:
705726
steam_biomass_fraction: 0.4
706727
steam_hydrogen_fraction: 0.3
707728
steam_electricity_fraction: 0.3
729+
sector:
730+
reduce_space_heat_exogenously_factor:
731+
2020: 0.0
732+
2025: 0.06
733+
2030: 0.12
734+
2035: 0.18
735+
2040: 0.24
736+
2045: 0.29
737+
738+
KN2045_Bal_LowDemand:
739+
# Ausgewogener Mix an Technologien zur Dekarbonisierung der Sektoren
740+
# Breites Energieträgerportfolio in der Endenergie (Strom, Wasserstoff, synthetische Kraftstoffe)
741+
# Ausbau der erneuerbare Stromerzeugung erreicht politisch gesetzte Ziele
742+
# Importe erneuerbar erzeugter Energien auf mittlerem Niveau
743+
# dient als Referenzszenario in der Familie der Ariadne-Szenarien
744+
745+
iiasa_database:
746+
reference_scenario: KN2045plus_LowDemand
747+
fallback_reference_scenario: KN2045_Bal_v4
748+
co2_budget_DE_source: KSG
749+
750+
costs:
751+
horizon: "mean"
752+
NEP: 2023
753+
transmission: "overhead" # either overhead line ("overhead") or underground cable ("underground")
754+
solving:
755+
constraints:
756+
# boundary condition of maximum volumes
757+
limits_volume_max:
758+
# constrain electricity import in TWh
759+
electricity_import:
760+
DE:
761+
2020: -20
762+
2025: 0
763+
2030: 0
764+
2035: 40
765+
2040: 80
766+
2045: 125
767+
electrolysis:
768+
DE:
769+
2020: 0
770+
2025: 5
771+
2030: 45
772+
2035: 130
773+
2040: 215
774+
2045: 300
775+
h2_derivate_import:
776+
DE:
777+
2020: 0
778+
2025: 0
779+
2030: 10
780+
2035: 105
781+
2040: 200
782+
2045: 300
783+
h2_import:
784+
DE:
785+
2020: 0
786+
2025: 5
787+
2030: 15
788+
2035: 115
789+
2040: 220
790+
2045: 325
791+
limits_volume_min:
792+
electrolysis:
793+
DE:
794+
2020: 0
795+
2025: 0
796+
2030: 0
797+
2035: 0
798+
2040: 0
799+
2045: 0
800+
limits_capacity_min:
801+
Link:
802+
H2 Electrolysis:
803+
DE:
804+
2030: 5
805+
industry:
806+
steam_biomass_fraction: 0.4
807+
steam_hydrogen_fraction: 0.3
808+
steam_electricity_fraction: 0.3
809+
810+
sector:
811+
reduce_space_heat_exogenously_factor:
812+
2020: 0.0
813+
2025: 0.08
814+
2030: 0.16
815+
2035: 0.25
816+
2040: 0.34
817+
2045: 0.43
818+
819+
KN2045_Bal_HighDemand:
820+
# Ausgewogener Mix an Technologien zur Dekarbonisierung der Sektoren
821+
# Breites Energieträgerportfolio in der Endenergie (Strom, Wasserstoff, synthetische Kraftstoffe)
822+
# Ausbau der erneuerbare Stromerzeugung erreicht politisch gesetzte Ziele
823+
# Importe erneuerbar erzeugter Energien auf mittlerem Niveau
824+
# dient als Referenzszenario in der Familie der Ariadne-Szenarien
825+
826+
iiasa_database:
827+
reference_scenario: KN2045minus_SupplyFocus
828+
fallback_reference_scenario: KN2045_Bal_v4
829+
co2_budget_DE_source: KSG
830+
831+
costs:
832+
horizon: "mean"
833+
NEP: 2023
834+
transmission: "overhead" # either overhead line ("overhead") or underground cable ("underground")
835+
solving:
836+
constraints:
837+
# boundary condition of maximum volumes
838+
limits_volume_max:
839+
# constrain electricity import in TWh
840+
electricity_import:
841+
DE:
842+
2020: -20
843+
2025: 0
844+
2030: 0
845+
2035: 40
846+
2040: 80
847+
2045: 125
848+
electrolysis:
849+
DE:
850+
2020: 0
851+
2025: 5
852+
2030: 45
853+
2035: 130
854+
2040: 215
855+
2045: 300
856+
h2_derivate_import:
857+
DE:
858+
2020: 0
859+
2025: 0
860+
2030: 10
861+
2035: 105
862+
2040: 200
863+
2045: 300
864+
h2_import:
865+
DE:
866+
2020: 0
867+
2025: 5
868+
2030: 15
869+
2035: 115
870+
2040: 220
871+
2045: 325
872+
limits_volume_min:
873+
electrolysis:
874+
DE:
875+
2020: 0
876+
2025: 0
877+
2030: 0
878+
2035: 0
879+
2040: 0
880+
2045: 0
881+
limits_capacity_min:
882+
Link:
883+
H2 Electrolysis:
884+
DE:
885+
2030: 5
886+
industry:
887+
steam_biomass_fraction: 0.4
888+
steam_hydrogen_fraction: 0.3
889+
steam_electricity_fraction: 0.3
890+
891+
sector:
892+
reduce_space_heat_exogenously_factor:
893+
2020: 0.0
894+
2025: 0.06
895+
2030: 0.12
896+
2035: 0.18
897+
2040: 0.24
898+
2045: 0.29
899+

scripts/pypsa-de/build_scenarios.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,8 @@ def write_to_scenario_yaml(input, output, scenarios, df):
184184
co2_budget_source,
185185
)
186186

187-
config[scenario]["sector"] = {}
187+
if not config[scenario].get("sector"):
188+
config[scenario]["sector"] = {}
188189

189190
config[scenario]["sector"]["aviation_demand_factor"] = {}
190191
for year in planning_horizons:

scripts/pypsa-de/export_ariadne_variables.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5040,6 +5040,19 @@ def process_postnetworks(n, n_start, model_year, snakemake, costs):
50405040
# # the same logic is applied to p_nom and p_nom_min
50415041
# n.links.loc[h2_links, attr] = n.links.loc[h2_links, attr].apply(_h2_lambda)
50425042

5043+
logger.info("Assing average Kernnetz cost to carrier H2 pipeline (Kernnetz)")
5044+
h2_links_kern = n.links.query("carrier == 'H2 pipeline (Kernnetz))'").index
5045+
capital_costs = (
5046+
0.7 * costs.at["H2 (g) pipeline", "fixed"]
5047+
+ 0.3 * costs.at["H2 (g) pipeline repurposed", "fixed"]
5048+
) * n.links.loc[h2_links_kern, "length"]
5049+
overnight_costs = (
5050+
0.7 * costs.at["H2 (g) pipeline", "investment"]
5051+
+ 0.3 * costs.at["H2 (g) pipeline repurposed", "investment"]
5052+
) * n.links.loc[h2_links_kern, "length"]
5053+
n.links.loc[h2_links_kern, "capital_cost"] = capital_costs
5054+
n.links.loc[h2_links_kern, "overnight_cost"] = overnight_costs
5055+
50435056
logger.info("Post-Discretizing DC links")
50445057
_dc_lambda = lambda x: get_discretized_value(
50455058
x,

0 commit comments

Comments
 (0)