Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix contingency on line disconnected at one side #756

Merged
merged 5 commits into from
Mar 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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());
}
}