From b1cbef9322af50a95bb52e1e5e90e86a269d44fd Mon Sep 17 00:00:00 2001 From: mark-hammond Date: Fri, 5 Jun 2026 16:26:01 +0100 Subject: [PATCH] Guard the v_nom voltage floor for networks with no lines (Zonal) apply_*_overrides indexes network.lines['v_nom'] when min_bm_constraint_voltage_kv > 0, but the Zonal network models inter-zone links and has no lines / no 'v_nom' column, so the solve raises KeyError. Skip the voltage floor when there are no lines. --- scripts/solve/solve_network.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/solve/solve_network.py b/scripts/solve/solve_network.py index f56ea29..b8c7976 100644 --- a/scripts/solve/solve_network.py +++ b/scripts/solve/solve_network.py @@ -439,7 +439,9 @@ def apply_line_rating_overrides(network, scenario_config, logger): # ── 1. Voltage floor ───────────────────────────────────────────────────── min_v = float(transmission.get('min_bm_constraint_voltage_kv', 0)) - if min_v > 0: + # Skip when the network has no lines (e.g. the Zonal network models inter-zone + # links and carries no lines / no 'v_nom' column) — indexing it would KeyError. + if min_v > 0 and not network.lines.empty and 'v_nom' in network.lines.columns: # Only applies to lines — transformers span two voltage levels so v_nom # is ambiguous, and transformer constraints are not the source of loop-flow # artefacts in the Highland 132 kV network.