From ac0de6c3cd7f1088bc108dc5a6106043ce15ca3b Mon Sep 17 00:00:00 2001 From: Coline PILOQUET Date: Mon, 9 Sep 2024 13:45:33 +0200 Subject: [PATCH 1/6] Export boundary TNs in TI. Signed-off-by: Coline PILOQUET --- .../powsybl/cgmes/conversion/export/StateVariablesExport.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/export/StateVariablesExport.java b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/export/StateVariablesExport.java index d6418aa9790..d5fbfd2bab1 100644 --- a/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/export/StateVariablesExport.java +++ b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/export/StateVariablesExport.java @@ -101,6 +101,10 @@ private static void writeTopologicalIslands(Network network, CgmesExportContext for (String tn : island.topologicalNodes) { CgmesExportUtil.writeReference("TopologicalIsland.TopologicalNodes", tn, cimNamespace, writer, context); } + for (DanglingLine dl : network.getDanglingLines(DanglingLineFilter.ALL)) { + String topologicalNodeId = dl.getProperty(Conversion.CGMES_PREFIX_ALIAS_PROPERTIES + CgmesNames.TOPOLOGICAL_NODE_BOUNDARY); + CgmesExportUtil.writeReference("TopologicalIsland.TopologicalNodes", topologicalNodeId, cimNamespace, writer, context); + } writer.writeEndElement(); } } From e8b0317950c624624e93acb00eb7155f8b63db24 Mon Sep 17 00:00:00 2001 From: Coline PILOQUET Date: Mon, 9 Sep 2024 13:48:30 +0200 Subject: [PATCH 2/6] Fix comment. Signed-off-by: Coline PILOQUET --- .../powsybl/cgmes/conversion/export/StateVariablesExport.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/export/StateVariablesExport.java b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/export/StateVariablesExport.java index d5fbfd2bab1..24543fda5f3 100644 --- a/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/export/StateVariablesExport.java +++ b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/export/StateVariablesExport.java @@ -62,7 +62,7 @@ public static void write(Network network, XMLStreamWriter writer, CgmesExportCon if (context.getCimVersion() >= 16) { CgmesExportUtil.writeModelDescription(network, CgmesSubset.STATE_VARIABLES, writer, model, context); writeTopologicalIslands(network, context, writer); - // Note: unmapped topological nodes (node breaker) & boundary topological nodes are not written in topological islands + // Note: unmapped topological nodes (node breaker) topological nodes are not written in topological islands } writeVoltagesForTopologicalNodes(network, context, writer); From a3f861005898a18d795c672bbe21c8f0d005b0ae Mon Sep 17 00:00:00 2001 From: Coline PILOQUET Date: Thu, 26 Sep 2024 13:25:46 +0200 Subject: [PATCH 3/6] Add boundary TN to the island directly Signed-off-by: Coline PILOQUET --- .../export/StateVariablesExport.java | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/export/StateVariablesExport.java b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/export/StateVariablesExport.java index 24543fda5f3..e5cac989aad 100644 --- a/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/export/StateVariablesExport.java +++ b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/export/StateVariablesExport.java @@ -62,7 +62,7 @@ public static void write(Network network, XMLStreamWriter writer, CgmesExportCon if (context.getCimVersion() >= 16) { CgmesExportUtil.writeModelDescription(network, CgmesSubset.STATE_VARIABLES, writer, model, context); writeTopologicalIslands(network, context, writer); - // Note: unmapped topological nodes (node breaker) topological nodes are not written in topological islands + // Note: unmapped topological nodes (node breaker) are not written in topological islands } writeVoltagesForTopologicalNodes(network, context, writer); @@ -101,10 +101,6 @@ private static void writeTopologicalIslands(Network network, CgmesExportContext for (String tn : island.topologicalNodes) { CgmesExportUtil.writeReference("TopologicalIsland.TopologicalNodes", tn, cimNamespace, writer, context); } - for (DanglingLine dl : network.getDanglingLines(DanglingLineFilter.ALL)) { - String topologicalNodeId = dl.getProperty(Conversion.CGMES_PREFIX_ALIAS_PROPERTIES + CgmesNames.TOPOLOGICAL_NODE_BOUNDARY); - CgmesExportUtil.writeReference("TopologicalIsland.TopologicalNodes", topologicalNodeId, cimNamespace, writer, context); - } writer.writeEndElement(); } } @@ -228,8 +224,8 @@ static TopologicalIsland fromSynchronousComponent(String key, CgmesExportContext return new TopologicalIsland(key, new ArrayList<>(), context); } - static TopologicalIsland fromTopologicalNode(String topologicalNode, CgmesExportContext context) { - return new TopologicalIsland(topologicalNode, Collections.singletonList(topologicalNode), context); + static TopologicalIsland fromTopologicalNodes(List topologicalNodes, CgmesExportContext context) { + return new TopologicalIsland(topologicalNodes.get(0), topologicalNodes, context); } void addNode(String topologicalNode, Bus bus, boolean updateLoadFlowStatus) { @@ -296,13 +292,19 @@ boolean isInAccordanceWithKirchhoffsFirstLaw(Bus bus) { private static List buildIslands(Network network, CgmesExportContext context) { Map islands = new HashMap<>(); for (Bus b : network.getBusBreakerView().getBuses()) { - String topologicalNodeId = context.getNamingStrategy().getCgmesId(b); + // Adds the topological node of the bus and of any dangling line connected to this bus (QoCDC 4.0) + List topologicalNodeIds = new ArrayList<>(); + String busTnId = context.getNamingStrategy().getCgmesId(b); + topologicalNodeIds.add(busTnId); + b.getDanglingLines().forEach(dl -> topologicalNodeIds.add(dl.getProperty(Conversion.CGMES_PREFIX_ALIAS_PROPERTIES + CgmesNames.TOPOLOGICAL_NODE_BOUNDARY))); if (b.getSynchronousComponent() != null) { String key = String.valueOf(b.getSynchronousComponent().getNum()); TopologicalIsland island = islands.computeIfAbsent(key, k -> TopologicalIsland.fromSynchronousComponent(k, context)); - island.addNode(topologicalNodeId, b, context.isExportLoadFlowStatus()); + for (String topologicalNodeId : topologicalNodeIds) { + island.addNode(topologicalNodeId, b, context.isExportLoadFlowStatus()); + } } else { - islands.put(topologicalNodeId, TopologicalIsland.fromTopologicalNode(topologicalNodeId, context)); + islands.put(busTnId, TopologicalIsland.fromTopologicalNodes(topologicalNodeIds, context)); } } return islands.values().stream().toList(); From b2df62ee54499d561f44dbef9ff1928c56fdc6c8 Mon Sep 17 00:00:00 2001 From: Coline PILOQUET Date: Thu, 26 Sep 2024 17:47:57 +0200 Subject: [PATCH 4/6] Add test Signed-off-by: Coline PILOQUET --- .../test/export/StateVariablesExportTest.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/cgmes/cgmes-conversion/src/test/java/com/powsybl/cgmes/conversion/test/export/StateVariablesExportTest.java b/cgmes/cgmes-conversion/src/test/java/com/powsybl/cgmes/conversion/test/export/StateVariablesExportTest.java index d4dfeacc6ef..26a9e1661e9 100644 --- a/cgmes/cgmes-conversion/src/test/java/com/powsybl/cgmes/conversion/test/export/StateVariablesExportTest.java +++ b/cgmes/cgmes-conversion/src/test/java/com/powsybl/cgmes/conversion/test/export/StateVariablesExportTest.java @@ -687,6 +687,20 @@ void testDisconnectedTerminalForSlack() { assertFalse(svInjectionPattern.matcher(svDisconnected).find()); } + @Test + void testWriteBoundaryTnInTopologicalIsland() throws XMLStreamException, IOException { + Network network = Network.read(CgmesConformity1Catalog.microGridBaseCaseNL().dataSource()); + Optional terminal = network.getBusBreakerView().getBus("97d7d14a-7294-458f-a8d7-024700a08717").getConnectedTerminalStream().findFirst(); + assertTrue(terminal.isPresent()); + ReferenceTerminals.addTerminal(terminal.get()); + String sv = exportSvAsString(network, false); + Pattern p = Pattern.compile(" Date: Mon, 30 Sep 2024 09:32:59 +0200 Subject: [PATCH 6/6] Comment change in unit test Co-authored-by: rcourtier <129156292+rcourtier@users.noreply.github.com> Signed-off-by: Olivier Perrin --- .../cgmes/conversion/test/export/StateVariablesExportTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cgmes/cgmes-conversion/src/test/java/com/powsybl/cgmes/conversion/test/export/StateVariablesExportTest.java b/cgmes/cgmes-conversion/src/test/java/com/powsybl/cgmes/conversion/test/export/StateVariablesExportTest.java index 18f3c042985..79362611b81 100644 --- a/cgmes/cgmes-conversion/src/test/java/com/powsybl/cgmes/conversion/test/export/StateVariablesExportTest.java +++ b/cgmes/cgmes-conversion/src/test/java/com/powsybl/cgmes/conversion/test/export/StateVariablesExportTest.java @@ -696,7 +696,7 @@ void testWriteBoundaryTnInTopologicalIsland() throws XMLStreamException { String sv = exportSvAsString(network, false); Pattern p = Pattern.compile("