Bug fix: Carrier type of added supernodes in simplify_network need to be set to "AC" (#1221)
* Fixed simplify_network.py to handle more complex topologies, i.e. if two links are connected to nearby AC buses separated by an AC line. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Added fix for Corsica node: If region containing Corsica is modelled, include substation on Corsica as supernode (end point). * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Bug fix: Carrier type of all supernodes corrected to 'AC' * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Bug fix: Carrier type of all supernodes corrected to 'AC' * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Bug fix: Carrier type of all supernodes corrected to 'AC' --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
0221372b49
commit
55cca6a0f9
@ -301,19 +301,11 @@ def simplify_links(
|
||||
# Only span graph over the DC link components
|
||||
G = n.graph(branch_components=["Link"])
|
||||
|
||||
def split_links(nodes):
|
||||
def split_links(nodes, added_supernodes=None):
|
||||
nodes = frozenset(nodes)
|
||||
|
||||
seen = set()
|
||||
|
||||
# Corsica substation
|
||||
node_corsica = find_closest_bus(
|
||||
n,
|
||||
x=9.44802,
|
||||
y=42.52842,
|
||||
tol=2000, # Tolerance needed to only return the bus if the region is actually modelled
|
||||
)
|
||||
|
||||
# Supernodes are endpoints of links, identified by having lass then two neighbours or being an AC Bus
|
||||
# An example for the latter is if two different links are connected to the same AC bus.
|
||||
supernodes = {
|
||||
@ -322,7 +314,7 @@ def simplify_links(
|
||||
if (
|
||||
(len(G.adj[m]) < 2 or (set(G.adj[m]) - nodes))
|
||||
or (n.buses.loc[m, "carrier"] == "AC")
|
||||
or (m == node_corsica)
|
||||
or (m in added_supernodes)
|
||||
)
|
||||
}
|
||||
|
||||
@ -359,6 +351,17 @@ def simplify_links(
|
||||
0.0, index=n.buses.index, columns=list(connection_costs_per_link)
|
||||
)
|
||||
|
||||
node_corsica = find_closest_bus(
|
||||
n,
|
||||
x=9.44802,
|
||||
y=42.52842,
|
||||
tol=2000, # Tolerance needed to only return the bus if the region is actually modelled
|
||||
)
|
||||
|
||||
added_supernodes = []
|
||||
if node_corsica is not None:
|
||||
added_supernodes.append(node_corsica)
|
||||
|
||||
for lbl in labels.value_counts().loc[lambda s: s > 2].index:
|
||||
for b, buses, links in split_links(labels.index[labels == lbl]):
|
||||
if len(buses) <= 2:
|
||||
@ -421,6 +424,9 @@ def simplify_links(
|
||||
|
||||
logger.debug("Collecting all components using the busmap")
|
||||
|
||||
# Change carrier type of all added super_nodes to "AC"
|
||||
n.buses.loc[added_supernodes, "carrier"] = "AC"
|
||||
|
||||
_aggregate_and_move_components(
|
||||
n,
|
||||
busmap,
|
||||
|
Loading…
Reference in New Issue
Block a user