From 6cab016de1505042a6e2eea316bea4df94240e24 Mon Sep 17 00:00:00 2001 From: Geoffroy Jamgotchian Date: Wed, 23 Aug 2023 13:29:37 +0200 Subject: [PATCH 1/3] Improve error message for lines between 2 Xnodes Signed-off-by: Geoffroy Jamgotchian --- .../java/com/powsybl/ucte/converter/UcteImporter.java | 2 +- .../com/powsybl/ucte/converter/UcteImporterTest.java | 9 +++++++++ .../src/test/resources/lineBetweenTwoXnodes.uct | 8 ++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 ucte/ucte-converter/src/test/resources/lineBetweenTwoXnodes.uct diff --git a/ucte/ucte-converter/src/main/java/com/powsybl/ucte/converter/UcteImporter.java b/ucte/ucte-converter/src/main/java/com/powsybl/ucte/converter/UcteImporter.java index 3428294d4fb..4a60b88960f 100644 --- a/ucte/ucte-converter/src/main/java/com/powsybl/ucte/converter/UcteImporter.java +++ b/ucte/ucte-converter/src/main/java/com/powsybl/ucte/converter/UcteImporter.java @@ -457,7 +457,7 @@ private static void createLine(UcteNetworkExt ucteNetwork, Network network, createDanglingLine(ucteLine, connected, xnode, nodeCode1, ucteVoltageLevel1, network); } else { - throw new UcteException("Line between 2 Xnodes"); + throw new UcteException("Line between 2 Xnodes: '" + nodeCode1 + "' and '" + nodeCode2 + "'"); } } } diff --git a/ucte/ucte-converter/src/test/java/com/powsybl/ucte/converter/UcteImporterTest.java b/ucte/ucte-converter/src/test/java/com/powsybl/ucte/converter/UcteImporterTest.java index 58a02f276c2..a8da5cb9a1c 100644 --- a/ucte/ucte-converter/src/test/java/com/powsybl/ucte/converter/UcteImporterTest.java +++ b/ucte/ucte-converter/src/test/java/com/powsybl/ucte/converter/UcteImporterTest.java @@ -6,6 +6,7 @@ */ package com.powsybl.ucte.converter; +import com.powsybl.commons.PowsyblException; import com.powsybl.commons.datasource.ReadOnlyDataSource; import com.powsybl.commons.datasource.ResourceDataSource; import com.powsybl.commons.datasource.ResourceSet; @@ -274,5 +275,13 @@ void combineRtcAndPtc() { assertEquals(1.92419, network2.getTwoWindingsTransformer("BBE2AA1 BBE3AA1 1").getPhaseTapChanger().getCurrentStep().getAlpha(), 0.001); assertEquals(1.00000694, network2.getTwoWindingsTransformer("BBE2AA1 BBE3AA1 1").getPhaseTapChanger().getCurrentStep().getRho(), 0.0000001); // FIXME, symmetrical no impact } + + @Test + void lineBetweenTwoXnodesTest() { + ReadOnlyDataSource dataSource = new ResourceDataSource("lineBetweenTwoXnodes", new ResourceSet("/", "lineBetweenTwoXnodes.uct")); + NetworkFactory networkFactory = NetworkFactory.findDefault(); + PowsyblException e = assertThrows(PowsyblException.class, () -> new UcteImporter().importData(dataSource, networkFactory, null)); + assertEquals("Line between 2 Xnodes: 'XXNODE11' and 'XXNODE12'", e.getMessage()); + } } diff --git a/ucte/ucte-converter/src/test/resources/lineBetweenTwoXnodes.uct b/ucte/ucte-converter/src/test/resources/lineBetweenTwoXnodes.uct new file mode 100644 index 00000000000..6388522a920 --- /dev/null +++ b/ucte/ucte-converter/src/test/resources/lineBetweenTwoXnodes.uct @@ -0,0 +1,8 @@ +##C 2007.05.01 +Test case for a line between 2 xnodes error +##N +##ZXX +XXNODE11 1 0 0 0 0 0 0 0 0 0 0 0 0 0 +XXNODE12 1 0 0 0 0 0 0 0 0 0 0 0 0 0 +##L +XXNODE11 XXNODE12 1 0 2 10 65 200 INTERCO FR From 79d994983c1c1cadb398dce5d546082f58e35e9f Mon Sep 17 00:00:00 2001 From: Geoffroy Jamgotchian Date: Wed, 23 Aug 2023 13:57:01 +0200 Subject: [PATCH 2/3] Fix Signed-off-by: Geoffroy Jamgotchian --- .../java/com/powsybl/ucte/converter/UcteImporter.java | 8 ++++---- .../java/com/powsybl/ucte/converter/UcteImporterTest.java | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ucte/ucte-converter/src/main/java/com/powsybl/ucte/converter/UcteImporter.java b/ucte/ucte-converter/src/main/java/com/powsybl/ucte/converter/UcteImporter.java index 4a60b88960f..2348024db91 100644 --- a/ucte/ucte-converter/src/main/java/com/powsybl/ucte/converter/UcteImporter.java +++ b/ucte/ucte-converter/src/main/java/com/powsybl/ucte/converter/UcteImporter.java @@ -281,7 +281,7 @@ private static void createGenerator(UcteNode ucteNode, VoltageLevel voltageLevel private static void createDanglingLine(UcteLine ucteLine, boolean connected, UcteNode xnode, UcteNodeCode nodeCode, UcteVoltageLevel ucteVoltageLevel, Network network) { - LOGGER.trace("Create dangling line '{}' (Xnode='{}')", ucteLine.getId(), xnode.getCode()); + LOGGER.trace("Create dangling line '{}' (X-node='{}')", ucteLine.getId(), xnode.getCode()); double p0 = isValueValid(xnode.getActiveLoad()) ? xnode.getActiveLoad() : 0; double q0 = isValueValid(xnode.getReactiveLoad()) ? xnode.getReactiveLoad() : 0; @@ -457,7 +457,7 @@ private static void createLine(UcteNetworkExt ucteNetwork, Network network, createDanglingLine(ucteLine, connected, xnode, nodeCode1, ucteVoltageLevel1, network); } else { - throw new UcteException("Line between 2 Xnodes: '" + nodeCode1 + "' and '" + nodeCode2 + "'"); + throw new UcteException("Line between 2 X-nodes: '" + nodeCode1 + "' and '" + nodeCode2 + "'"); } } } @@ -664,7 +664,7 @@ private static TwoWindingsTransformer createXnodeTransfo(UcteNetworkExt ucteNetw UcteNode ucteXnode = ucteNetwork.getNode(xNodeCode); - LOGGER.warn("Create small impedance dangling line '{}{}' (transformer connected to XNODE '{}')", + LOGGER.warn("Create small impedance dangling line '{}{}' (transformer connected to X-node '{}')", xNodeName, yNodeName, ucteXnode.getCode()); double p0 = isValueValid(ucteXnode.getActiveLoad()) ? ucteXnode.getActiveLoad() : 0; @@ -853,7 +853,7 @@ private static DanglingLine getMatchingDanglingLine(DanglingLine dl1, Map new UcteImporter().importData(dataSource, networkFactory, null)); - assertEquals("Line between 2 Xnodes: 'XXNODE11' and 'XXNODE12'", e.getMessage()); + assertEquals("Line between 2 X-nodes: 'XXNODE11' and 'XXNODE12'", e.getMessage()); } } From adecfddf6f78fce513f588a7eef26f5cb41117c7 Mon Sep 17 00:00:00 2001 From: Geoffroy Jamgotchian Date: Wed, 23 Aug 2023 14:19:43 +0200 Subject: [PATCH 3/3] Fix Signed-off-by: Geoffroy Jamgotchian --- .../java/com/powsybl/ucte/converter/UcteImporterTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ucte/ucte-converter/src/test/java/com/powsybl/ucte/converter/UcteImporterTest.java b/ucte/ucte-converter/src/test/java/com/powsybl/ucte/converter/UcteImporterTest.java index b64bdb66777..5df911737e9 100644 --- a/ucte/ucte-converter/src/test/java/com/powsybl/ucte/converter/UcteImporterTest.java +++ b/ucte/ucte-converter/src/test/java/com/powsybl/ucte/converter/UcteImporterTest.java @@ -280,8 +280,8 @@ void combineRtcAndPtc() { void lineBetweenTwoXnodesTest() { ReadOnlyDataSource dataSource = new ResourceDataSource("lineBetweenTwoXnodes", new ResourceSet("/", "lineBetweenTwoXnodes.uct")); NetworkFactory networkFactory = NetworkFactory.findDefault(); - PowsyblException e = assertThrows(PowsyblException.class, () -> new UcteImporter().importData(dataSource, networkFactory, null)); + UcteImporter importer = new UcteImporter(); + PowsyblException e = assertThrows(PowsyblException.class, () -> importer.importData(dataSource, networkFactory, null)); assertEquals("Line between 2 X-nodes: 'XXNODE11' and 'XXNODE12'", e.getMessage()); } } -