add_brownfield: disable grid expansion if LV already hit
Numerical problems were causing infeasibilities otherwise
This commit is contained in:
parent
00e86e6435
commit
326ed63329
@ -119,6 +119,32 @@ def add_brownfield(n, n_p, year):
|
|||||||
n.links.loc[new_pipes, "p_nom"] = 0.0
|
n.links.loc[new_pipes, "p_nom"] = 0.0
|
||||||
n.links.loc[new_pipes, "p_nom_min"] = 0.0
|
n.links.loc[new_pipes, "p_nom_min"] = 0.0
|
||||||
|
|
||||||
|
def disable_grid_expansion_if_LV_limit_hit(n):
|
||||||
|
if not "lv_limit" in n.global_constraints.index:
|
||||||
|
return
|
||||||
|
|
||||||
|
#calculate minimum LV
|
||||||
|
attr = "nom_min"
|
||||||
|
dc = n.links.index[n.links.carrier == "DC"]
|
||||||
|
tot = (n.lines["s_" + attr]*n.lines["length"]).sum() + (n.links.loc[dc,"p_" + attr]*n.links.loc[dc,"length"]).sum()
|
||||||
|
|
||||||
|
diff = n.global_constraints.at["lv_limit","constant"]-tot
|
||||||
|
|
||||||
|
#allow small numerical differences
|
||||||
|
limit = 1
|
||||||
|
|
||||||
|
if diff < limit:
|
||||||
|
logger.info(f"LV is already reached (gap {diff}), disabling expansion and LV limit")
|
||||||
|
expandable_acs = n.lines.index[n.lines.s_nom_extendable]
|
||||||
|
n.lines.loc[expandable_acs,"s_nom_extendable"] = False
|
||||||
|
n.lines.loc[expandable_acs,"s_nom"] = n.lines.loc[expandable_acs,"s_nom_min"]
|
||||||
|
|
||||||
|
expandable_dcs = n.links.index[n.links.p_nom_extendable & (n.links.carrier == "DC")]
|
||||||
|
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)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
if "snakemake" not in globals():
|
if "snakemake" not in globals():
|
||||||
@ -150,5 +176,7 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
add_brownfield(n, n_p, year)
|
add_brownfield(n, n_p, year)
|
||||||
|
|
||||||
|
disable_grid_expansion_if_LV_limit_hit(n)
|
||||||
|
|
||||||
n.meta = dict(snakemake.config, **dict(wildcards=dict(snakemake.wildcards)))
|
n.meta = dict(snakemake.config, **dict(wildcards=dict(snakemake.wildcards)))
|
||||||
n.export_to_netcdf(snakemake.output[0])
|
n.export_to_netcdf(snakemake.output[0])
|
||||||
|
Loading…
Reference in New Issue
Block a user