tidy code
This commit is contained in:
parent
42f11752ca
commit
deba2a4ed5
@ -124,31 +124,25 @@ def disable_grid_expansion_if_LV_limit_hit(n):
|
|||||||
if not "lv_limit" in n.global_constraints.index:
|
if not "lv_limit" in n.global_constraints.index:
|
||||||
return
|
return
|
||||||
|
|
||||||
# calculate minimum LV
|
total_expansion = (
|
||||||
attr = "nom_min"
|
n.lines.eval("s_nom_min * length").sum()
|
||||||
dc = n.links.index[n.links.carrier == "DC"]
|
+ n.links.query("carrier == 'DC'").eval("p_nom_min * length").sum()
|
||||||
tot = (n.lines["s_" + attr] * n.lines["length"]).sum() + (
|
|
||||||
n.links.loc[dc, "p_" + attr] * n.links.loc[dc, "length"]
|
|
||||||
).sum()
|
).sum()
|
||||||
|
|
||||||
diff = n.global_constraints.at["lv_limit", "constant"] - tot
|
lv_limit = n.global_constraints.at["lv_limit", "constant"]
|
||||||
|
|
||||||
# allow small numerical differences
|
# allow small numerical differences
|
||||||
limit = 1
|
if lv_limit - total_expansion < 1:
|
||||||
|
|
||||||
if diff < limit:
|
|
||||||
logger.info(
|
logger.info(
|
||||||
f"LV is already reached (gap {diff}), disabling expansion and LV limit"
|
f"LV is already reached (gap {diff} MWkm), disabling expansion and LV limit"
|
||||||
)
|
)
|
||||||
expandable_acs = n.lines.index[n.lines.s_nom_extendable]
|
extendable_acs = n.lines.query("s_nom_extendable").index
|
||||||
n.lines.loc[expandable_acs, "s_nom_extendable"] = False
|
n.lines.loc[extendable_acs, "s_nom_extendable"] = False
|
||||||
n.lines.loc[expandable_acs, "s_nom"] = n.lines.loc[expandable_acs, "s_nom_min"]
|
n.lines.loc[extendable_acs, "s_nom"] = n.lines.loc[extendable_acs, "s_nom_min"]
|
||||||
|
|
||||||
expandable_dcs = n.links.index[
|
extendable_dcs = n.links.query("carrier == 'DC' and p_nom_extendable").index
|
||||||
n.links.p_nom_extendable & (n.links.carrier == "DC")
|
n.links.loc[extendable_dcs, "p_nom_extendable"] = False
|
||||||
]
|
n.links.loc[extendable_dcs, "p_nom"] = n.links.loc[extendable_dcs, "p_nom_min"]
|
||||||
n.links.loc[expandable_dcs, "p_nom_extendable"] = False
|
|
||||||
n.links.loc[expandable_dcs, "p_nom"] = n.links.loc[expandable_dcs, "p_nom_min"]
|
|
||||||
|
|
||||||
n.global_constraints.drop("lv_limit", inplace=True)
|
n.global_constraints.drop("lv_limit", inplace=True)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user