fix p_nom_min of renewable generators for myopic approach

as described in https://github.com/PyPSA/pypsa-eur/issues/727
This commit is contained in:
martavp 2023-08-22 08:31:46 +02:00
parent 1fc83b793d
commit 2391a5c4e9

View File

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