fix capacity synchronisation between forward and backward lossy links
This commit is contained in:
parent
cc162a9e02
commit
e4eff27e50
@ -3294,7 +3294,6 @@ def lossy_bidirectional_links(n, carrier, losses_per_thousand_km=0.0):
|
||||
|
||||
carrier_i = n.links.query("carrier == @carrier").index
|
||||
n.links.loc[carrier_i, "p_min_pu"] = 0
|
||||
n.links["reversed"] = False
|
||||
n.links.loc[carrier_i, "efficiency"] = (
|
||||
1 - n.links.loc[carrier_i, "length"] * losses_per_thousand_km / 1e3
|
||||
)
|
||||
@ -3302,10 +3301,11 @@ def lossy_bidirectional_links(n, carrier, losses_per_thousand_km=0.0):
|
||||
n.links.loc[carrier_i].copy().rename({"bus0": "bus1", "bus1": "bus0"}, axis=1)
|
||||
)
|
||||
rev_links.capital_cost = 0
|
||||
rev_links.reversed = True
|
||||
rev_links["reversed"] = True
|
||||
rev_links.index = rev_links.index.map(lambda x: x + "-reversed")
|
||||
|
||||
n.links = pd.concat([n.links, rev_links], sort=False)
|
||||
n.links["reversed"] = n.links["reversed"].fillna(False)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
@ -500,14 +500,10 @@ def add_lossy_bidirectional_link_constraints(n):
|
||||
|
||||
carriers = n.links.loc[n.links.reversed, "carrier"].unique()
|
||||
|
||||
backward_i = n.links.query(
|
||||
"carrier in @carriers and reversed and p_nom_extendable"
|
||||
).index
|
||||
forward_i = n.links.query(
|
||||
"carrier in @carriers and ~reversed and p_nom_extendable"
|
||||
).index
|
||||
|
||||
assert len(forward_i) == len(backward_i)
|
||||
backward_i = forward_i + "-reversed"
|
||||
|
||||
lhs = n.model["Link-p_nom"].loc[backward_i]
|
||||
rhs = n.model["Link-p_nom"].loc[forward_i]
|
||||
|
Loading…
Reference in New Issue
Block a user