Fix p_nom_min of renewables generators for myopic approach and add check of existing capacities in add_land_use_constraint_m

This commit is contained in:
Thomas Gilon 2024-04-11 10:54:25 +02:00
parent 5ecd56d53c
commit 98d2c4dd91
2 changed files with 18 additions and 0 deletions

View File

@ -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)
=====================================

View File

@ -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)