Skip to content

Commit

Permalink
Bug fix: Wrongfully dropped DC bus regions (regions_onshore_base) (#1507
Browse files Browse the repository at this point in the history
)

* Fixed issue where DC bus regions where dropped due to missing converter busmap.

* Fixed issue where DC bus regions where dropped due to missing converter busmap.

* Added release notes for bugfix.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Undo changes in build_electricity.smk

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Fabian Neumann <[email protected]>
  • Loading branch information
3 people authored Jan 24, 2025
1 parent 1d8bb3d commit 2fec716
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
3 changes: 2 additions & 1 deletion doc/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,9 @@ Upcoming Release

* Update locations and capacities of ammonia plants.

* Updating all base shapes (country_shapes, europe_shape, nuts3_shapes, ...). The workflow has been modified to use higher resolution and more harmonised shapes (NUTS3 2021 01M data and OSM administration level 1 for non-NUTS3 countries, such as BA, MD, UA, and XK). Data sources for population and GDP p.c. have been updated to JRC ARDECO https://urban.jrc.ec.europa.eu/ardeco/ -- 2019 values are used. `build_gdp_pop_non_nuts3` (originally created to build regional GDP p.c. and population data for MD and UA) is now integrated into `build_shapes` and extended to build regional values for all non-NUTS3 countries using cutouts of the updated datasets `GDP_per_capita_PPP_1990_2015_v2.nc` and `ppp_2019_1km_Aggregated.tif`,
* Bugfix: Fixed issue where DC bus regions were dropped in `regions_onshore_base_s.geojson` and `regions_onshore_base_s_{clusters}.geojson` due to missing converter busmap.

* Updating all base shapes (country_shapes, europe_shape, nuts3_shapes, ...). The workflow has been modified to use higher resolution and more harmonised shapes (NUTS3 2021 01M data and OSM administration level 1 for non-NUTS3 countries, such as BA, MD, UA, and XK). Data sources for population and GDP p.c. have been updated to JRC ARDECO https://urban.jrc.ec.europa.eu/ardeco/ -- 2019 values are used. `build_gdp_pop_non_nuts3` (originally created to build regional GDP p.c. and population data for MD and UA) is now integrated into `build_shapes` and extended to build regional values for all non-NUTS3 countries using cutouts of the updated datasets `GDP_per_capita_PPP_1990_2015_v2.nc` and `ppp_2019_1km_Aggregated.tif`,


PyPSA-Eur 0.13.0 (13th September 2024)
Expand Down
6 changes: 3 additions & 3 deletions rules/build_electricity.smk
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ rule build_electricity_demand:
log:
logs("build_electricity_demand.log"),
benchmark:
benchmarks("build_electricity_demand"),
benchmarks("build_electricity_demand")
resources:
mem_mb=5000,
conda:
Expand Down Expand Up @@ -348,7 +348,7 @@ rule build_monthly_prices:
log:
logs("build_monthly_prices.log"),
benchmark:
benchmarks("build_monthly_prices"),
benchmarks("build_monthly_prices")
threads: 1
resources:
mem_mb=5000,
Expand Down Expand Up @@ -378,7 +378,7 @@ rule build_hydro_profile:
log:
logs("build_hydro_profile.log"),
benchmark:
benchmarks("build_hydro_profile"),
benchmarks("build_hydro_profile")
resources:
mem_mb=5000,
conda:
Expand Down
2 changes: 1 addition & 1 deletion rules/retrieve.smk
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ if config["enable"]["retrieve"] and config["enable"].get("retrieve_databundle",
log:
"logs/retrieve_databundle.log",
benchmark:
"benchmarks/retrieve_databundle",
"benchmarks/retrieve_databundle"
resources:
mem_mb=1000,
retries: 2
Expand Down
11 changes: 9 additions & 2 deletions scripts/simplify_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,9 @@ def remove_converters(n: pypsa.Network) -> pypsa.Network:
-------
n (pypsa.Network): The network object with all converters removed.
"""
# Initialise converter_map
converter_map = n.buses.index.to_series()

# Extract converters
converters = n.links.query("carrier == ''")[["bus0", "bus1"]]
converters["bus0_carrier"] = converters["bus0"].map(n.buses.carrier)
Expand All @@ -402,6 +405,8 @@ def remove_converters(n: pypsa.Network) -> pypsa.Network:

# Dictionary for remapping
dict_dc_to_ac = dict(zip(converters["dc_bus"], converters["ac_bus"]))
# Update converter map
converter_map = converter_map.replace(dict_dc_to_ac)

# Remap all buses that were originally connected to the converter to the connected AC bus
n.links["bus0"] = n.links["bus0"].replace(dict_dc_to_ac)
Expand All @@ -411,7 +416,7 @@ def remove_converters(n: pypsa.Network) -> pypsa.Network:
n.links = n.links.loc[~n.links.index.isin(converters.index)]
n.buses = n.buses.loc[~n.buses.index.isin(converters["dc_bus"])]

return n
return n, converter_map


if __name__ == "__main__":
Expand All @@ -432,7 +437,9 @@ def remove_converters(n: pypsa.Network) -> pypsa.Network:
n, trafo_map = simplify_network_to_380(n, linetype_380)
busmaps = [trafo_map]

n = remove_converters(n)
n, converter_map = remove_converters(n)
busmaps.append(converter_map)

n, simplify_links_map = simplify_links(n, params.p_max_pu)
busmaps.append(simplify_links_map)

Expand Down

0 comments on commit 2fec716

Please sign in to comment.