Skip to content

Commit

Permalink
Add log during merging.
Browse files Browse the repository at this point in the history
Signed-off-by: Anne Tilloy <anne.tilloy@rte-france.com>
  • Loading branch information
annetill committed Oct 5, 2023
1 parent fe24266 commit bba7463
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@ public static void findAndAssociateDanglingLines(DanglingLine candidateDanglingL
List<DanglingLine> connectedDls = dls.stream().filter(dl -> dl.getTerminal().isConnected()).collect(Collectors.toList());
if (connectedDls.size() == 1) { // if there is exactly one connected dangling line in the merging network, merge it. Otherwise, do nothing
associateDanglingLines.accept(connectedDls.get(0), candidateDanglingLine);
} else {
LOGGER.warn("Several connected dangling lines {} of the same subnetwork are candidate for merging for pairing key '{}'. " +
"No tie line automatically created, tie lines must be created by hand.",
connectedDls.stream().map(DanglingLine::getId).collect(Collectors.toList()), connectedDls.get(0).getPairingKey());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -619,23 +619,61 @@ public void mergeThenCloneVariantBug() {

@Test
public void multipleDanglingLinesInMergedNetwork() {
// The code is not the same if the dangling line with the duplicate pairing key is in the current network
// or in the network we are adding when we try to associate dangling lines.
//
// This test covers the case where the duplicate pairing key is in the CURRENT network.
addCommonSubstationsAndVoltageLevels();
addCommonDanglingLines("dl1", "code", "dl2", "code");
addDanglingLine(n2, "vl2", "dl3", "code", "b2", null);
Network merge = Network.merge(n1, n2);
// Since n2 has ONLY ONE connected dangling line with the pairing key, the tie line is created
assertNotNull(merge.getTieLine("dl1 + dl2"));
assertEquals("dl1_name + dl2_name", merge.getTieLine("dl1 + dl2").getOptionalName().orElse(null));
assertEquals("dl1_name + dl2_name", merge.getTieLine("dl1 + dl2").getNameOrId());
}

@Test
public void multipleConnectedDanglingLinesInMergedNetwork() {
// The code is not the same if the dangling line with the duplicate pairing key is in the current network
// or in the network we are adding when we try to associate dangling lines.
//
// This test covers the case where the duplicate pairing key is in the CURRENT network.
addCommonSubstationsAndVoltageLevels();
addCommonDanglingLines("dl1", "code", "dl2", "code");
addDanglingLine(n2, "vl2", "dl3", "code", "b2", "b2");
Network merge = Network.merge(n1, n2);
// Since n2 has SEVERAL connected dangling lines with the pairing key, we don't create the tie line
assertEquals(0, merge.getTieLineCount());
}

@Test
public void multipleDanglingLinesInMergingNetwork() {
// The code is not the same if the dangling line with the duplicate pairing key is in the current network
// or in the network we are adding when we try to associate dangling lines.
//
// This test covers the case where the duplicate pairing key is in the ADDED network.
addCommonSubstationsAndVoltageLevels();
addCommonDanglingLines("dl1", "code", "dl2", "code");
addDanglingLine(n1, "vl1", "dl3", "code", "b1", null);
Network merge = Network.merge(n1, n2);
// Since n1 has ONLY ONE connected dangling line with the pairing key, the tie line is created
assertNotNull(merge.getTieLine("dl1 + dl2"));
assertEquals("dl1_name + dl2_name", merge.getTieLine("dl1 + dl2").getOptionalName().orElse(null));
assertEquals("dl1_name + dl2_name", merge.getTieLine("dl1 + dl2").getNameOrId());
}

@Test
public void multipleConnectedDanglingLinesWithSamePairingKey() {
// The code is not the same if the dangling line with the duplicate pairing key is in the current network
// or in the network we are adding when we try to associate dangling lines.
//
// This test covers the case where the duplicate pairing key is in the ADDED network.
addCommonSubstationsAndVoltageLevels();
addCommonDanglingLines("dl1", "code", "dl2", "code");
addDanglingLine(n1, "vl1", "dl3", "code", "b1", "b1");
Network merge = Network.merge(n1, n2);
// Since n1 has SEVERAL connected dangling lines with the pairing key, we don't create the tie line
assertEquals(0, merge.getTieLineCount());
}
}

0 comments on commit bba7463

Please sign in to comment.