diff --git a/doc/img/intro-workflow.png b/doc/img/intro-workflow.png index 27b5a389..a273ab39 100644 Binary files a/doc/img/intro-workflow.png and b/doc/img/intro-workflow.png differ diff --git a/doc/index.rst b/doc/index.rst index 90114aca..840b6208 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -135,7 +135,7 @@ as part of the `Stromnetze Research Initiative Workflow ======== -.. image:: ../doc/img/workflow.png +.. image:: img/workflow.png :class: full-width :align: center diff --git a/doc/preparation.rst b/doc/preparation.rst index f608e031..feb10c60 100644 --- a/doc/preparation.rst +++ b/doc/preparation.rst @@ -21,8 +21,7 @@ Having downloaded the necessary data, With these and the externally extracted ENTSO-E online map topology (``data/entsoegridkit``), it can build a base PyPSA network with the following rules: -- :mod:`base_network` builds and stores the base network with all buses, HVAC lines and HVDC links, while -- :mod:`build_bus_regions` determines `Voronoi cells `__ for all substations. +- :mod:`base_network` builds and stores the base network with all buses, HVAC lines and HVDC links, and determines `Voronoi cells `__ for all substations. Then the process continues by calculating conventional power plant capacities, potentials, and per-unit availability time series for variable renewable energy carriers and hydro power plants with the following rules: @@ -35,13 +34,6 @@ Then the process continues by calculating conventional power plant capacities, p The central rule :mod:`add_electricity` then ties all the different data inputs together into a detailed PyPSA network stored in ``networks/elec.nc``. -.. _busregions: - -Rule ``build_bus_regions`` -============================= - -.. automodule:: build_bus_regions - .. _cutout: Rule ``build_cutout`` diff --git a/doc/release_notes.rst b/doc/release_notes.rst index 5e530963..dbc857bc 100644 --- a/doc/release_notes.rst +++ b/doc/release_notes.rst @@ -186,7 +186,7 @@ Upcoming Release * Data on existing renewable capacities is now consistently taken from powerplantmatching (instead of being retrieved separately); the dataset has also been updated to include 2023 values. -* Added shapes to .nc file for different stages of the network object in `base_network`, `build_bus_regions`, and `cluster_network`. +* Added shapes to .nc file for different stages of the network object in `base_network`, `simplify_network`, and `cluster_network`; the `build_bus_regions` rule is now integrated into the `base_network` rule. * Fix p_nom_min of renewables generators for myopic approach and add check of existing capacities in `add_land_use_constraint_m`. diff --git a/doc/tutorial.rst b/doc/tutorial.rst index 93bb8e54..4c10b573 100644 --- a/doc/tutorial.rst +++ b/doc/tutorial.rst @@ -133,32 +133,31 @@ This triggers a workflow of multiple preceding jobs that depend on each rule's i graph[bgcolor=white, margin=0]; node[shape=box, style=rounded, fontname=sans, fontsize=10, penwidth=2]; edge[penwidth=2, color=grey]; - 0[label = "solve_network", color = "0.39 0.6 0.85", style="rounded"]; - 1[label = "prepare_network\nll: copt\nopts: Co2L-24H", color = "0.29 0.6 0.85", style="rounded"]; - 2[label = "add_extra_components", color = "0.28 0.6 0.85", style="rounded"]; - 3[label = "cluster_network\nclusters: 6", color = "0.19 0.6 0.85", style="rounded"]; - 4[label = "simplify_network\nsimpl: ", color = "0.01 0.6 0.85", style="rounded"]; - 5[label = "add_electricity", color = "0.49 0.6 0.85", style="rounded"]; - 6[label = "build_renewable_profiles\ntechnology: solar", color = "0.21 0.6 0.85", style="rounded"]; - 7[label = "base_network", color = "0.27 0.6 0.85", style="rounded"]; - 8[label = "build_shapes", color = "0.26 0.6 0.85", style="rounded"]; - 9[label = "retrieve_databundle", color = "0.59 0.6 0.85", style="rounded"]; - 10[label = "retrieve_natura_raster", color = "0.47 0.6 0.85", style="rounded"]; - 11[label = "build_bus_regions", color = "0.13 0.6 0.85", style="rounded"]; - 12[label = "retrieve_cutout\ncutout: be-03-2013-era5", color = "0.36 0.6 0.85", style="rounded,dashed"]; - 13[label = "build_renewable_profiles\ntechnology: onwind", color = "0.21 0.6 0.85", style="rounded"]; - 14[label = "build_renewable_profiles\ntechnology: offwind-ac", color = "0.21 0.6 0.85", style="rounded"]; - 15[label = "build_ship_raster", color = "0.00 0.6 0.85", style="rounded"]; - 16[label = "retrieve_ship_raster", color = "0.51 0.6 0.85", style="rounded,dashed"]; - 17[label = "build_renewable_profiles\ntechnology: offwind-dc", color = "0.21 0.6 0.85", style="rounded"]; - 18[label = "build_line_rating", color = "0.05 0.6 0.85", style="rounded"]; - 19[label = "retrieve_cost_data\nyear: 2030", color = "0.15 0.6 0.85", style="rounded"]; - 20[label = "build_powerplants", color = "0.54 0.6 0.85", style="rounded"]; - 21[label = "build_electricity_demand", color = "0.52 0.6 0.85", style="rounded"]; - 22[label = "retrieve_electricity_demand", color = "0.22 0.6 0.85", style="rounded"]; - 23[label = "copy_config", color = "0.44 0.6 0.85", style="rounded"]; + 0[label = "solve_network", color = "0.24 0.6 0.85", style="rounded"]; + 1[label = "prepare_network\nll: vopt\nopts: Co2L-3H", color = "0.10 0.6 0.85", style="rounded"]; + 2[label = "add_extra_components", color = "0.33 0.6 0.85", style="rounded"]; + 3[label = "cluster_network\nclusters: 128", color = "0.59 0.6 0.85", style="rounded"]; + 4[label = "simplify_network\nsimpl: ", color = "0.18 0.6 0.85", style="rounded"]; + 5[label = "add_electricity", color = "0.48 0.6 0.85", style="rounded"]; + 6[label = "build_renewable_profiles\ntechnology: solar", color = "0.29 0.6 0.85", style="rounded"]; + 7[label = "base_network", color = "0.30 0.6 0.85", style="rounded"]; + 8[label = "build_shapes", color = "0.61 0.6 0.85", style="rounded"]; + 9[label = "retrieve_databundle", color = "0.06 0.6 0.85", style="rounded"]; + 10[label = "retrieve_natura_raster", color = "0.03 0.6 0.85", style="rounded"]; + 11[label = "retrieve_cutout\ncutout: europe-2013-sarah", color = "0.50 0.6 0.85", style="rounded"]; + 12[label = "build_renewable_profiles\ntechnology: onwind", color = "0.29 0.6 0.85", style="rounded"]; + 13[label = "retrieve_cutout\ncutout: europe-2013-era5", color = "0.50 0.6 0.85", style="rounded"]; + 14[label = "build_renewable_profiles\ntechnology: offwind-ac", color = "0.29 0.6 0.85", style="rounded"]; + 15[label = "build_ship_raster", color = "0.16 0.6 0.85", style="rounded"]; + 16[label = "retrieve_ship_raster", color = "0.53 0.6 0.85", style="rounded"]; + 17[label = "build_renewable_profiles\ntechnology: offwind-dc", color = "0.29 0.6 0.85", style="rounded"]; + 18[label = "build_hydro_profile", color = "0.47 0.6 0.85", style="rounded"]; + 19[label = "retrieve_cost_data\nyear: 2030", color = "0.21 0.6 0.85", style="rounded"]; + 20[label = "build_powerplants", color = "0.56 0.6 0.85", style="rounded"]; + 21[label = "build_electricity_demand", color = "0.54 0.6 0.85", style="rounded"]; + 22[label = "retrieve_electricity_demand", color = "0.34 0.6 0.85", style="rounded"]; + 23[label = "retrieve_synthetic_electricity_demand", color = "0.65 0.6 0.85", style="rounded"]; 1 -> 0 - 23 -> 0 2 -> 1 19 -> 1 3 -> 2 @@ -167,15 +166,14 @@ This triggers a workflow of multiple preceding jobs that depend on each rule's i 19 -> 3 5 -> 4 19 -> 4 - 11 -> 4 + 7 -> 4 6 -> 5 - 13 -> 5 + 12 -> 5 14 -> 5 17 -> 5 - 7 -> 5 18 -> 5 + 7 -> 5 19 -> 5 - 11 -> 5 20 -> 5 9 -> 5 21 -> 5 @@ -185,37 +183,32 @@ This triggers a workflow of multiple preceding jobs that depend on each rule's i 10 -> 6 8 -> 6 11 -> 6 - 12 -> 6 8 -> 7 9 -> 8 - 8 -> 11 - 7 -> 11 - 7 -> 13 - 9 -> 13 - 10 -> 13 - 8 -> 13 - 11 -> 13 - 12 -> 13 + 7 -> 12 + 9 -> 12 + 10 -> 12 + 8 -> 12 + 13 -> 12 7 -> 14 9 -> 14 10 -> 14 15 -> 14 8 -> 14 - 11 -> 14 - 12 -> 14 + 13 -> 14 16 -> 15 - 12 -> 15 + 13 -> 15 7 -> 17 9 -> 17 10 -> 17 15 -> 17 8 -> 17 - 11 -> 17 - 12 -> 17 - 7 -> 18 - 12 -> 18 + 13 -> 17 + 8 -> 18 + 13 -> 18 7 -> 20 22 -> 21 + 23 -> 21 } | @@ -226,28 +219,25 @@ In the terminal, this will show up as a list of jobs to be run: Building DAG of jobs... Job stats: - job count - --------------------------- ------- - add_electricity 1 - add_extra_components 1 - base_network 1 - build_bus_regions 1 - build_electricity_demand 1 - build_line_rating 1 - build_powerplants 1 - build_renewable_profiles 4 - build_shapes 1 - build_ship_raster 1 - cluster_network 1 - copy_config 1 - prepare_network 1 - retrieve_cost_data 1 - retrieve_databundle 1 - retrieve_electricity_demand 1 - retrieve_natura_raster 1 - simplify_network 1 - solve_network 1 - total 22 + job count + ------------------------------------- ------- + add_electricity 1 + add_extra_components 1 + build_line_rating 1 + build_renewable_profiles 4 + build_ship_raster 1 + cluster_network 1 + prepare_network 1 + retrieve_cost_data 1 + retrieve_cutout 1 + retrieve_databundle 1 + retrieve_electricity_demand 1 + retrieve_natura_raster 1 + retrieve_ship_raster 1 + retrieve_synthetic_electricity_demand 1 + simplify_network 1 + solve_network 1 + total 19 ``snakemake`` then runs these jobs in the correct order. diff --git a/doc/tutorial_sector.rst b/doc/tutorial_sector.rst index a1556150..d6fafa69 100644 --- a/doc/tutorial_sector.rst +++ b/doc/tutorial_sector.rst @@ -71,18 +71,16 @@ which were already included in the electricity-only tutorial: add_electricity 1 add_extra_components 1 all 1 - base_network 1 build_ammonia_production 1 build_biomass_potentials 1 - build_bus_regions 1 build_clustered_population_layouts 1 build_cop_profiles 1 build_daily_heat_demand 1 build_district_heat_share 1 - build_electricity_demand 1 build_energy_totals 1 build_gas_input_locations 1 build_gas_network 1 + build_heat_totals 1 build_hourly_heat_demand 1 build_industrial_distribution_key 1 build_industrial_energy_demand_per_country_today 1 @@ -94,19 +92,17 @@ which were already included in the electricity-only tutorial: build_industry_sector_ratios 1 build_industry_sector_ratios_intermediate 1 build_population_layouts 1 - build_population_weighted_energy_totals 1 - build_powerplants 1 + build_population_weighted_energy_totals 2 build_renewable_profiles 4 build_salt_cavern_potentials 1 - build_shapes 1 build_ship_raster 1 build_shipping_demand 1 build_simplified_population_layouts 1 + build_solar_thermal_profiles 3 build_temperature_profiles 3 build_transport_demand 1 cluster_gas_network 1 cluster_network 1 - copy_config 1 make_summary 1 plot_gas_network 1 plot_hydrogen_network 1 @@ -116,14 +112,18 @@ which were already included in the electricity-only tutorial: prepare_network 1 prepare_sector_network 1 retrieve_cost_data 1 + retrieve_cutout 1 retrieve_databundle 1 retrieve_electricity_demand 1 + retrieve_eurostat_data 1 retrieve_gas_infrastructure_data 1 retrieve_natura_raster 1 retrieve_sector_databundle 1 + retrieve_ship_raster 1 + retrieve_synthetic_electricity_demand 1 simplify_network 1 solve_sector_network 1 - total 60 + total 63 This covers the retrieval of additional raw data from online resources and preprocessing data about the transport, industry, and heating sectors as well as @@ -142,234 +142,252 @@ successfully. graph[bgcolor=white, margin=0]; node[shape=box, style=rounded, fontname=sans, fontsize=10, penwidth=2]; edge[penwidth=2, color=grey]; - 0[label = "all", color = "0.55 0.6 0.85", style="rounded"]; - 1[label = "plot_summary", color = "0.31 0.6 0.85", style="rounded"]; - 2[label = "make_summary", color = "0.37 0.6 0.85", style="rounded"]; - 3[label = "plot_power_network_clustered", color = "0.50 0.6 0.85", style="rounded"]; - 4[label = "cluster_network\nclusters: 5", color = "0.62 0.6 0.85", style="rounded"]; - 5[label = "simplify_network\nsimpl: ", color = "0.18 0.6 0.85", style="rounded"]; - 6[label = "add_electricity", color = "0.33 0.6 0.85", style="rounded"]; - 7[label = "build_renewable_profiles\ntechnology: solar", color = "0.20 0.6 0.85", style="rounded"]; - 8[label = "base_network", color = "0.31 0.6 0.85", style="rounded"]; - 9[label = "build_shapes", color = "0.36 0.6 0.85", style="rounded"]; - 10[label = "retrieve_databundle", color = "0.29 0.6 0.85", style="rounded"]; - 11[label = "retrieve_natura_raster", color = "0.01 0.6 0.85", style="rounded"]; - 12[label = "build_bus_regions", color = "0.10 0.6 0.85", style="rounded"]; - 13[label = "retrieve_cutout\ncutout: be-03-2013-era5", color = "0.37 0.6 0.85", style="rounded,dashed"]; - 14[label = "build_renewable_profiles\ntechnology: onwind", color = "0.20 0.6 0.85", style="rounded"]; - 15[label = "build_renewable_profiles\ntechnology: offwind-ac", color = "0.20 0.6 0.85", style="rounded"]; - 16[label = "build_ship_raster", color = "0.64 0.6 0.85", style="rounded"]; - 17[label = "retrieve_ship_raster", color = "0.64 0.6 0.85", style="rounded,dashed"]; - 18[label = "build_renewable_profiles\ntechnology: offwind-dc", color = "0.20 0.6 0.85", style="rounded"]; - 19[label = "retrieve_cost_data\nyear: 2030", color = "0.12 0.6 0.85", style="rounded"]; - 20[label = "build_powerplants", color = "0.23 0.6 0.85", style="rounded"]; - 21[label = "build_electricity_demand", color = "0.54 0.6 0.85", style="rounded"]; - 22[label = "retrieve_electricity_demand", color = "0.07 0.6 0.85", style="rounded"]; - 23[label = "solve_sector_network", color = "0.41 0.6 0.85", style="rounded"]; - 24[label = "prepare_sector_network\nsector_opts: CO2L0-24h-T-H-B-I-A-dist1", color = "0.22 0.6 0.85", style="rounded"]; - 25[label = "cluster_gas_network", color = "0.24 0.6 0.85", style="rounded"]; - 26[label = "build_gas_network", color = "0.10 0.6 0.85", style="rounded"]; - 27[label = "retrieve_gas_infrastructure_data", color = "0.17 0.6 0.85", style="rounded"]; - 28[label = "build_gas_input_locations", color = "0.16 0.6 0.85", style="rounded"]; - 29[label = "prepare_network\nll: v1.5\nopts: ", color = "0.49 0.6 0.85", style="rounded"]; - 30[label = "add_extra_components", color = "0.14 0.6 0.85", style="rounded"]; - 31[label = "build_energy_totals", color = "0.39 0.6 0.85", style="rounded"]; - 32[label = "retrieve_sector_databundle", color = "0.58 0.6 0.85", style="rounded"]; - 33[label = "build_population_weighted_energy_totals", color = "0.56 0.6 0.85", style="rounded"]; - 34[label = "build_clustered_population_layouts", color = "0.49 0.6 0.85", style="rounded"]; - 35[label = "build_population_layouts", color = "0.06 0.6 0.85", style="rounded"]; - 36[label = "build_shipping_demand", color = "0.47 0.6 0.85", style="rounded"]; - 37[label = "build_transport_demand", color = "0.45 0.6 0.85", style="rounded"]; - 38[label = "build_temperature_profiles\nscope: total", color = "0.04 0.6 0.85", style="rounded"]; - 39[label = "build_biomass_potentials\nplanning_horizons: 2030", color = "0.11 0.6 0.85", style="rounded"]; - 40[label = "build_salt_cavern_potentials", color = "0.15 0.6 0.85", style="rounded"]; - 41[label = "build_simplified_population_layouts", color = "0.46 0.6 0.85", style="rounded"]; - 42[label = "build_industrial_energy_demand_per_node", color = "0.63 0.6 0.85", style="rounded"]; - 43[label = "build_industry_sector_ratios_intermediate\nplanning_horizons: 2030", color = "0.07 0.6 0.85", style="rounded"]; - 44[label = "build_industry_sector_ratios", color = "0.59 0.6 0.85", style="rounded"]; - 45[label = "build_ammonia_production", color = "0.04 0.6 0.85", style="rounded"]; - 46[label = "build_industrial_energy_demand_per_country_today", color = "0.44 0.6 0.85", style="rounded"]; - 47[label = "build_industrial_production_per_country", color = "0.34 0.6 0.85", style="rounded"]; - 48[label = "build_industrial_production_per_node", color = "0.26 0.6 0.85", style="rounded"]; - 49[label = "build_industrial_distribution_key", color = "0.13 0.6 0.85", style="rounded"]; - 50[label = "build_industrial_production_per_country_tomorrow\nplanning_horizons: 2030", color = "0.32 0.6 0.85", style="rounded"]; - 51[label = "build_industrial_energy_demand_per_node_today", color = "0.48 0.6 0.85", style="rounded"]; - 52[label = "build_hourly_heat_demand", color = "0.28 0.6 0.85", style="rounded"]; - 53[label = "build_daily_heat_demand\nscope: total", color = "0.28 0.6 0.85", style="rounded"]; - 54[label = "build_district_heat_share\nplanning_horizons: 2030", color = "0.52 0.6 0.85", style="rounded"]; - 55[label = "build_temperature_profiles\nscope: rural", color = "0.04 0.6 0.85", style="rounded"]; - 56[label = "build_temperature_profiles\nscope: urban", color = "0.04 0.6 0.85", style="rounded"]; - 57[label = "build_cop_profiles", color = "0.38 0.6 0.85", style="rounded"]; - 58[label = "copy_config", color = "0.19 0.6 0.85", style="rounded"]; - 59[label = "plot_power_network", color = "0.60 0.6 0.85", style="rounded"]; - 60[label = "plot_hydrogen_network", color = "0.27 0.6 0.85", style="rounded"]; - 61[label = "plot_gas_network", color = "0.08 0.6 0.85", style="rounded"]; + 0[label = "all", color = "0.66 0.6 0.85", style="rounded"]; + 1[label = "plot_summary", color = "0.20 0.6 0.85", style="rounded"]; + 2[label = "make_summary", color = "0.02 0.6 0.85", style="rounded"]; + 3[label = "solve_sector_network", color = "0.11 0.6 0.85", style="rounded"]; + 4[label = "prepare_sector_network\nsector_opts: CO2L0-24h-T-H-B-I-A-dist1", color = "0.22 0.6 0.85", style="rounded"]; + 5[label = "build_renewable_profiles\ntechnology: offwind-ac", color = "0.26 0.6 0.85", style="rounded"]; + 6[label = "base_network", color = "0.53 0.6 0.85", style="rounded"]; + 7[label = "build_shapes", color = "0.04 0.6 0.85", style="rounded"]; + 8[label = "retrieve_databundle", color = "0.49 0.6 0.85", style="rounded"]; + 9[label = "retrieve_natura_raster", color = "0.46 0.6 0.85", style="rounded"]; + 10[label = "build_ship_raster", color = "0.29 0.6 0.85", style="rounded"]; + 11[label = "retrieve_ship_raster", color = "0.42 0.6 0.85", style="rounded"]; + 12[label = "retrieve_cutout\ncutout: be-03-2013-era5", color = "0.27 0.6 0.85", style="rounded"]; + 13[label = "build_renewable_profiles\ntechnology: offwind-dc", color = "0.26 0.6 0.85", style="rounded"]; + 14[label = "cluster_gas_network", color = "0.48 0.6 0.85", style="rounded"]; + 15[label = "build_gas_network", color = "0.27 0.6 0.85", style="rounded"]; + 16[label = "retrieve_gas_infrastructure_data", color = "0.38 0.6 0.85", style="rounded"]; + 17[label = "cluster_network\nclusters: 5", color = "0.58 0.6 0.85", style="rounded"]; + 18[label = "simplify_network\nsimpl: ", color = "0.55 0.6 0.85", style="rounded"]; + 19[label = "add_electricity", color = "0.37 0.6 0.85", style="rounded"]; + 20[label = "build_renewable_profiles\ntechnology: solar", color = "0.26 0.6 0.85", style="rounded"]; + 21[label = "build_renewable_profiles\ntechnology: onwind", color = "0.26 0.6 0.85", style="rounded"]; + 22[label = "retrieve_cost_data\nyear: 2030", color = "0.14 0.6 0.85", style="rounded"]; + 23[label = "build_powerplants", color = "0.64 0.6 0.85", style="rounded"]; + 24[label = "build_electricity_demand", color = "0.61 0.6 0.85", style="rounded"]; + 25[label = "retrieve_electricity_demand", color = "0.08 0.6 0.85", style="rounded"]; + 26[label = "retrieve_synthetic_electricity_demand", color = "0.36 0.6 0.85", style="rounded"]; + 27[label = "build_gas_input_locations", color = "0.44 0.6 0.85", style="rounded"]; + 28[label = "prepare_network\nll: v1.5\nopts: ", color = "0.25 0.6 0.85", style="rounded"]; + 29[label = "add_extra_components", color = "0.39 0.6 0.85", style="rounded"]; + 30[label = "retrieve_eurostat_data", color = "0.20 0.6 0.85", style="rounded"]; + 31[label = "build_population_weighted_energy_totals\nkind: energy", color = "0.58 0.6 0.85", style="rounded"]; + 32[label = "build_energy_totals", color = "0.44 0.6 0.85", style="rounded"]; + 33[label = "retrieve_sector_databundle", color = "0.60 0.6 0.85", style="rounded"]; + 34[label = "build_clustered_population_layouts", color = "0.46 0.6 0.85", style="rounded"]; + 35[label = "build_population_layouts", color = "0.43 0.6 0.85", style="rounded"]; + 36[label = "build_population_weighted_energy_totals\nkind: heat", color = "0.58 0.6 0.85", style="rounded"]; + 37[label = "build_heat_totals", color = "0.11 0.6 0.85", style="rounded"]; + 38[label = "build_shipping_demand", color = "0.16 0.6 0.85", style="rounded"]; + 39[label = "build_transport_demand", color = "0.04 0.6 0.85", style="rounded"]; + 40[label = "build_temperature_profiles\nscope: total", color = "0.28 0.6 0.85", style="rounded"]; + 41[label = "build_biomass_potentials\nplanning_horizons: 2030", color = "0.07 0.6 0.85", style="rounded"]; + 42[label = "build_salt_cavern_potentials", color = "0.47 0.6 0.85", style="rounded"]; + 43[label = "build_simplified_population_layouts", color = "0.29 0.6 0.85", style="rounded"]; + 44[label = "build_industrial_energy_demand_per_node", color = "0.39 0.6 0.85", style="rounded"]; + 45[label = "build_industry_sector_ratios_intermediate\nplanning_horizons: 2030", color = "0.57 0.6 0.85", style="rounded"]; + 46[label = "build_industry_sector_ratios", color = "0.55 0.6 0.85", style="rounded"]; + 47[label = "build_ammonia_production", color = "0.00 0.6 0.85", style="rounded"]; + 48[label = "build_industrial_energy_demand_per_country_today", color = "0.52 0.6 0.85", style="rounded"]; + 49[label = "build_industrial_production_per_country", color = "0.19 0.6 0.85", style="rounded"]; + 50[label = "build_industrial_production_per_node", color = "0.21 0.6 0.85", style="rounded"]; + 51[label = "build_industrial_distribution_key", color = "0.10 0.6 0.85", style="rounded"]; + 52[label = "build_industrial_production_per_country_tomorrow\nplanning_horizons: 2030", color = "0.63 0.6 0.85", style="rounded"]; + 53[label = "build_industrial_energy_demand_per_node_today", color = "0.18 0.6 0.85", style="rounded"]; + 54[label = "build_hourly_heat_demand", color = "0.13 0.6 0.85", style="rounded"]; + 55[label = "build_daily_heat_demand\nscope: total", color = "0.22 0.6 0.85", style="rounded"]; + 56[label = "build_district_heat_share\nplanning_horizons: 2030", color = "0.34 0.6 0.85", style="rounded"]; + 57[label = "build_temperature_profiles\nscope: rural", color = "0.28 0.6 0.85", style="rounded"]; + 58[label = "build_temperature_profiles\nscope: urban", color = "0.28 0.6 0.85", style="rounded"]; + 59[label = "build_cop_profiles", color = "0.65 0.6 0.85", style="rounded"]; + 60[label = "build_solar_thermal_profiles\nscope: total", color = "0.54 0.6 0.85", style="rounded"]; + 61[label = "build_solar_thermal_profiles\nscope: urban", color = "0.54 0.6 0.85", style="rounded"]; + 62[label = "build_solar_thermal_profiles\nscope: rural", color = "0.54 0.6 0.85", style="rounded"]; + 63[label = "plot_power_network_clustered", color = "0.15 0.6 0.85", style="rounded"]; + 64[label = "plot_power_network", color = "0.56 0.6 0.85", style="rounded"]; + 65[label = "plot_hydrogen_network", color = "0.60 0.6 0.85", style="rounded"]; + 66[label = "plot_gas_network", color = "0.53 0.6 0.85", style="rounded"]; 1 -> 0 2 -> 1 - 32 -> 1 + 30 -> 1 + 33 -> 1 3 -> 2 - 23 -> 2 - 19 -> 2 - 59 -> 2 - 60 -> 2 - 61 -> 2 + 22 -> 2 + 63 -> 2 + 64 -> 2 + 65 -> 2 + 66 -> 2 4 -> 3 5 -> 4 - 19 -> 4 + 13 -> 4 + 14 -> 4 + 27 -> 4 + 28 -> 4 + 30 -> 4 + 31 -> 4 + 36 -> 4 + 38 -> 4 + 39 -> 4 + 32 -> 4 + 33 -> 4 + 41 -> 4 + 22 -> 4 + 42 -> 4 + 18 -> 4 + 17 -> 4 + 34 -> 4 + 43 -> 4 + 44 -> 4 + 54 -> 4 + 56 -> 4 + 40 -> 4 + 57 -> 4 + 58 -> 4 + 59 -> 4 + 60 -> 4 + 61 -> 4 + 62 -> 4 6 -> 5 - 19 -> 5 + 8 -> 5 + 9 -> 5 + 10 -> 5 + 7 -> 5 12 -> 5 7 -> 6 - 14 -> 6 - 15 -> 6 - 18 -> 6 - 8 -> 6 - 19 -> 6 - 12 -> 6 - 20 -> 6 - 10 -> 6 - 21 -> 6 - 9 -> 6 8 -> 7 - 10 -> 7 - 11 -> 7 - 9 -> 7 - 12 -> 7 - 13 -> 7 - 9 -> 8 - 10 -> 9 - 9 -> 12 - 8 -> 12 - 8 -> 14 - 10 -> 14 - 11 -> 14 - 9 -> 14 - 12 -> 14 - 13 -> 14 - 8 -> 15 - 10 -> 15 - 11 -> 15 + 11 -> 10 + 12 -> 10 + 6 -> 13 + 8 -> 13 + 9 -> 13 + 10 -> 13 + 7 -> 13 + 12 -> 13 + 15 -> 14 + 17 -> 14 16 -> 15 - 9 -> 15 - 12 -> 15 - 13 -> 15 - 17 -> 16 - 13 -> 16 - 8 -> 18 - 10 -> 18 - 11 -> 18 - 16 -> 18 - 9 -> 18 - 12 -> 18 - 13 -> 18 + 18 -> 17 + 22 -> 17 + 19 -> 18 + 22 -> 18 + 6 -> 18 + 20 -> 19 + 21 -> 19 + 5 -> 19 + 13 -> 19 + 6 -> 19 + 22 -> 19 + 23 -> 19 + 8 -> 19 + 24 -> 19 + 7 -> 19 + 6 -> 20 8 -> 20 - 22 -> 21 - 24 -> 23 - 58 -> 23 + 9 -> 20 + 7 -> 20 + 12 -> 20 + 6 -> 21 + 8 -> 21 + 9 -> 21 + 7 -> 21 + 12 -> 21 + 6 -> 23 25 -> 24 - 28 -> 24 - 29 -> 24 - 31 -> 24 - 32 -> 24 - 33 -> 24 - 36 -> 24 - 37 -> 24 - 39 -> 24 - 19 -> 24 - 15 -> 24 - 18 -> 24 - 40 -> 24 - 5 -> 24 - 4 -> 24 - 34 -> 24 - 41 -> 24 - 42 -> 24 - 52 -> 24 - 54 -> 24 - 38 -> 24 - 55 -> 24 - 56 -> 24 - 57 -> 24 - 26 -> 25 - 4 -> 25 - 27 -> 26 - 27 -> 28 - 4 -> 28 - 30 -> 29 - 19 -> 29 - 4 -> 30 - 19 -> 30 - 9 -> 31 + 26 -> 24 + 16 -> 27 + 17 -> 27 + 29 -> 28 + 22 -> 28 + 17 -> 29 + 22 -> 29 32 -> 31 - 31 -> 33 - 34 -> 33 + 34 -> 31 + 7 -> 32 + 33 -> 32 + 30 -> 32 35 -> 34 - 4 -> 34 - 13 -> 34 - 9 -> 35 - 13 -> 35 - 9 -> 36 - 4 -> 36 - 31 -> 36 - 34 -> 37 - 33 -> 37 - 31 -> 37 + 17 -> 34 + 12 -> 34 + 7 -> 35 + 12 -> 35 + 37 -> 36 + 34 -> 36 32 -> 37 - 38 -> 37 - 35 -> 38 - 4 -> 38 - 13 -> 38 + 7 -> 38 + 17 -> 38 + 32 -> 38 + 34 -> 39 + 31 -> 39 32 -> 39 - 4 -> 39 - 10 -> 39 - 9 -> 39 - 32 -> 40 - 4 -> 40 - 35 -> 41 - 5 -> 41 - 13 -> 41 - 43 -> 42 - 48 -> 42 - 51 -> 42 - 44 -> 43 - 46 -> 43 - 47 -> 43 + 33 -> 39 + 40 -> 39 + 35 -> 40 + 17 -> 40 + 12 -> 40 + 33 -> 41 + 17 -> 41 + 8 -> 41 + 7 -> 41 + 33 -> 42 + 17 -> 42 + 35 -> 43 + 18 -> 43 + 12 -> 43 45 -> 44 - 32 -> 44 - 32 -> 45 - 32 -> 46 + 50 -> 44 + 53 -> 44 + 46 -> 45 + 48 -> 45 + 49 -> 45 47 -> 46 - 45 -> 47 - 32 -> 47 + 33 -> 46 + 33 -> 47 + 33 -> 48 49 -> 48 - 50 -> 48 - 4 -> 49 - 34 -> 49 - 32 -> 49 - 47 -> 50 - 49 -> 51 - 46 -> 51 - 53 -> 52 - 35 -> 53 - 4 -> 53 - 13 -> 53 - 31 -> 54 - 34 -> 54 + 47 -> 49 + 33 -> 49 + 30 -> 49 + 51 -> 50 + 52 -> 50 + 17 -> 51 + 34 -> 51 + 33 -> 51 + 49 -> 52 + 51 -> 53 + 48 -> 53 + 55 -> 54 35 -> 55 - 4 -> 55 - 13 -> 55 - 35 -> 56 - 4 -> 56 - 13 -> 56 - 38 -> 57 - 55 -> 57 - 56 -> 57 - 23 -> 59 - 4 -> 59 - 23 -> 60 - 4 -> 60 - 23 -> 61 - 4 -> 61 + 17 -> 55 + 12 -> 55 + 32 -> 56 + 34 -> 56 + 35 -> 57 + 17 -> 57 + 12 -> 57 + 35 -> 58 + 17 -> 58 + 12 -> 58 + 40 -> 59 + 57 -> 59 + 58 -> 59 + 35 -> 60 + 17 -> 60 + 12 -> 60 + 35 -> 61 + 17 -> 61 + 12 -> 61 + 35 -> 62 + 17 -> 62 + 12 -> 62 + 17 -> 63 + 3 -> 64 + 17 -> 64 + 3 -> 65 + 17 -> 65 + 3 -> 66 + 17 -> 66 } | @@ -429,386 +447,412 @@ workflow: graph[bgcolor=white, margin=0]; node[shape=box, style=rounded, fontname=sans, fontsize=10, penwidth=2]; edge[penwidth=2, color=grey]; - 0[label = "all", color = "0.46 0.6 0.85", style="rounded"]; - 1[label = "plot_summary", color = "0.40 0.6 0.85", style="rounded"]; - 2[label = "make_summary", color = "0.59 0.6 0.85", style="rounded"]; - 3[label = "plot_power_network_clustered", color = "0.17 0.6 0.85", style="rounded"]; - 4[label = "cluster_network\nclusters: 5", color = "0.49 0.6 0.85", style="rounded"]; - 5[label = "simplify_network\nsimpl: ", color = "0.16 0.6 0.85", style="rounded"]; - 6[label = "add_electricity", color = "0.32 0.6 0.85", style="rounded"]; - 7[label = "build_renewable_profiles\ntechnology: solar", color = "0.63 0.6 0.85", style="rounded"]; - 8[label = "base_network", color = "0.12 0.6 0.85", style="rounded"]; - 9[label = "build_shapes", color = "0.23 0.6 0.85", style="rounded"]; - 10[label = "retrieve_databundle", color = "0.61 0.6 0.85", style="rounded"]; - 11[label = "retrieve_natura_raster", color = "0.50 0.6 0.85", style="rounded"]; - 12[label = "build_bus_regions", color = "0.51 0.6 0.85", style="rounded"]; - 13[label = "retrieve_cutout\ncutout: be-03-2013-era5", color = "0.37 0.6 0.85", style="rounded,dashed"]; - 14[label = "build_renewable_profiles\ntechnology: onwind", color = "0.63 0.6 0.85", style="rounded"]; - 15[label = "build_renewable_profiles\ntechnology: offwind-ac", color = "0.63 0.6 0.85", style="rounded"]; - 16[label = "build_ship_raster", color = "0.24 0.6 0.85", style="rounded"]; - 17[label = "retrieve_ship_raster", color = "0.14 0.6 0.85", style="rounded,dashed"]; - 18[label = "build_renewable_profiles\ntechnology: offwind-dc", color = "0.63 0.6 0.85", style="rounded"]; - 19[label = "retrieve_cost_data\nyear: 2030", color = "0.04 0.6 0.85", style="rounded"]; - 20[label = "build_powerplants", color = "0.58 0.6 0.85", style="rounded"]; - 21[label = "build_electricity_demand", color = "0.04 0.6 0.85", style="rounded"]; - 22[label = "retrieve_electricity_demand", color = "0.62 0.6 0.85", style="rounded"]; - 23[label = "solve_sector_network_myopic", color = "0.30 0.6 0.85", style="rounded"]; - 24[label = "add_existing_baseyear", color = "0.34 0.6 0.85", style="rounded"]; - 25[label = "prepare_sector_network\nsector_opts: 24h-T-H-B-I-A-dist1", color = "0.42 0.6 0.85", style="rounded"]; - 26[label = "cluster_gas_network", color = "0.39 0.6 0.85", style="rounded"]; - 27[label = "build_gas_network", color = "0.59 0.6 0.85", style="rounded"]; - 28[label = "retrieve_gas_infrastructure_data", color = "0.15 0.6 0.85", style="rounded"]; - 29[label = "build_gas_input_locations", color = "0.07 0.6 0.85", style="rounded"]; - 30[label = "prepare_network\nll: v1.5\nopts: ", color = "0.56 0.6 0.85", style="rounded"]; - 31[label = "add_extra_components", color = "0.11 0.6 0.85", style="rounded"]; - 32[label = "build_energy_totals", color = "0.18 0.6 0.85", style="rounded"]; - 33[label = "retrieve_sector_databundle", color = "0.06 0.6 0.85", style="rounded"]; - 34[label = "build_population_weighted_energy_totals", color = "0.03 0.6 0.85", style="rounded"]; - 35[label = "build_clustered_population_layouts", color = "0.25 0.6 0.85", style="rounded"]; - 36[label = "build_population_layouts", color = "0.57 0.6 0.85", style="rounded"]; - 37[label = "build_shipping_demand", color = "0.45 0.6 0.85", style="rounded"]; - 38[label = "build_transport_demand", color = "0.18 0.6 0.85", style="rounded"]; - 39[label = "build_temperature_profiles\nscope: total", color = "0.54 0.6 0.85", style="rounded"]; - 40[label = "build_biomass_potentials\nplanning_horizons: 2030", color = "0.41 0.6 0.85", style="rounded"]; - 41[label = "build_salt_cavern_potentials", color = "0.02 0.6 0.85", style="rounded"]; - 42[label = "build_simplified_population_layouts", color = "0.15 0.6 0.85", style="rounded"]; - 43[label = "build_industrial_energy_demand_per_node", color = "0.47 0.6 0.85", style="rounded"]; - 44[label = "build_industry_sector_ratios_intermediate\nplanning_horizons: 2030", color = "0.31 0.6 0.85", style="rounded"]; - 45[label = "build_industry_sector_ratios", color = "0.48 0.6 0.85", style="rounded"]; - 46[label = "build_ammonia_production", color = "0.00 0.6 0.85", style="rounded"]; - 47[label = "build_industrial_energy_demand_per_country_today", color = "0.32 0.6 0.85", style="rounded"]; - 48[label = "build_industrial_production_per_country", color = "0.60 0.6 0.85", style="rounded"]; - 49[label = "build_industrial_production_per_node", color = "0.05 0.6 0.85", style="rounded"]; - 50[label = "build_industrial_distribution_key", color = "0.21 0.6 0.85", style="rounded"]; - 51[label = "build_industrial_production_per_country_tomorrow\nplanning_horizons: 2030", color = "0.33 0.6 0.85", style="rounded"]; - 52[label = "build_industrial_energy_demand_per_node_today", color = "0.62 0.6 0.85", style="rounded"]; - 53[label = "build_hourly_heat_demand", color = "0.28 0.6 0.85", style="rounded"]; - 54[label = "build_daily_heat_demand\nscope: total", color = "0.22 0.6 0.85", style="rounded"]; - 55[label = "build_district_heat_share\nplanning_horizons: 2030", color = "0.21 0.6 0.85", style="rounded"]; - 56[label = "build_temperature_profiles\nscope: rural", color = "0.54 0.6 0.85", style="rounded"]; - 57[label = "build_temperature_profiles\nscope: urban", color = "0.54 0.6 0.85", style="rounded"]; - 58[label = "build_cop_profiles", color = "0.52 0.6 0.85", style="rounded"]; - 59[label = "build_existing_heating_distribution", color = "0.09 0.6 0.85", style="rounded"]; - 60[label = "copy_config", color = "0.42 0.6 0.85", style="rounded"]; - 61[label = "solve_sector_network_myopic", color = "0.30 0.6 0.85", style="rounded"]; - 62[label = "add_brownfield", color = "0.10 0.6 0.85", style="rounded"]; - 63[label = "prepare_sector_network\nsector_opts: 24h-T-H-B-I-A-dist1", color = "0.42 0.6 0.85", style="rounded"]; - 64[label = "build_biomass_potentials\nplanning_horizons: 2040", color = "0.41 0.6 0.85", style="rounded"]; - 65[label = "retrieve_cost_data\nyear: 2040", color = "0.04 0.6 0.85", style="rounded"]; - 66[label = "build_industrial_energy_demand_per_node", color = "0.47 0.6 0.85", style="rounded"]; - 67[label = "build_industry_sector_ratios_intermediate\nplanning_horizons: 2040", color = "0.31 0.6 0.85", style="rounded"]; - 68[label = "build_industrial_production_per_node", color = "0.05 0.6 0.85", style="rounded"]; - 69[label = "build_industrial_production_per_country_tomorrow\nplanning_horizons: 2040", color = "0.33 0.6 0.85", style="rounded"]; - 70[label = "build_district_heat_share\nplanning_horizons: 2040", color = "0.21 0.6 0.85", style="rounded"]; - 71[label = "solve_sector_network_myopic", color = "0.30 0.6 0.85", style="rounded"]; - 72[label = "add_brownfield", color = "0.10 0.6 0.85", style="rounded"]; - 73[label = "prepare_sector_network\nsector_opts: 24h-T-H-B-I-A-dist1", color = "0.42 0.6 0.85", style="rounded"]; - 74[label = "build_biomass_potentials\nplanning_horizons: 2050", color = "0.41 0.6 0.85", style="rounded"]; - 75[label = "retrieve_cost_data\nyear: 2050", color = "0.04 0.6 0.85", style="rounded"]; - 76[label = "build_industrial_energy_demand_per_node", color = "0.47 0.6 0.85", style="rounded"]; - 77[label = "build_industry_sector_ratios_intermediate\nplanning_horizons: 2050", color = "0.31 0.6 0.85", style="rounded"]; - 78[label = "build_industrial_production_per_node", color = "0.05 0.6 0.85", style="rounded"]; - 79[label = "build_industrial_production_per_country_tomorrow\nplanning_horizons: 2050", color = "0.33 0.6 0.85", style="rounded"]; - 80[label = "build_district_heat_share\nplanning_horizons: 2050", color = "0.21 0.6 0.85", style="rounded"]; - 81[label = "plot_power_network", color = "0.48 0.6 0.85", style="rounded"]; - 82[label = "plot_power_network", color = "0.48 0.6 0.85", style="rounded"]; - 83[label = "plot_power_network", color = "0.48 0.6 0.85", style="rounded"]; - 84[label = "plot_hydrogen_network", color = "0.37 0.6 0.85", style="rounded"]; - 85[label = "plot_hydrogen_network", color = "0.37 0.6 0.85", style="rounded"]; - 86[label = "plot_hydrogen_network", color = "0.37 0.6 0.85", style="rounded"]; + 0[label = "all", color = "0.20 0.6 0.85", style="rounded"]; + 1[label = "plot_summary", color = "0.55 0.6 0.85", style="rounded"]; + 2[label = "make_summary", color = "0.21 0.6 0.85", style="rounded"]; + 3[label = "solve_sector_network_myopic", color = "0.50 0.6 0.85", style="rounded"]; + 4[label = "add_existing_baseyear", color = "0.38 0.6 0.85", style="rounded"]; + 5[label = "prepare_sector_network\nsector_opts: 24h-T-H-B-I-A-dist1", color = "0.53 0.6 0.85", style="rounded"]; + 6[label = "build_renewable_profiles\ntechnology: offwind-ac", color = "0.54 0.6 0.85", style="rounded"]; + 7[label = "base_network", color = "0.12 0.6 0.85", style="rounded"]; + 8[label = "build_shapes", color = "0.21 0.6 0.85", style="rounded"]; + 9[label = "retrieve_databundle", color = "0.41 0.6 0.85", style="rounded"]; + 10[label = "retrieve_natura_raster", color = "0.38 0.6 0.85", style="rounded"]; + 11[label = "build_ship_raster", color = "0.05 0.6 0.85", style="rounded"]; + 12[label = "retrieve_ship_raster", color = "0.25 0.6 0.85", style="rounded"]; + 13[label = "retrieve_cutout\ncutout: be-03-2013-era5", color = "0.23 0.6 0.85", style="rounded"]; + 14[label = "build_renewable_profiles\ntechnology: offwind-dc", color = "0.54 0.6 0.85", style="rounded"]; + 15[label = "cluster_gas_network", color = "0.16 0.6 0.85", style="rounded"]; + 16[label = "build_gas_network", color = "0.26 0.6 0.85", style="rounded"]; + 17[label = "retrieve_gas_infrastructure_data", color = "0.04 0.6 0.85", style="rounded"]; + 18[label = "cluster_network\nclusters: 5", color = "0.10 0.6 0.85", style="rounded"]; + 19[label = "simplify_network\nsimpl: ", color = "0.02 0.6 0.85", style="rounded"]; + 20[label = "add_electricity", color = "0.56 0.6 0.85", style="rounded"]; + 21[label = "build_renewable_profiles\ntechnology: solar", color = "0.54 0.6 0.85", style="rounded"]; + 22[label = "build_renewable_profiles\ntechnology: onwind", color = "0.54 0.6 0.85", style="rounded"]; + 23[label = "retrieve_cost_data\nyear: 2030", color = "0.16 0.6 0.85", style="rounded"]; + 24[label = "build_powerplants", color = "0.63 0.6 0.85", style="rounded"]; + 25[label = "build_electricity_demand", color = "0.57 0.6 0.85", style="rounded"]; + 26[label = "retrieve_electricity_demand", color = "0.27 0.6 0.85", style="rounded"]; + 27[label = "retrieve_synthetic_electricity_demand", color = "0.58 0.6 0.85", style="rounded"]; + 28[label = "build_gas_input_locations", color = "0.28 0.6 0.85", style="rounded"]; + 29[label = "prepare_network\nll: v1.5\nopts: ", color = "0.14 0.6 0.85", style="rounded"]; + 30[label = "add_extra_components", color = "0.14 0.6 0.85", style="rounded"]; + 31[label = "retrieve_eurostat_data", color = "0.58 0.6 0.85", style="rounded"]; + 32[label = "build_population_weighted_energy_totals\nkind: energy", color = "0.36 0.6 0.85", style="rounded"]; + 33[label = "build_energy_totals", color = "0.65 0.6 0.85", style="rounded"]; + 34[label = "retrieve_sector_databundle", color = "0.46 0.6 0.85", style="rounded"]; + 35[label = "build_clustered_population_layouts", color = "0.52 0.6 0.85", style="rounded"]; + 36[label = "build_population_layouts", color = "0.13 0.6 0.85", style="rounded"]; + 37[label = "build_population_weighted_energy_totals\nkind: heat", color = "0.36 0.6 0.85", style="rounded"]; + 38[label = "build_heat_totals", color = "0.31 0.6 0.85", style="rounded"]; + 39[label = "build_shipping_demand", color = "0.01 0.6 0.85", style="rounded"]; + 40[label = "build_transport_demand", color = "0.51 0.6 0.85", style="rounded"]; + 41[label = "build_temperature_profiles\nscope: total", color = "0.00 0.6 0.85", style="rounded"]; + 42[label = "build_biomass_potentials\nplanning_horizons: 2030", color = "0.18 0.6 0.85", style="rounded"]; + 43[label = "build_salt_cavern_potentials", color = "0.25 0.6 0.85", style="rounded"]; + 44[label = "build_simplified_population_layouts", color = "0.27 0.6 0.85", style="rounded"]; + 45[label = "build_industrial_energy_demand_per_node", color = "0.30 0.6 0.85", style="rounded"]; + 46[label = "build_industry_sector_ratios_intermediate\nplanning_horizons: 2030", color = "0.41 0.6 0.85", style="rounded"]; + 47[label = "build_industry_sector_ratios", color = "0.03 0.6 0.85", style="rounded"]; + 48[label = "build_ammonia_production", color = "0.37 0.6 0.85", style="rounded"]; + 49[label = "build_industrial_energy_demand_per_country_today", color = "0.10 0.6 0.85", style="rounded"]; + 50[label = "build_industrial_production_per_country", color = "0.03 0.6 0.85", style="rounded"]; + 51[label = "build_industrial_production_per_node", color = "0.63 0.6 0.85", style="rounded"]; + 52[label = "build_industrial_distribution_key", color = "0.17 0.6 0.85", style="rounded"]; + 53[label = "build_industrial_production_per_country_tomorrow\nplanning_horizons: 2030", color = "0.06 0.6 0.85", style="rounded"]; + 54[label = "build_industrial_energy_demand_per_node_today", color = "0.08 0.6 0.85", style="rounded"]; + 55[label = "build_hourly_heat_demand", color = "0.08 0.6 0.85", style="rounded"]; + 56[label = "build_daily_heat_demand\nscope: total", color = "0.60 0.6 0.85", style="rounded"]; + 57[label = "build_district_heat_share\nplanning_horizons: 2030", color = "0.32 0.6 0.85", style="rounded"]; + 58[label = "build_temperature_profiles\nscope: rural", color = "0.00 0.6 0.85", style="rounded"]; + 59[label = "build_temperature_profiles\nscope: urban", color = "0.00 0.6 0.85", style="rounded"]; + 60[label = "build_cop_profiles", color = "0.11 0.6 0.85", style="rounded"]; + 61[label = "build_solar_thermal_profiles\nscope: total", color = "0.01 0.6 0.85", style="rounded"]; + 62[label = "build_solar_thermal_profiles\nscope: urban", color = "0.01 0.6 0.85", style="rounded"]; + 63[label = "build_solar_thermal_profiles\nscope: rural", color = "0.01 0.6 0.85", style="rounded"]; + 64[label = "build_existing_heating_distribution", color = "0.40 0.6 0.85", style="rounded"]; + 65[label = "solve_sector_network_myopic", color = "0.50 0.6 0.85", style="rounded"]; + 66[label = "add_brownfield", color = "0.45 0.6 0.85", style="rounded"]; + 67[label = "prepare_sector_network\nsector_opts: 24h-T-H-B-I-A-dist1", color = "0.53 0.6 0.85", style="rounded"]; + 68[label = "build_biomass_potentials\nplanning_horizons: 2040", color = "0.18 0.6 0.85", style="rounded"]; + 69[label = "retrieve_cost_data\nyear: 2040", color = "0.16 0.6 0.85", style="rounded"]; + 70[label = "build_industrial_energy_demand_per_node", color = "0.30 0.6 0.85", style="rounded"]; + 71[label = "build_industry_sector_ratios_intermediate\nplanning_horizons: 2040", color = "0.41 0.6 0.85", style="rounded"]; + 72[label = "build_industrial_production_per_node", color = "0.63 0.6 0.85", style="rounded"]; + 73[label = "build_industrial_production_per_country_tomorrow\nplanning_horizons: 2040", color = "0.06 0.6 0.85", style="rounded"]; + 74[label = "build_district_heat_share\nplanning_horizons: 2040", color = "0.32 0.6 0.85", style="rounded"]; + 75[label = "solve_sector_network_myopic", color = "0.50 0.6 0.85", style="rounded"]; + 76[label = "add_brownfield", color = "0.45 0.6 0.85", style="rounded"]; + 77[label = "prepare_sector_network\nsector_opts: 24h-T-H-B-I-A-dist1", color = "0.53 0.6 0.85", style="rounded"]; + 78[label = "build_biomass_potentials\nplanning_horizons: 2050", color = "0.18 0.6 0.85", style="rounded"]; + 79[label = "retrieve_cost_data\nyear: 2050", color = "0.16 0.6 0.85", style="rounded"]; + 80[label = "build_industrial_energy_demand_per_node", color = "0.30 0.6 0.85", style="rounded"]; + 81[label = "build_industry_sector_ratios_intermediate\nplanning_horizons: 2050", color = "0.41 0.6 0.85", style="rounded"]; + 82[label = "build_industrial_production_per_node", color = "0.63 0.6 0.85", style="rounded"]; + 83[label = "build_industrial_production_per_country_tomorrow\nplanning_horizons: 2050", color = "0.06 0.6 0.85", style="rounded"]; + 84[label = "build_district_heat_share\nplanning_horizons: 2050", color = "0.32 0.6 0.85", style="rounded"]; + 85[label = "plot_power_network_clustered", color = "0.09 0.6 0.85", style="rounded"]; + 86[label = "plot_power_network", color = "0.43 0.6 0.85", style="rounded"]; + 87[label = "plot_power_network", color = "0.43 0.6 0.85", style="rounded"]; + 88[label = "plot_power_network", color = "0.43 0.6 0.85", style="rounded"]; + 89[label = "plot_hydrogen_network", color = "0.33 0.6 0.85", style="rounded"]; + 90[label = "plot_hydrogen_network", color = "0.33 0.6 0.85", style="rounded"]; + 91[label = "plot_hydrogen_network", color = "0.33 0.6 0.85", style="rounded"]; 1 -> 0 2 -> 1 - 33 -> 1 + 31 -> 1 + 34 -> 1 3 -> 2 + 65 -> 2 + 75 -> 2 23 -> 2 - 61 -> 2 - 71 -> 2 - 19 -> 2 - 81 -> 2 - 82 -> 2 - 83 -> 2 - 84 -> 2 85 -> 2 86 -> 2 + 87 -> 2 + 88 -> 2 + 89 -> 2 + 90 -> 2 + 91 -> 2 4 -> 3 + 23 -> 3 5 -> 4 + 24 -> 4 19 -> 4 + 18 -> 4 + 35 -> 4 + 23 -> 4 + 60 -> 4 + 64 -> 4 6 -> 5 + 14 -> 5 + 15 -> 5 + 28 -> 5 + 29 -> 5 + 31 -> 5 + 32 -> 5 + 37 -> 5 + 39 -> 5 + 40 -> 5 + 33 -> 5 + 34 -> 5 + 42 -> 5 + 23 -> 5 + 43 -> 5 19 -> 5 - 12 -> 5 + 18 -> 5 + 35 -> 5 + 44 -> 5 + 45 -> 5 + 55 -> 5 + 57 -> 5 + 41 -> 5 + 58 -> 5 + 59 -> 5 + 60 -> 5 + 61 -> 5 + 62 -> 5 + 63 -> 5 7 -> 6 - 14 -> 6 - 15 -> 6 - 18 -> 6 - 8 -> 6 - 19 -> 6 - 12 -> 6 - 20 -> 6 - 10 -> 6 - 21 -> 6 9 -> 6 + 10 -> 6 + 11 -> 6 + 8 -> 6 + 13 -> 6 8 -> 7 - 10 -> 7 - 11 -> 7 - 9 -> 7 - 12 -> 7 - 13 -> 7 9 -> 8 - 10 -> 9 - 9 -> 12 - 8 -> 12 - 8 -> 14 + 12 -> 11 + 13 -> 11 + 7 -> 14 + 9 -> 14 10 -> 14 11 -> 14 - 9 -> 14 - 12 -> 14 + 8 -> 14 13 -> 14 - 8 -> 15 - 10 -> 15 - 11 -> 15 16 -> 15 - 9 -> 15 - 12 -> 15 - 13 -> 15 + 18 -> 15 17 -> 16 - 13 -> 16 - 8 -> 18 - 10 -> 18 - 11 -> 18 - 16 -> 18 - 9 -> 18 - 12 -> 18 - 13 -> 18 + 19 -> 18 + 23 -> 18 + 20 -> 19 + 23 -> 19 + 7 -> 19 + 21 -> 20 + 22 -> 20 + 6 -> 20 + 14 -> 20 + 7 -> 20 + 23 -> 20 + 24 -> 20 + 9 -> 20 + 25 -> 20 8 -> 20 - 22 -> 21 - 24 -> 23 - 19 -> 23 - 60 -> 23 - 25 -> 24 - 20 -> 24 - 5 -> 24 - 4 -> 24 - 35 -> 24 - 19 -> 24 - 58 -> 24 - 59 -> 24 + 7 -> 21 + 9 -> 21 + 10 -> 21 + 8 -> 21 + 13 -> 21 + 7 -> 22 + 9 -> 22 + 10 -> 22 + 8 -> 22 + 13 -> 22 + 7 -> 24 26 -> 25 - 29 -> 25 - 30 -> 25 - 32 -> 25 - 33 -> 25 - 34 -> 25 - 37 -> 25 - 38 -> 25 - 40 -> 25 - 19 -> 25 - 15 -> 25 - 18 -> 25 - 41 -> 25 - 5 -> 25 - 4 -> 25 - 35 -> 25 - 42 -> 25 - 43 -> 25 - 53 -> 25 - 55 -> 25 - 39 -> 25 - 56 -> 25 - 57 -> 25 - 58 -> 25 - 27 -> 26 - 4 -> 26 - 28 -> 27 - 28 -> 29 - 4 -> 29 - 31 -> 30 - 19 -> 30 - 4 -> 31 - 19 -> 31 - 9 -> 32 + 27 -> 25 + 17 -> 28 + 18 -> 28 + 30 -> 29 + 23 -> 29 + 18 -> 30 + 23 -> 30 33 -> 32 - 32 -> 34 - 35 -> 34 + 35 -> 32 + 8 -> 33 + 34 -> 33 + 31 -> 33 36 -> 35 - 4 -> 35 + 18 -> 35 13 -> 35 - 9 -> 36 + 8 -> 36 13 -> 36 - 9 -> 37 - 4 -> 37 - 32 -> 37 - 35 -> 38 - 34 -> 38 - 32 -> 38 + 38 -> 37 + 35 -> 37 33 -> 38 - 39 -> 38 - 36 -> 39 - 4 -> 39 - 13 -> 39 + 8 -> 39 + 18 -> 39 + 33 -> 39 + 35 -> 40 + 32 -> 40 33 -> 40 - 4 -> 40 - 10 -> 40 - 9 -> 40 - 33 -> 41 - 4 -> 41 - 36 -> 42 - 5 -> 42 - 13 -> 42 - 44 -> 43 - 49 -> 43 - 52 -> 43 - 45 -> 44 - 47 -> 44 - 48 -> 44 + 34 -> 40 + 41 -> 40 + 36 -> 41 + 18 -> 41 + 13 -> 41 + 34 -> 42 + 18 -> 42 + 9 -> 42 + 8 -> 42 + 34 -> 43 + 18 -> 43 + 36 -> 44 + 19 -> 44 + 13 -> 44 46 -> 45 - 33 -> 45 - 33 -> 46 - 33 -> 47 + 51 -> 45 + 54 -> 45 + 47 -> 46 + 49 -> 46 + 50 -> 46 48 -> 47 - 46 -> 48 - 33 -> 48 + 34 -> 47 + 34 -> 48 + 34 -> 49 50 -> 49 - 51 -> 49 - 4 -> 50 - 35 -> 50 - 33 -> 50 - 48 -> 51 - 50 -> 52 - 47 -> 52 - 54 -> 53 - 36 -> 54 - 4 -> 54 - 13 -> 54 - 32 -> 55 - 35 -> 55 + 48 -> 50 + 34 -> 50 + 31 -> 50 + 52 -> 51 + 53 -> 51 + 18 -> 52 + 35 -> 52 + 34 -> 52 + 50 -> 53 + 52 -> 54 + 49 -> 54 + 56 -> 55 36 -> 56 - 4 -> 56 + 18 -> 56 13 -> 56 - 36 -> 57 - 4 -> 57 - 13 -> 57 - 39 -> 58 - 56 -> 58 - 57 -> 58 - 35 -> 59 - 34 -> 59 - 55 -> 59 - 62 -> 61 - 65 -> 61 - 60 -> 61 - 7 -> 62 - 14 -> 62 - 15 -> 62 + 33 -> 57 + 35 -> 57 + 36 -> 58 + 18 -> 58 + 13 -> 58 + 36 -> 59 + 18 -> 59 + 13 -> 59 + 41 -> 60 + 58 -> 60 + 59 -> 60 + 36 -> 61 + 18 -> 61 + 13 -> 61 + 36 -> 62 18 -> 62 - 5 -> 62 - 4 -> 62 - 63 -> 62 - 23 -> 62 - 65 -> 62 - 58 -> 62 - 26 -> 63 - 29 -> 63 - 30 -> 63 - 32 -> 63 - 33 -> 63 - 34 -> 63 - 37 -> 63 - 38 -> 63 - 64 -> 63 - 65 -> 63 - 15 -> 63 + 13 -> 62 + 36 -> 63 18 -> 63 - 41 -> 63 - 5 -> 63 - 4 -> 63 - 35 -> 63 - 42 -> 63 - 66 -> 63 - 53 -> 63 - 70 -> 63 - 39 -> 63 - 56 -> 63 - 57 -> 63 - 58 -> 63 - 33 -> 64 - 4 -> 64 - 10 -> 64 - 9 -> 64 + 13 -> 63 + 35 -> 64 + 32 -> 64 + 57 -> 64 + 66 -> 65 + 69 -> 65 + 21 -> 66 + 22 -> 66 + 6 -> 66 + 14 -> 66 + 19 -> 66 + 18 -> 66 67 -> 66 - 68 -> 66 - 52 -> 66 - 45 -> 67 - 47 -> 67 - 48 -> 67 - 50 -> 68 - 69 -> 68 - 48 -> 69 - 32 -> 70 - 35 -> 70 - 72 -> 71 - 75 -> 71 - 60 -> 71 - 7 -> 72 - 14 -> 72 - 15 -> 72 - 18 -> 72 - 5 -> 72 - 4 -> 72 + 3 -> 66 + 69 -> 66 + 60 -> 66 + 6 -> 67 + 14 -> 67 + 15 -> 67 + 28 -> 67 + 29 -> 67 + 31 -> 67 + 32 -> 67 + 37 -> 67 + 39 -> 67 + 40 -> 67 + 33 -> 67 + 34 -> 67 + 68 -> 67 + 69 -> 67 + 43 -> 67 + 19 -> 67 + 18 -> 67 + 35 -> 67 + 44 -> 67 + 70 -> 67 + 55 -> 67 + 74 -> 67 + 41 -> 67 + 58 -> 67 + 59 -> 67 + 60 -> 67 + 61 -> 67 + 62 -> 67 + 63 -> 67 + 34 -> 68 + 18 -> 68 + 9 -> 68 + 8 -> 68 + 71 -> 70 + 72 -> 70 + 54 -> 70 + 47 -> 71 + 49 -> 71 + 50 -> 71 + 52 -> 72 73 -> 72 - 61 -> 72 - 75 -> 72 - 58 -> 72 - 26 -> 73 - 29 -> 73 - 30 -> 73 - 32 -> 73 - 33 -> 73 - 34 -> 73 - 37 -> 73 - 38 -> 73 - 74 -> 73 - 75 -> 73 - 15 -> 73 - 18 -> 73 - 41 -> 73 - 5 -> 73 - 4 -> 73 - 35 -> 73 - 42 -> 73 - 76 -> 73 - 53 -> 73 - 80 -> 73 - 39 -> 73 - 56 -> 73 - 57 -> 73 - 58 -> 73 + 50 -> 73 33 -> 74 - 4 -> 74 - 10 -> 74 - 9 -> 74 + 35 -> 74 + 76 -> 75 + 79 -> 75 + 21 -> 76 + 22 -> 76 + 6 -> 76 + 14 -> 76 + 19 -> 76 + 18 -> 76 77 -> 76 - 78 -> 76 - 52 -> 76 - 45 -> 77 - 47 -> 77 - 48 -> 77 - 50 -> 78 - 79 -> 78 - 48 -> 79 - 32 -> 80 - 35 -> 80 - 23 -> 81 - 4 -> 81 - 61 -> 82 - 4 -> 82 - 71 -> 83 - 4 -> 83 - 23 -> 84 - 4 -> 84 - 61 -> 85 - 4 -> 85 - 71 -> 86 - 4 -> 86 + 65 -> 76 + 79 -> 76 + 60 -> 76 + 6 -> 77 + 14 -> 77 + 15 -> 77 + 28 -> 77 + 29 -> 77 + 31 -> 77 + 32 -> 77 + 37 -> 77 + 39 -> 77 + 40 -> 77 + 33 -> 77 + 34 -> 77 + 78 -> 77 + 79 -> 77 + 43 -> 77 + 19 -> 77 + 18 -> 77 + 35 -> 77 + 44 -> 77 + 80 -> 77 + 55 -> 77 + 84 -> 77 + 41 -> 77 + 58 -> 77 + 59 -> 77 + 60 -> 77 + 61 -> 77 + 62 -> 77 + 63 -> 77 + 34 -> 78 + 18 -> 78 + 9 -> 78 + 8 -> 78 + 81 -> 80 + 82 -> 80 + 54 -> 80 + 47 -> 81 + 49 -> 81 + 50 -> 81 + 52 -> 82 + 83 -> 82 + 50 -> 83 + 33 -> 84 + 35 -> 84 + 18 -> 85 + 3 -> 86 + 18 -> 86 + 65 -> 87 + 18 -> 87 + 75 -> 88 + 18 -> 88 + 3 -> 89 + 18 -> 89 + 65 -> 90 + 18 -> 90 + 75 -> 91 + 18 -> 91 } | diff --git a/rules/build_electricity.smk b/rules/build_electricity.smk index c074bdbd..c8d19d50 100644 --- a/rules/build_electricity.smk +++ b/rules/build_electricity.smk @@ -86,7 +86,9 @@ rule base_network: offshore_shapes=resources("offshore_shapes.geojson"), europe_shape=resources("europe_shape.geojson"), output: - resources("networks/base.nc"), + base_network=resources("networks/base.nc"), + regions_onshore=resources("regions_onshore.geojson"), + regions_offshore=resources("regions_offshore.geojson"), log: logs("base_network.log"), benchmark: @@ -127,27 +129,6 @@ rule build_shapes: "../scripts/build_shapes.py" -rule build_bus_regions: - params: - countries=config_provider("countries"), - input: - country_shapes=resources("country_shapes.geojson"), - offshore_shapes=resources("offshore_shapes.geojson"), - base_network=resources("networks/base.nc"), - output: - regions_onshore=resources("regions_onshore.geojson"), - regions_offshore=resources("regions_offshore.geojson"), - log: - logs("build_bus_regions.log"), - threads: 1 - resources: - mem_mb=1000, - conda: - "../envs/environment.yaml" - script: - "../scripts/build_bus_regions.py" - - if config["enable"].get("build_cutout", False): rule build_cutout: diff --git a/scripts/base_network.py b/scripts/base_network.py index d96a7e54..432813cf 100644 --- a/scripts/base_network.py +++ b/scripts/base_network.py @@ -5,10 +5,7 @@ # coding: utf-8 """ -Creates the network topology from a `ENTSO-E map extract. - -`_ (March 2022) as a PyPSA -network. +Creates the network topology from an `ENTSO-E map extract `_ (March 2022) as a PyPSA network. Relevant Settings ----------------- @@ -59,8 +56,19 @@ Outputs .. image:: img/base.png :scale: 33 % +- ``resources/regions_onshore.geojson``: + + .. image:: img/regions_onshore.png + :scale: 33 % + +- ``resources/regions_offshore.geojson``: + + .. image:: img/regions_offshore.png + :scale: 33 % + Description ----------- +Creates the network topology from an ENTSO-E map extract, and create Voronoi shapes for each bus representing both onshore and offshore regions. """ import logging @@ -75,11 +83,11 @@ import shapely import shapely.prepared import shapely.wkt import yaml -from _helpers import configure_logging, get_snapshots, set_scenario_config +from _helpers import REGION_COLS, configure_logging, get_snapshots, set_scenario_config from packaging.version import Version, parse from scipy import spatial from scipy.sparse import csgraph -from shapely.geometry import LineString, Point +from shapely.geometry import LineString, Point, Polygon PD_GE_2_2 = parse(pd.__version__) >= Version("2.2") @@ -779,9 +787,147 @@ def base_network( return n +def voronoi_partition_pts(points, outline): + """ + Compute the polygons of a voronoi partition of `points` within the polygon + `outline`. Taken from + https://github.com/FRESNA/vresutils/blob/master/vresutils/graph.py. + + Attributes + ---------- + points : Nx2 - ndarray[dtype=float] + outline : Polygon + Returns + ------- + polygons : N - ndarray[dtype=Polygon|MultiPolygon] + """ + points = np.asarray(points) + + if len(points) == 1: + polygons = [outline] + else: + xmin, ymin = np.amin(points, axis=0) + xmax, ymax = np.amax(points, axis=0) + xspan = xmax - xmin + yspan = ymax - ymin + + # to avoid any network positions outside all Voronoi cells, append + # the corners of a rectangle framing these points + vor = spatial.Voronoi( + np.vstack( + ( + points, + [ + [xmin - 3.0 * xspan, ymin - 3.0 * yspan], + [xmin - 3.0 * xspan, ymax + 3.0 * yspan], + [xmax + 3.0 * xspan, ymin - 3.0 * yspan], + [xmax + 3.0 * xspan, ymax + 3.0 * yspan], + ], + ) + ) + ) + + polygons = [] + for i in range(len(points)): + poly = Polygon(vor.vertices[vor.regions[vor.point_region[i]]]) + + if not poly.is_valid: + poly = poly.buffer(0) + + with np.errstate(invalid="ignore"): + poly = poly.intersection(outline) + + polygons.append(poly) + + return polygons + + +def build_bus_shapes(n, country_shapes, offshore_shapes, countries): + country_shapes = gpd.read_file(country_shapes).set_index("name")["geometry"] + offshore_shapes = gpd.read_file(offshore_shapes) + offshore_shapes = offshore_shapes.reindex(columns=REGION_COLS).set_index("name")[ + "geometry" + ] + + onshore_regions = [] + offshore_regions = [] + + for country in countries: + c_b = n.buses.country == country + + onshore_shape = country_shapes[country] + onshore_locs = ( + n.buses.loc[c_b & n.buses.onshore_bus] + .sort_values( + by="substation_lv", ascending=False + ) # preference for substations + .drop_duplicates(subset=["x", "y"], keep="first")[["x", "y"]] + ) + onshore_regions.append( + gpd.GeoDataFrame( + { + "name": onshore_locs.index, + "x": onshore_locs["x"], + "y": onshore_locs["y"], + "geometry": voronoi_partition_pts( + onshore_locs.values, onshore_shape + ), + "country": country, + } + ) + ) + + if country not in offshore_shapes.index: + continue + offshore_shape = offshore_shapes[country] + offshore_locs = n.buses.loc[c_b & n.buses.substation_off, ["x", "y"]] + offshore_regions_c = gpd.GeoDataFrame( + { + "name": offshore_locs.index, + "x": offshore_locs["x"], + "y": offshore_locs["y"], + "geometry": voronoi_partition_pts(offshore_locs.values, offshore_shape), + "country": country, + } + ) + offshore_regions_c = offshore_regions_c.loc[offshore_regions_c.area > 1e-2] + offshore_regions.append(offshore_regions_c) + + shapes = pd.concat(onshore_regions, ignore_index=True) + + return onshore_regions, offshore_regions, shapes + + +def append_bus_shapes(n, shapes, type): + """ + Append shapes to the network. If shapes with the same component and type + already exist, they will be removed. + + Parameters: + n (pypsa.Network): The network to which the shapes will be appended. + shapes (geopandas.GeoDataFrame): The shapes to be appended. + **kwargs: Additional keyword arguments used in `n.madd`. + + Returns: + None + """ + remove = n.shapes.query("component == 'Bus' and type == @type").index + n.mremove("Shape", remove) + + offset = n.shapes.index.astype(int).max() + 1 if not n.shapes.empty else 0 + shapes = shapes.rename(lambda x: int(x) + offset) + n.madd( + "Shape", + shapes.index, + geometry=shapes.geometry, + idx=shapes.name, + component="Bus", + type=type, + ) + + if __name__ == "__main__": if "snakemake" not in globals(): - from _helpers import mock_snakemake snakemake = mock_snakemake("base_network") @@ -803,5 +949,22 @@ if __name__ == "__main__": snakemake.config, ) + onshore_regions, offshore_regions, shapes = build_bus_shapes( + n, + snakemake.input.country_shapes, + snakemake.input.offshore_shapes, + snakemake.params.countries, + ) + + shapes.to_file(snakemake.output.regions_onshore) + append_bus_shapes(n, shapes, "onshore") + + if offshore_regions: + shapes = pd.concat(offshore_regions, ignore_index=True) + shapes.to_file(snakemake.output.regions_offshore) + append_bus_shapes(n, shapes, "offshore") + else: + offshore_shapes.to_frame().to_file(snakemake.output.regions_offshore) + n.meta = snakemake.config - n.export_to_netcdf(snakemake.output[0]) + n.export_to_netcdf(snakemake.output.base_network) diff --git a/scripts/build_bus_regions.py b/scripts/build_bus_regions.py deleted file mode 100644 index 05a7729e..00000000 --- a/scripts/build_bus_regions.py +++ /dev/null @@ -1,218 +0,0 @@ -# -*- coding: utf-8 -*- -# SPDX-FileCopyrightText: : 2017-2024 The PyPSA-Eur Authors -# -# SPDX-License-Identifier: MIT -""" -Creates Voronoi shapes for each bus representing both onshore and offshore -regions. - -Relevant Settings ------------------ - -.. code:: yaml - - countries: - -.. seealso:: - Documentation of the configuration file ``config/config.yaml`` at - :ref:`toplevel_cf` - -Inputs ------- - -- ``resources/country_shapes.geojson``: confer :ref:`shapes` -- ``resources/offshore_shapes.geojson``: confer :ref:`shapes` -- ``networks/base.nc``: confer :ref:`base` - -Outputs -------- - -- ``resources/regions_onshore.geojson``: - - .. image:: img/regions_onshore.png - :scale: 33 % - -- ``resources/regions_offshore.geojson``: - - .. image:: img/regions_offshore.png - :scale: 33 % - -Description ------------ -""" - -import logging - -import geopandas as gpd -import numpy as np -import pandas as pd -import pypsa -from _helpers import REGION_COLS, configure_logging, set_scenario_config -from scipy.spatial import Voronoi -from shapely.geometry import Polygon - -logger = logging.getLogger(__name__) - - -def voronoi_partition_pts(points, outline): - """ - Compute the polygons of a voronoi partition of `points` within the polygon - `outline`. Taken from - https://github.com/FRESNA/vresutils/blob/master/vresutils/graph.py. - - Attributes - ---------- - points : Nx2 - ndarray[dtype=float] - outline : Polygon - Returns - ------- - polygons : N - ndarray[dtype=Polygon|MultiPolygon] - """ - points = np.asarray(points) - - if len(points) == 1: - polygons = [outline] - else: - xmin, ymin = np.amin(points, axis=0) - xmax, ymax = np.amax(points, axis=0) - xspan = xmax - xmin - yspan = ymax - ymin - - # to avoid any network positions outside all Voronoi cells, append - # the corners of a rectangle framing these points - vor = Voronoi( - np.vstack( - ( - points, - [ - [xmin - 3.0 * xspan, ymin - 3.0 * yspan], - [xmin - 3.0 * xspan, ymax + 3.0 * yspan], - [xmax + 3.0 * xspan, ymin - 3.0 * yspan], - [xmax + 3.0 * xspan, ymax + 3.0 * yspan], - ], - ) - ) - ) - - polygons = [] - for i in range(len(points)): - poly = Polygon(vor.vertices[vor.regions[vor.point_region[i]]]) - - if not poly.is_valid: - poly = poly.buffer(0) - - with np.errstate(invalid="ignore"): - poly = poly.intersection(outline) - - polygons.append(poly) - - return polygons - - -def append_bus_shapes(n, shapes, type): - """ - Append shapes to the network. If shapes with the same component and type - already exist, they will be removed. - - Parameters: - n (pypsa.Network): The network to which the shapes will be appended. - shapes (geopandas.GeoDataFrame): The shapes to be appended. - **kwargs: Additional keyword arguments used in `n.madd`. - - Returns: - None - """ - remove = n.shapes.query("component == 'Bus' and type == @type").index - n.mremove("Shape", remove) - - offset = n.shapes.index.astype(int).max() + 1 if not n.shapes.empty else 0 - shapes = shapes.rename(lambda x: int(x) + offset) - n.madd( - "Shape", - shapes.index, - geometry=shapes.geometry, - idx=shapes.name, - component="Bus", - type=type, - ) - - -if __name__ == "__main__": - if "snakemake" not in globals(): - from _helpers import mock_snakemake - - snakemake = mock_snakemake("build_bus_regions") - configure_logging(snakemake) - set_scenario_config(snakemake) - - countries = snakemake.params.countries - - base_network = snakemake.input.base_network - n = pypsa.Network(base_network) - - country_shapes = gpd.read_file(snakemake.input.country_shapes).set_index("name")[ - "geometry" - ] - offshore_shapes = gpd.read_file(snakemake.input.offshore_shapes) - offshore_shapes = offshore_shapes.reindex(columns=REGION_COLS).set_index("name")[ - "geometry" - ] - - onshore_regions = [] - offshore_regions = [] - - for country in countries: - c_b = n.buses.country == country - - onshore_shape = country_shapes[country] - onshore_locs = ( - n.buses.loc[c_b & n.buses.onshore_bus] - .sort_values( - by="substation_lv", ascending=False - ) # preference for substations - .drop_duplicates(subset=["x", "y"], keep="first")[["x", "y"]] - ) - onshore_regions.append( - gpd.GeoDataFrame( - { - "name": onshore_locs.index, - "x": onshore_locs["x"], - "y": onshore_locs["y"], - "geometry": voronoi_partition_pts( - onshore_locs.values, onshore_shape - ), - "country": country, - } - ) - ) - - if country not in offshore_shapes.index: - continue - offshore_shape = offshore_shapes[country] - offshore_locs = n.buses.loc[c_b & n.buses.substation_off, ["x", "y"]] - offshore_regions_c = gpd.GeoDataFrame( - { - "name": offshore_locs.index, - "x": offshore_locs["x"], - "y": offshore_locs["y"], - "geometry": voronoi_partition_pts(offshore_locs.values, offshore_shape), - "country": country, - } - ) - offshore_regions_c = offshore_regions_c.loc[offshore_regions_c.area > 1e-2] - offshore_regions.append(offshore_regions_c) - - shapes = pd.concat(onshore_regions, ignore_index=True) - shapes.to_file(snakemake.output.regions_onshore) - append_bus_shapes(n, shapes, "onshore") - - if offshore_regions: - shapes = pd.concat(offshore_regions, ignore_index=True) - shapes.to_file(snakemake.output.regions_offshore) - append_bus_shapes(n, shapes, "offshore") - - else: - offshore_shapes.to_frame().to_file(snakemake.output.regions_offshore) - - # save network with shapes - n.export_to_netcdf(base_network) diff --git a/scripts/cluster_network.py b/scripts/cluster_network.py index f58e5f8b..87762b36 100644 --- a/scripts/cluster_network.py +++ b/scripts/cluster_network.py @@ -135,7 +135,7 @@ import pypsa import seaborn as sns from _helpers import configure_logging, set_scenario_config, update_p_nom_max from add_electricity import load_costs -from build_bus_regions import append_bus_shapes +from base_network import append_bus_shapes from packaging.version import Version, parse from pypsa.clustering.spatial import ( busmap_by_greedy_modularity, diff --git a/scripts/simplify_network.py b/scripts/simplify_network.py index 8f2a84cd..558e4cf2 100644 --- a/scripts/simplify_network.py +++ b/scripts/simplify_network.py @@ -95,7 +95,7 @@ import pypsa import scipy as sp from _helpers import configure_logging, set_scenario_config, update_p_nom_max from add_electricity import load_costs -from build_bus_regions import append_bus_shapes +from base_network import append_bus_shapes from cluster_network import cluster_regions, clustering_for_n_clusters from pypsa.clustering.spatial import ( aggregateoneport,