Skip to content
Open
Show file tree
Hide file tree
Changes from 5 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 @@ -136,6 +136,8 @@ core.iidm.modification.voltageLevelCreated = VoltageLevel ${voltageLevelId} crea
core.iidm.modification.voltageLevelNotFound = Voltage level ${voltageLevelId} is not found
core.iidm.modification.voltageLevelRemoved = Voltage level ${vlId} removed
core.iidm.modification.voltageLevelRemovingEquipmentsLeft = Voltage level ${vlId} still contains equipments
core.iidm.modification.voltageLevelRemovingEquipmentsLeftWithQuadripoles = Voltage level ${vlId} still contains equipments including quadripoles, it is not removed
core.iidm.modification.voltageLevelRemovingEquipmentsLeftWithoutQuadripoles = Voltage level ${vlId} still contains equipments but no quadripoles, it is not removed
Comment on lines +139 to +140
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quadripoles -> branches

Can you fix the keys and the messages?

core.iidm.modification.wrongSwitchKind = Switch kinds must be DISCONNECTOR or BREAKER
core.iidm.modification.noBusbarSection = No busbar section provided.
core.iidm.modification.wrongNetwork = All busbar sections must be in the network passed to the method.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@ core.iidm.modification.voltageConnectedOnLine = Le poste ${voltageLevelId} conne
core.iidm.modification.voltageLevelCreated = Poste ${voltageLevelId} créé.
core.iidm.modification.voltageLevelNotFound = Poste ${voltageLevelId} introuvable.
core.iidm.modification.voltageLevelRemoved = Le poste ${vlId} a été supprimé.
core.iidm.modification.voltageLevelRemovingEquipmentsLeft = Le poste ${vlId} contient toujours des équipements.
core.iidm.modification.voltageLevelRemovingEquipmentsLeft = Le poste ${vlId} contient toujours des équipements.
core.iidm.modification.voltageLevelRemovingEquipmentsLeftWithQuadripoles = Le poste ${vlId} contient toujours des équipements dont des quadripoles, il n'est pas supprimé.
core.iidm.modification.voltageLevelRemovingEquipmentsLeftWithoutQuadripoles = Le poste ${vlId} contient toujours des équipements mais aucun quadripoles, il n'est pas supprimé.
Comment on lines +139 to +140
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a typo in quadripôles: it takes a ^.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beware, this file should be edited in UTF-8.

core.iidm.modification.wrongSwitchKind = Les organes de coupures doivent être de type DISCONNECTOR ou BREAKER.
core.iidm.modification.noBusbarSection = Aucune section de jeu de barres donnée
core.iidm.modification.wrongNetwork = Toutes les sections de jeu de barres doivent être dans le réseau passé en entrée.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,17 +199,26 @@ private static <L extends LoadingLimits, A extends LoadingLimitsAdder<L, A>> voi
}

