diff --git a/iidm/iidm-modification/src/main/java/com/powsybl/iidm/modification/topology/RemoveHvdcLine.java b/iidm/iidm-modification/src/main/java/com/powsybl/iidm/modification/topology/RemoveHvdcLine.java index f27eb9521d1..14a9dd51686 100644 --- a/iidm/iidm-modification/src/main/java/com/powsybl/iidm/modification/topology/RemoveHvdcLine.java +++ b/iidm/iidm-modification/src/main/java/com/powsybl/iidm/modification/topology/RemoveHvdcLine.java @@ -57,8 +57,8 @@ public void apply(Network network, boolean throwException, ComputationManager co hvdcLine.remove(); removedHvdcLineReport(reporter, hvdcLineId); // Remove the Shunt compensators that represent the filters of the LCC - removeShuntCompensators(hvdcConverterStation1, hvdcConverterStation2, shunts, reporter); - removeConverterStations(hvdcConverterStation1, hvdcConverterStation2, reporter); + removeShuntCompensators(network, hvdcConverterStation1, hvdcConverterStation2, shunts, throwException, computationManager, reporter); + removeConverterStations(network, hvdcConverterStation1, hvdcConverterStation2, throwException, computationManager, reporter); } else { LOGGER.error("Hvdc Line {} not found", hvdcLineId); notFoundHvdcLineReport(reporter, hvdcLineId); @@ -80,7 +80,7 @@ private static ShuntCompensator getShuntCompensator(String id, Network network, return sc; } - private static void removeShuntCompensators(HvdcConverterStation hvdcConverterStation1, HvdcConverterStation hvdcConverterStation2, Set shunts, Reporter reporter) { + private static void removeShuntCompensators(Network network, HvdcConverterStation hvdcConverterStation1, HvdcConverterStation hvdcConverterStation2, Set shunts, boolean throwException, ComputationManager computationManager, Reporter reporter) { if (shunts == null) { return; } @@ -94,7 +94,7 @@ private static void removeShuntCompensators(HvdcConverterStation hvdcConverte VoltageLevel shuntVl = shuntCompensator.getTerminal().getVoltageLevel(); // check whether the shunt compensator is connected to the same voltage level as the lcc if (vl1 == shuntVl || vl2 == shuntVl) { - shuntCompensator.remove(); + new RemoveFeederBay(shuntCompensator.getId()).apply(network, throwException, computationManager, reporter); removedShuntCompensatorReport(reporter, shuntCompensator.getId()); } else { LOGGER.warn("Shunt compensator {} has been ignored because it is not in the same voltage levels as the Lcc ({} or {})", shuntCompensator.getId(), vl1.getId(), vl2.getId()); @@ -103,9 +103,9 @@ private static void removeShuntCompensators(HvdcConverterStation hvdcConverte } } - private static void removeConverterStations(HvdcConverterStation hvdcConverterStation1, HvdcConverterStation hvdcConverterStation2, Reporter reporter) { - hvdcConverterStation1.remove(); - hvdcConverterStation2.remove(); + private static void removeConverterStations(Network network, HvdcConverterStation hvdcConverterStation1, HvdcConverterStation hvdcConverterStation2, boolean throwException, ComputationManager computationManager, Reporter reporter) { + new RemoveFeederBay(hvdcConverterStation1.getId()).apply(network, throwException, computationManager, reporter); + new RemoveFeederBay(hvdcConverterStation2.getId()).apply(network, throwException, computationManager, reporter); reportConverterStationRemoved(reporter, hvdcConverterStation1); reportConverterStationRemoved(reporter, hvdcConverterStation2); } diff --git a/iidm/iidm-modification/src/main/java/com/powsybl/iidm/modification/topology/RemoveVoltageLevel.java b/iidm/iidm-modification/src/main/java/com/powsybl/iidm/modification/topology/RemoveVoltageLevel.java index 84b2dab8132..99f6ed458f7 100644 --- a/iidm/iidm-modification/src/main/java/com/powsybl/iidm/modification/topology/RemoveVoltageLevel.java +++ b/iidm/iidm-modification/src/main/java/com/powsybl/iidm/modification/topology/RemoveVoltageLevel.java @@ -46,12 +46,17 @@ public void apply(Network network, boolean throwException, ComputationManager co voltageLevel.getConnectables(HvdcConverterStation.class).forEach(hcs -> { if (hcs.getHvdcLine() != null) { - hcs.getHvdcLine().remove(); + new RemoveHvdcLineBuilder().withHvdcLineId(hcs.getHvdcLine().getId()).build().apply(network, throwException, computationManager, reporter); } - hcs.remove(); }); - voltageLevel.getConnectables().forEach(Connectable::remove); + voltageLevel.getConnectables().forEach(connectable -> { + if (connectable instanceof Injection) { + connectable.remove(); + } else { + new RemoveFeederBayBuilder().withConnectableId(connectable.getId()).build().apply(network, throwException, computationManager, reporter); + } + }); voltageLevel.remove(); removedVoltageLevelReport(reporter, voltageLevelId); diff --git a/iidm/iidm-modification/src/test/java/com/powsybl/iidm/modification/topology/RemoveVoltageLevelTest.java b/iidm/iidm-modification/src/test/java/com/powsybl/iidm/modification/topology/RemoveVoltageLevelTest.java index 26a7876365b..4c79287b4ff 100644 --- a/iidm/iidm-modification/src/test/java/com/powsybl/iidm/modification/topology/RemoveVoltageLevelTest.java +++ b/iidm/iidm-modification/src/test/java/com/powsybl/iidm/modification/topology/RemoveVoltageLevelTest.java @@ -59,8 +59,8 @@ void testRemoveVoltageLevel() { addListener(network); new RemoveVoltageLevelBuilder().withVoltageLevelId("S1VL1").build().apply(network); - assertEquals(Set.of("TWT", "S1VL1_BBS", "S1VL1_BBS_TWT_DISCONNECTOR", "S1VL1", "S1VL1_LD1_BREAKER", "LD1", "S1VL1_TWT_BREAKER", "S1VL1_BBS_LD1_DISCONNECTOR"), beforeRemovalObjects); - assertEquals(Set.of("TWT", "S1VL1_BBS", "S1VL1_BBS_TWT_DISCONNECTOR", "S1VL1", "S1VL1_LD1_BREAKER", "LD1", "S1VL1_TWT_BREAKER", "S1VL1_BBS_LD1_DISCONNECTOR"), removedObjects); + assertEquals(Set.of("TWT", "S1VL1_BBS", "S1VL1_BBS_TWT_DISCONNECTOR", "S1VL1", "S1VL1_LD1_BREAKER", "LD1", "S1VL1_TWT_BREAKER", "S1VL1_BBS_LD1_DISCONNECTOR", "S1VL2_BBS1_TWT_DISCONNECTOR", "S1VL2_BBS2_TWT_DISCONNECTOR", "S1VL2_TWT_BREAKER"), beforeRemovalObjects); + assertEquals(Set.of("TWT", "S1VL1_BBS", "S1VL1_BBS_TWT_DISCONNECTOR", "S1VL1", "S1VL1_LD1_BREAKER", "LD1", "S1VL1_TWT_BREAKER", "S1VL1_BBS_LD1_DISCONNECTOR", "S1VL2_BBS1_TWT_DISCONNECTOR", "S1VL2_BBS2_TWT_DISCONNECTOR", "S1VL2_TWT_BREAKER"), removedObjects); assertNull(network.getVoltageLevel("S1VL1")); assertNull(network.getTwoWindingsTransformer("TWT")); diff --git a/iidm/iidm-modification/src/test/resources/eurostag-remove-voltage-level-nb.xml b/iidm/iidm-modification/src/test/resources/eurostag-remove-voltage-level-nb.xml index c3c6fa4b1f3..059ca1a52c1 100644 --- a/iidm/iidm-modification/src/test/resources/eurostag-remove-voltage-level-nb.xml +++ b/iidm/iidm-modification/src/test/resources/eurostag-remove-voltage-level-nb.xml @@ -1,6 +1,7 @@ + - + @@ -13,7 +14,6 @@ - - \ No newline at end of file +