diff --git a/network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/TerminalImpl.java b/network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/TerminalImpl.java index 2011d05f9..31cd418dc 100644 --- a/network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/TerminalImpl.java +++ b/network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/TerminalImpl.java @@ -362,6 +362,82 @@ private boolean isAnOpenSwitch(Edge edge) { return testSwitchFromEdge(edge, SwitchPredicates.IS_OPEN); } + private Set getConnectableNodes(Resource voltageLevelResource) { + Set busbarSectionNodes = index.getStoreClient().getVoltageLevelBusbarSections(index.getNetwork().getUuid(), index.getWorkingVariantNum(), voltageLevelResource.getId()) + .stream().map(resource -> resource.getAttributes().getNode()) + .collect(Collectors.toSet()); + + Set lineNodes = index.getStoreClient().getVoltageLevelLines(index.getNetwork().getUuid(), index.getWorkingVariantNum(), voltageLevelResource.getId()) + .stream().map(resource -> resource.getAttributes().getVoltageLevelId1().equals(getVoltageLevelId()) + ? resource.getAttributes().getNode1() + : resource.getAttributes().getNode2() + ) + .collect(Collectors.toSet()); + + Set twoWindingsTransformerNodes = index.getStoreClient().getVoltageLevelTwoWindingsTransformers(index.getNetwork().getUuid(), index.getWorkingVariantNum(), voltageLevelResource.getId()) + .stream().map(resource -> resource.getAttributes().getVoltageLevelId1().equals(getVoltageLevelId()) + ? resource.getAttributes().getNode1() + : resource.getAttributes().getNode2() + ) + .collect(Collectors.toSet()); + + Set threeWindingsTransformerNodes = index.getStoreClient().getVoltageLevelThreeWindingsTransformers(index.getNetwork().getUuid(), index.getWorkingVariantNum(), voltageLevelResource.getId()) + .stream().map(resource -> { + if (resource.getAttributes().getLeg1().getVoltageLevelId().equals(getVoltageLevelId())) { + return resource.getAttributes().getLeg1().getNode(); + } else if (resource.getAttributes().getLeg2().getVoltageLevelId().equals(getVoltageLevelId())) { + return resource.getAttributes().getLeg2().getNode(); + } else { + return resource.getAttributes().getLeg3().getNode(); + } + }) + .collect(Collectors.toSet()); + + Set generatorNodes = index.getStoreClient().getVoltageLevelGenerators(index.getNetwork().getUuid(), index.getWorkingVariantNum(), voltageLevelResource.getId()) + .stream().map(resource -> resource.getAttributes().getNode()) + .collect(Collectors.toSet()); + Set batteryNodes = index.getStoreClient().getVoltageLevelBatteries(index.getNetwork().getUuid(), index.getWorkingVariantNum(), voltageLevelResource.getId()) + .stream().map(resource -> resource.getAttributes().getNode()) + .collect(Collectors.toSet()); + Set loadNodes = index.getStoreClient().getVoltageLevelLoads(index.getNetwork().getUuid(), index.getWorkingVariantNum(), voltageLevelResource.getId()) + .stream().map(resource -> resource.getAttributes().getNode()) + .collect(Collectors.toSet()); + Set shuntCompensatorNodes = index.getStoreClient().getVoltageLevelShuntCompensators(index.getNetwork().getUuid(), index.getWorkingVariantNum(), voltageLevelResource.getId()) + .stream().map(resource -> resource.getAttributes().getNode()) + .collect(Collectors.toSet()); + Set staticVarCompensatorNodes = index.getStoreClient().getVoltageLevelStaticVarCompensators(index.getNetwork().getUuid(), index.getWorkingVariantNum(), voltageLevelResource.getId()) + .stream().map(resource -> resource.getAttributes().getNode()) + .collect(Collectors.toSet()); + Set danglingLineNodes = index.getStoreClient().getVoltageLevelDanglingLines(index.getNetwork().getUuid(), index.getWorkingVariantNum(), voltageLevelResource.getId()) + .stream().map(resource -> resource.getAttributes().getNode()) + .collect(Collectors.toSet()); + Set lccConverterStationNodes = index.getStoreClient().getVoltageLevelLccConverterStations(index.getNetwork().getUuid(), index.getWorkingVariantNum(), voltageLevelResource.getId()) + .stream().map(resource -> resource.getAttributes().getNode()) + .collect(Collectors.toSet()); + Set vscConverterStationNodes = index.getStoreClient().getVoltageLevelVscConverterStations(index.getNetwork().getUuid(), index.getWorkingVariantNum(), voltageLevelResource.getId()) + .stream().map(resource -> resource.getAttributes().getNode()) + .collect(Collectors.toSet()); + Set groundNodes = index.getStoreClient().getVoltageLevelGrounds(index.getNetwork().getUuid(), index.getWorkingVariantNum(), voltageLevelResource.getId()) + .stream().map(resource -> resource.getAttributes().getNode()) + .collect(Collectors.toSet()); + + Set connectableNodes = new HashSet<>(busbarSectionNodes); + connectableNodes.addAll(lineNodes); + connectableNodes.addAll(twoWindingsTransformerNodes); + connectableNodes.addAll(threeWindingsTransformerNodes); + connectableNodes.addAll(generatorNodes); + connectableNodes.addAll(batteryNodes); + connectableNodes.addAll(loadNodes); + connectableNodes.addAll(shuntCompensatorNodes); + connectableNodes.addAll(staticVarCompensatorNodes); + connectableNodes.addAll(danglingLineNodes); + connectableNodes.addAll(lccConverterStationNodes); + connectableNodes.addAll(vscConverterStationNodes); + connectableNodes.addAll(groundNodes); + + return connectableNodes; + } + /** *

This method is an adaptation of the same method from NodeBreakerVoltageLevel in powsybl-core, in order to keep * the same logic and the same results on both sides.

@@ -377,12 +453,12 @@ boolean getDisconnectingSwitches(Predicate isSwitchOpenable, Set busbarSectionNodes = getBusbarSectionNodes(voltageLevelResource); + // Nodes of the connectables (end of the paths) + Set connectableNodes = getConnectableNodes(voltageLevelResource); - // find all paths starting from the current terminal to a busbar section that does not contain an open switch + // find all paths starting from the current terminal to a connectable that does not contain an open switch List> paths = graph.findAllPaths(node, - busbarSectionNodes::contains, + connectableNodes::contains, this::isAnOpenSwitch, Comparator.comparing(List::size)); if (paths.isEmpty()) { diff --git a/network-store-iidm-impl/src/test/java/com/powsybl/network/store/iidm/impl/tck/ForkConnectDisconnectTest.java b/network-store-iidm-impl/src/test/java/com/powsybl/network/store/iidm/impl/tck/ForkConnectDisconnectTest.java index 1d4c0902a..8a2a4fa6d 100644 --- a/network-store-iidm-impl/src/test/java/com/powsybl/network/store/iidm/impl/tck/ForkConnectDisconnectTest.java +++ b/network-store-iidm-impl/src/test/java/com/powsybl/network/store/iidm/impl/tck/ForkConnectDisconnectTest.java @@ -7,14 +7,9 @@ package com.powsybl.network.store.iidm.impl.tck; import com.powsybl.iidm.network.tck.AbstractForkConnectDisconnectTest; -import org.junit.jupiter.api.Test; /** * @author Franck Lecuyer */ public class ForkConnectDisconnectTest extends AbstractForkConnectDisconnectTest { - @Test - public void forkDisconnectedTest() { - // FIXME : no line disconnection in case of 2 lines connected together in a fork - } }