Skip to content

Commit

Permalink
Fix contingency on line disconnected at one side (#756)
Browse files Browse the repository at this point in the history
Signed-off-by: Bertrand Rix <bertrand.rix@artelys.com>
Signed-off-by: Anne Tilloy <anne.tilloy@rte-france.com>
  • Loading branch information
obrix authored Mar 16, 2023
1 parent ca8e0c2 commit df9569c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -277,10 +277,14 @@ public Optional<LfContingency> toLfContingency(LfNetwork network) {
// update connectivity with triggered branches of this network
GraphConnectivity<LfBus, LfBranch> connectivity = network.getConnectivity();
connectivity.startTemporaryChanges();
branchIdsToOpen.stream()

List<LfBranch> branchesToOpen = branchIdsToOpen.stream()
.map(network::getBranchById)
.filter(Objects::nonNull) // could be in another component
.filter(b -> b.getBus1() != null && b.getBus2() != null)
.collect(Collectors.toList());

branchesToOpen.stream()
.filter(LfBranch::isConnectedAtBothSides)
.forEach(connectivity::removeEdge);

// add to contingency description buses and branches that won't be part of the main connected
Expand All @@ -289,7 +293,10 @@ public Optional<LfContingency> toLfContingency(LfNetwork network) {
Set<LfBus> buses = connectivity.getVerticesRemovedFromMainComponent();
Set<LfBranch> branches = new HashSet<>(connectivity.getEdgesRemovedFromMainComponent());

// we should manage branches open at one side.
// we should manage branches open at one side
branchesToOpen.stream()
.filter(b -> !b.isConnectedAtBothSides())
.forEach(branches::add);
for (LfBus bus : buses) {
bus.getBranches().stream().filter(b -> !b.isConnectedAtBothSides()).forEach(branches::add);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2576,4 +2576,18 @@ void testActionOnGeneratorInContingency() {
assertEquals(-35.294, operatorStrategyResult2.getNetworkResult().getBranchResult("l14").getP1(), LoadFlowAssert.DELTA_POWER);
assertEquals(-58.824, operatorStrategyResult2.getNetworkResult().getBranchResult("l34").getP1(), LoadFlowAssert.DELTA_POWER);
}

@Test
void testLineDisconnectedOnOneSideContingency() {
Network network = DistributedSlackNetworkFactory.create();
network.getBranch("l24").getTerminal1().disconnect();
List<StateMonitor> monitors = createAllBranchesMonitors(network);
SecurityAnalysisResult result = runSecurityAnalysis(network, List.of(new Contingency("l24", new BranchContingency("l24"))), monitors);
PostContingencyResult postContingencyResult = getPostContingencyResult(result, "l24");
assertEquals(200.000, postContingencyResult.getNetworkResult().getBranchResult("l14").getP1(), LoadFlowAssert.DELTA_POWER);
assertEquals(140.141, postContingencyResult.getNetworkResult().getBranchResult("l14").getQ1(), LoadFlowAssert.DELTA_POWER);
assertEquals(300.000, postContingencyResult.getNetworkResult().getBranchResult("l34").getP1(), LoadFlowAssert.DELTA_POWER);
assertEquals(260.005, postContingencyResult.getNetworkResult().getBranchResult("l34").getQ1(), LoadFlowAssert.DELTA_POWER);
assertEquals(1, result.getPostContingencyResults().size());
}
}

0 comments on commit df9569c

Please sign in to comment.