From 98d2c4dd911b6d0157ea11691b057f32837a1760 Mon Sep 17 00:00:00 2001 From: Thomas Gilon Date: Thu, 11 Apr 2024 10:54:25 +0200 Subject: [PATCH] Fix p_nom_min of renewables generators for myopic approach and add check of existing capacities in add_land_use_constraint_m --- doc/release_notes.rst | 2 ++ scripts/solve_network.py | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/doc/release_notes.rst b/doc/release_notes.rst index d42b149f8..d9c692449 100644 --- a/doc/release_notes.rst +++ b/doc/release_notes.rst @@ -181,6 +181,8 @@ Upcoming Release * Fix custom busmap read in `cluster_network`. +* Fix p_nom_min of renewables generators for myopic approach and add check of existing capacities in `add_land_use_constraint_m`. + PyPSA-Eur 0.10.0 (19th February 2024) ===================================== diff --git a/scripts/solve_network.py b/scripts/solve_network.py index 0f6725c70..b8819a19b 100644 --- a/scripts/solve_network.py +++ b/scripts/solve_network.py @@ -159,6 +159,9 @@ def _add_land_use_constraint_m(n, planning_horizons, config): current_horizon = snakemake.wildcards.planning_horizons for carrier in ["solar", "onwind", "offwind-ac", "offwind-dc"]: + extendable_i = (n.generators.carrier == carrier) & n.generators.p_nom_extendable + n.generators.loc[extendable_i, "p_nom_min"] = 0 + existing = n.generators.loc[n.generators.carrier == carrier, "p_nom"] ind = list( {i.split(sep=" ")[0] + " " + i.split(sep=" ")[1] for i in existing.index} @@ -180,6 +183,19 @@ def _add_land_use_constraint_m(n, planning_horizons, config): sel_p_year ].rename(lambda x: x[:-4] + current_horizon) + # check if existing capacities are larger than technical potential + existing_large = n.generators[ + n.generators["p_nom_min"] > n.generators["p_nom_max"] + ].index + if len(existing_large): + logger.warning( + f"Existing capacities larger than technical potential for {existing_large},\ + adjust technical potential to existing capacities" + ) + n.generators.loc[existing_large, "p_nom_max"] = n.generators.loc[ + existing_large, "p_nom_min" + ] + n.generators.p_nom_max.clip(lower=0, inplace=True)