Skip to content

Commit

Permalink
Only use branches connected at both sides in most meshed slack bus se…
Browse files Browse the repository at this point in the history
…lection (#762)

Signed-off-by: Geoffroy Jamgotchian <geoffroy.jamgotchian@rte-france.com>
  • Loading branch information
geofjamg committed Mar 27, 2023
1 parent bfb2521 commit 15062c5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ public MostMeshedSlackBusSelector(double maxNominalVoltagePercentile) {
this.maxNominalVoltagePercentile = maxNominalVoltagePercentile;
}

private static int getBranchCountConnectedAtBothSides(LfBus bus) {
return (int) bus.getBranches().stream().filter(LfBranch::isConnectedAtBothSides).count();
}

@Override
public SelectedSlackBus select(List<LfBus> buses, int limit) {
double[] nominalVoltages = buses.stream()
Expand All @@ -41,7 +45,7 @@ public SelectedSlackBus select(List<LfBus> buses, int limit) {
// select non-fictitious and most meshed bus among buses with the highest nominal voltage
List<LfBus> slackBuses = buses.stream()
.filter(bus -> !bus.isFictitious() && bus.getNominalV() == maxNominalV)
.sorted(Comparator.comparingInt((LfBus bus) -> bus.getBranches().size())
.sorted(Comparator.comparingInt(MostMeshedSlackBusSelector::getBranchCountConnectedAtBothSides)
.thenComparing(Comparator.comparing(LfBus::getId).reversed()).reversed())
.limit(limit)
.collect(Collectors.toList());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ void testOpenBranch() {
network.getLine("L2").setR(0.0).setX(0.0);
network.getLine("L1").getTerminal1().disconnect();
LoadFlow.run(network);
assertEquals(600.0, network.getLine("L2").getTerminal1().getP(), LoadFlowAssert.DELTA_POWER);
assertEquals(-600.0, network.getLine("L2").getTerminal2().getP(), LoadFlowAssert.DELTA_POWER);
assertEquals(600.018, network.getLine("L2").getTerminal1().getP(), LoadFlowAssert.DELTA_POWER);
assertEquals(-600.018, network.getLine("L2").getTerminal2().getP(), LoadFlowAssert.DELTA_POWER);
assertEquals(Double.NaN, network.getLine("L1").getTerminal1().getP(), LoadFlowAssert.DELTA_POWER);

network.getLine("L1").getTerminal1().connect();
Expand Down

0 comments on commit 15062c5

Please sign in to comment.