From 2391a5c4e90df3a5184a476514ddc6739d85b521 Mon Sep 17 00:00:00 2001 From: martavp Date: Tue, 22 Aug 2023 08:31:46 +0200 Subject: [PATCH] fix p_nom_min of renewable generators for myopic approach as described in https://github.com/PyPSA/pypsa-eur/issues/727 --- scripts/solve_network.py | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/scripts/solve_network.py b/scripts/solve_network.py index 8eccef19..a3a3f58c 100644 --- a/scripts/solve_network.py +++ b/scripts/solve_network.py @@ -51,6 +51,9 @@ def _add_land_use_constraint(n): # warning: this will miss existing offwind which is not classed AC-DC and has carrier 'offwind' 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 + ext_i = (n.generators.carrier == carrier) & ~n.generators.p_nom_extendable existing = ( n.generators.loc[ext_i, "p_nom"] @@ -60,18 +63,18 @@ def _add_land_use_constraint(n): existing.index += " " + carrier + "-" + snakemake.wildcards.planning_horizons n.generators.loc[existing.index, "p_nom_max"] -= existing - # 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" - ] + # # 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)