From af640480acc081465513e8bc4532b5a271f91b03 Mon Sep 17 00:00:00 2001 From: Emmanuel Bolarinwa Date: Fri, 12 Jul 2024 09:46:51 +0100 Subject: [PATCH] fix to avoid negative objective value (#961) * fix to avoid negative objective value * revert change * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * added rebase voltage for buses * added release note --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- doc/release_notes.rst | 2 ++ scripts/simplify_network.py | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/doc/release_notes.rst b/doc/release_notes.rst index f7e8232b7..e90f8f8b9 100644 --- a/doc/release_notes.rst +++ b/doc/release_notes.rst @@ -48,6 +48,8 @@ E.g. if a new rule becomes available describe how to use it `snakemake -j1 run_t * Create files where the code outputs the value of the objective function. `PR #1033 `__ +* Minor bug-fixing for s_nom_min. `PR #961 `__ + PyPSA-Earth 0.3.0 ================= diff --git a/scripts/simplify_network.py b/scripts/simplify_network.py index 30d60e32f..72a44355d 100644 --- a/scripts/simplify_network.py +++ b/scripts/simplify_network.py @@ -126,8 +126,9 @@ def simplify_network_to_base_voltage(n, linetype, base_voltage): are moved from their starting bus to their ending bus. The corresponding starting buses are removed as well. """ - logger.info(f"Mapping all network lines onto a single {int(base_voltage)}kV layer") + logger.info(f"Mapping all network lines onto a single {int(base_voltage)}kV layer") + n.buses["v_nom"] = base_voltage n.lines["type"] = linetype n.lines["v_nom"] = base_voltage n.lines["i_nom"] = n.line_types.i_nom[linetype] @@ -1100,6 +1101,7 @@ def merge_isolated_nodes(n, threshold, aggregation_strategies=dict()): "substation_lv", "substation_off", }.intersection(n.buses.columns) + n.buses = n.buses.drop(buses_c, axis=1) update_p_nom_max(n) @@ -1111,6 +1113,7 @@ def merge_isolated_nodes(n, threshold, aggregation_strategies=dict()): s_threshold_fetch_isolated = cluster_config.get("s_threshold_fetch_isolated", False) n = drop_isolated_nodes(n, threshold=p_threshold_drop_isolated) + if p_threshold_merge_isolated: n, merged_nodes_map = merge_isolated_nodes( n,