static void removeVoltageLevelAndSubstation(VoltageLevel voltageLevel, ReportNode reportNode) {
Optional<Substation> substation = voltageLevel.getSubstation();
String vlId = voltageLevel.getId();
boolean noMoreBranches = voltageLevel.getConnectableStream().noneMatch(c -> c.getType() != IdentifiableType.LINE
|| c.getType() != IdentifiableType.TWO_WINDINGS_TRANSFORMER || c.getType() != IdentifiableType.THREE_WINDINGS_TRANSFORMER ||
c.getType() != IdentifiableType.HVDC_CONVERTER_STATION);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check can be done in the if (!noMoreEquipments) {.

boolean noMoreEquipments = voltageLevel.getConnectableStream().noneMatch(c -> c.getType() != IdentifiableType.BUSBAR_SECTION);
if (!noMoreEquipments) {
voltageLevelRemovingEquipmentsLeftReport(reportNode, vlId);
LOGGER.warn("Voltage level {} still contains equipments", vlId);
if (noMoreBranches) {
voltageLevelRemovingEquipmentsLeftWithoutQuadripoleReport(reportNode, vlId);
LOGGER.warn("Voltage level {} still contains equipments but no quadripoles, it is not removed", vlId);
} else {
voltageLevelRemovingEquipmentsLeftWithQuadripoleReport(reportNode, vlId);
LOGGER.warn("Voltage level {} still contains equipments including quadripoles, it is not removed", vlId);
}
return;
}
// substation must be gotten before removing the voltageLevel
Optional<Substation> substation = voltageLevel.getSubstation();
voltageLevel.remove();
voltageLevelRemovedReport(reportNode, vlId);
LOGGER.info("Voltage level {} removed", vlId);

substation.ifPresent(s -> {
if (s.getVoltageLevelStream().count() == 0) {
String substationId = s.getId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,22 @@ public static void voltageLevelRemovingEquipmentsLeftReport(ReportNode reportNod
.add();
}

public static void voltageLevelRemovingEquipmentsLeftWithoutQuadripoleReport(ReportNode reportNode, String vlId) {
reportNode.newReportNode()
.withMessageTemplate("core.iidm.modification.voltageLevelRemovingEquipmentsLeftWithoutQuadripoles")
.withUntypedValue("vlId", vlId)
.withSeverity(TypedValue.WARN_SEVERITY)
.add();
}

public static void voltageLevelRemovingEquipmentsLeftWithQuadripoleReport(ReportNode reportNode, String vlId) {
reportNode.newReportNode()
.withMessageTemplate("core.iidm.modification.voltageLevelRemovingEquipmentsLeftWithQuadripoles")
.withUntypedValue("vlId", vlId)
.withSeverity(TypedValue.WARN_SEVERITY)
.add();
}

// ERROR
public static void notFoundBusOrBusbarSectionReport(ReportNode reportNode, String identifiableId) {
reportNode.newReportNode()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

import com.powsybl.commons.PowsyblException;
import com.powsybl.commons.report.PowsyblCoreReportResourceBundle;
import com.powsybl.commons.test.PowsyblTestReportResourceBundle;
import com.powsybl.commons.report.ReportNode;
import com.powsybl.commons.test.PowsyblTestReportResourceBundle;
import com.powsybl.iidm.modification.AbstractNetworkModification;
import com.powsybl.iidm.modification.NetworkModification;
import com.powsybl.iidm.modification.NetworkModificationImpact;
Expand Down Expand Up @@ -338,4 +338,35 @@ void testHasImpact() {
.build();
assertEquals(NetworkModificationImpact.CANNOT_BE_APPLIED, modification.hasImpactOnNetwork(network));
}

@Test
void testDoesNotDeleteVoltageLevel() throws IOException {
Network network = createNbNetworkWithBusbarSection();
Line line = network.getLine("CJ");
LineAdder adder = createLineAdder(line, network);
NetworkModification modification = new CreateLineOnLineBuilder().withBusbarSectionOrBusId(BBS).withLine(line).withLineAdder(adder).build();
modification.apply(network);
VoltageLevel vl = network.getVoltageLevel("CJ_VL");
assertNotNull(vl);

// add one element
vl.newLoad().setId("loadId").setP0(100).setQ0(50).setNode(4).add();

ReportNode reportNode = ReportNode.newRootReportNode()
.withResourceBundles(PowsyblTestReportResourceBundle.TEST_BASE_NAME, PowsyblCoreReportResourceBundle.BASE_NAME)
.withMessageTemplate("reportNodeTestRevertCreateLineOnLineKeepingTheVL")
.build();
modification = new RevertCreateLineOnLineBuilder()
.withLineToBeMerged1Id("CJ_1")
.withLineToBeMerged2Id("CJ_2")
.withLineToBeDeletedId("testLine")
.withMergedLineId("CJ_NEW")
.build();
modification.apply(network, true, reportNode);
vl = network.getVoltageLevel("CJ_VL");
assertNotNull(vl);
Load load = network.getLoad("loadId");
assertNotNull(load);
testReportNode(reportNode, "/reportNode/revert-create-line-on-line-keeping-vl.txt");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ ReportNodeTest = Testing reportNode
reportNodeTestRevertCreateLineOnLine = Testing reportNode for reverting create line on line in node/breaker network
reportNodeTestRevertCreateLineOnLineBB = Testing reportNode for reverting create line on line in bus/breaker network
reportNodeTestRevertCreateLineOnLineNBBB = Testing reportNode for reverting create line on line with mixed topology network
reportNodeTestRevertCreateLineOnLineKeepingTheVL = Testing reportNode for reverting create line on line and not removing the voltage level
reportPlannedDisconnectionComplete = Testing reportNode for connectable disconnection
reportTest = Testing reportNode
reportTestBbsInWrongVL = Testing reportNode with busbar section in wrong voltage level
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
+ Testing reportNode for reverting create line on line and not removing the voltage level
Line CJ_1 removed
Line CJ_2 removed
Line testLine removed
Line CJ_NEW created
Voltage level CJ_VL still contains equipments including quadripoles, it is not removed
Voltage level VLTEST removed
Comment on lines +1 to +7
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So you are expecting everything to be deleted even if the voltage level cannot be deleted ? Wouldn't it be better to check before deleting instead of starting and noticing that one of the element cannot be deleted ?

Loading