Fix disabling transmission limit for volume limit type

This commit is contained in:
Koen van Greevenbroek 2024-05-21 15:47:11 +00:00
parent 0370deebca
commit b6fa0043bf

View File

@ -132,22 +132,20 @@ def disable_grid_expansion_if_limit_hit(n):
minimum and extendable is turned off; the corresponding global minimum and extendable is turned off; the corresponding global
constraint is then dropped. constraint is then dropped.
""" """
cols = {"cost": "capital_cost", "volume": "length"} types = {"expansion_cost": "capital_cost", "volume_expansion": "length"}
for limit_type in ["cost", "volume"]: for limit_type in types:
glcs = n.global_constraints.query( glcs = n.global_constraints.query(f"type == 'transmission_{limit_type}_limit'")
f"type == 'transmission_expansion_{limit_type}_limit'"
)
for name, glc in glcs.iterrows(): for name, glc in glcs.iterrows():
total_expansion = ( total_expansion = (
( (
n.lines.query("s_nom_extendable") n.lines.query("s_nom_extendable")
.eval(f"s_nom_min * {cols[limit_type]}") .eval(f"s_nom_min * {types[limit_type]}")
.sum() .sum()
) )
+ ( + (
n.links.query("carrier == 'DC' and p_nom_extendable") n.links.query("carrier == 'DC' and p_nom_extendable")
.eval(f"p_nom_min * {cols[limit_type]}") .eval(f"p_nom_min * {types[limit_type]}")
.sum() .sum()
) )
).sum() ).sum()