Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric-Nitschke committed Nov 18, 2024
2 parents a1f91e4 + 9acbfe4 commit 31c7973
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 18 deletions.
13 changes: 4 additions & 9 deletions scripts/add_extra_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,24 +266,19 @@ def attach_hydrogen_pipelines(n, costs, config):
)

# setup pipelines as bidirectional and lossy
lossy_bidirectional_links(n,"H2 pipeline")
lossy_bidirectional_links(n, "H2 pipeline")


def lossy_bidirectional_links(
n: pypsa.components.Network,
carrier: str
):
def lossy_bidirectional_links(n: pypsa.components.Network, carrier: str):

"Split bidirectional links into two unidirectional links to include transmission losses."

carrier_i = n.links.query("carrier == @carrier").index

if carrier_i.empty:
return

logger.info(
f"Splitting bidirectional links with the carrier {carrier}"
)

logger.info(f"Splitting bidirectional links with the carrier {carrier}")

n.links.loc[carrier_i, "p_min_pu"] = 0

Expand Down
15 changes: 6 additions & 9 deletions scripts/solve_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -854,13 +854,10 @@ def add_existing(n):
n.generators.loc[tech_index, tech] = existing_res


def add_lossy_bidirectional_link_constraints(
n: pypsa.components.Network
) -> None:

'''
def add_lossy_bidirectional_link_constraints(n: pypsa.components.Network) -> None:
"""
Ensures that the two links simulating a bidirectional_link are extended the same amount.
'''
"""

if not n.links.p_nom_extendable.any() or "reversed" not in n.links.columns:
return
Expand All @@ -887,10 +884,10 @@ def get_backward_i(forward_i):
backward_i = get_backward_i(forward_i)

lhs = linexpr(
(1, get_var(n,"Link", "p_nom")[backward_i].to_numpy()),
(-1, get_var(n,"Link", "p_nom")[forward_i].to_numpy())
(1, get_var(n, "Link", "p_nom")[backward_i].to_numpy()),
(-1, get_var(n, "Link", "p_nom")[forward_i].to_numpy()),
)

define_constraints(n, lhs, "=", 0, "Link-bidirectional_sync")


Expand Down

0 comments on commit 31c7973

Please sign in to comment.