From cebab1140d3d26c64f1d62374d408dc5f87bff5d Mon Sep 17 00:00:00 2001 From: danielthirion <152513244+danielthirion@users.noreply.github.com> Date: Thu, 13 Jun 2024 16:58:06 +0200 Subject: [PATCH] Fix hvdc ra inverted (#1036) * Fix HVDC RA direction convention in CIM crac creation Signed-off-by: thiriondan --- .../remedialaction/HvdcRangeActionCreator.java | 14 ++++++++++---- .../cim/craccreator/CimCracCreatorTest.java | 4 ++-- .../SweCNEDivergentAngleMonitoring_Z01.xml | 16 ++++++++-------- .../src/test/resources/SweCNEWithFailure_Z01.xml | 8 ++++---- .../src/test/resources/SweCNE_Z01.xml | 16 ++++++++-------- .../epic21_cim_crac_swe_d2/US21_6.feature | 4 ++-- 6 files changed, 34 insertions(+), 28 deletions(-) diff --git a/data/crac-creation/crac-creator-cim/src/main/java/com/powsybl/openrao/data/craccreation/creator/cim/craccreator/remedialaction/HvdcRangeActionCreator.java b/data/crac-creation/crac-creator-cim/src/main/java/com/powsybl/openrao/data/craccreation/creator/cim/craccreator/remedialaction/HvdcRangeActionCreator.java index 2746519b40..cc158ed38a 100644 --- a/data/crac-creation/crac-creator-cim/src/main/java/com/powsybl/openrao/data/craccreation/creator/cim/craccreator/remedialaction/HvdcRangeActionCreator.java +++ b/data/crac-creation/crac-creator-cim/src/main/java/com/powsybl/openrao/data/craccreation/creator/cim/craccreator/remedialaction/HvdcRangeActionCreator.java @@ -229,8 +229,14 @@ private void checkRegisteredResource(RemedialActionRegisteredResource registered } } - // Return type : - // -- the boolean indicates whether the Hvdc line is inverted + /** + * @param networkElement - HVDC line name + * @param minCapacity + * @param maxCapacity + * @param inNode - The area of the related oriented border study where the energy flows INTO. + * @param outNode - The area of the related oriented border study where the energy comes FROM. + * @return - the boolean indicates whether the Hvdc line is inverted + */ private boolean readHvdcRange(String networkElement, int minCapacity, int maxCapacity, String inNode, String outNode) { HvdcLine hvdcLine = network.getHvdcLine(networkElement); boolean isInverted; @@ -245,11 +251,11 @@ private boolean readHvdcRange(String networkElement, int minCapacity, int maxCap if (Objects.isNull(inNode) || Objects.isNull(outNode)) { throw new OpenRaoImportException(ImportStatus.INCOMPLETE_DATA, "Missing HVDC in or out aggregate nodes"); } - if (inNode.equals(from) && outNode.equals(to)) { + if (inNode.equals(to) && outNode.equals(from)) { isInverted = false; min = minCapacity; max = maxCapacity; - } else if (inNode.equals(to) && outNode.equals(from)) { + } else if (inNode.equals(from) && outNode.equals(to)) { isInverted = true; min = -maxCapacity; max = -minCapacity; diff --git a/data/crac-creation/crac-creator-cim/src/test/java/com/powsybl/openrao/data/craccreation/creator/cim/craccreator/CimCracCreatorTest.java b/data/crac-creation/crac-creator-cim/src/test/java/com/powsybl/openrao/data/craccreation/creator/cim/craccreator/CimCracCreatorTest.java index 024f93a3b6..c06f600f4d 100644 --- a/data/crac-creation/crac-creator-cim/src/test/java/com/powsybl/openrao/data/craccreation/creator/cim/craccreator/CimCracCreatorTest.java +++ b/data/crac-creation/crac-creator-cim/src/test/java/com/powsybl/openrao/data/craccreation/creator/cim/craccreator/CimCracCreatorTest.java @@ -537,8 +537,8 @@ void testImportHvdcRangeActions() { Set createdIds1 = Set.of("HVDC-direction11 + HVDC-direction12 - BBE2AA12 FFR3AA12 1", "HVDC-direction11 + HVDC-direction12 - BBE2AA11 FFR3AA11 1"); Set createdIds2 = Set.of("HVDC-direction11 + HVDC-direction12 - BBE2AA12 FFR3AA12 1", "HVDC-direction11 + HVDC-direction12 - BBE2AA11 FFR3AA11 1"); - assertHvdcRangeActionImported("HVDC-direction11", createdIds1, Set.of("BBE2AA11 FFR3AA11 1", "BBE2AA12 FFR3AA12 1"), Set.of("HVDC"), true); - assertHvdcRangeActionImported("HVDC-direction12", createdIds2, Set.of("BBE2AA11 FFR3AA11 1", "BBE2AA12 FFR3AA12 1"), Set.of("HVDC"), false); + assertHvdcRangeActionImported("HVDC-direction11", createdIds1, Set.of("BBE2AA11 FFR3AA11 1", "BBE2AA12 FFR3AA12 1"), Set.of("HVDC"), false); + assertHvdcRangeActionImported("HVDC-direction12", createdIds2, Set.of("BBE2AA11 FFR3AA11 1", "BBE2AA12 FFR3AA12 1"), Set.of("HVDC"), true); assertEquals("BBE2AA11 FFR3AA11 1 + BBE2AA12 FFR3AA12 1", importedCrac.getHvdcRangeAction("HVDC-direction11 + HVDC-direction12 - BBE2AA12 FFR3AA12 1").getGroupId().get()); assertEquals("BBE2AA11 FFR3AA11 1 + BBE2AA12 FFR3AA12 1", importedCrac.getHvdcRangeAction("HVDC-direction11 + HVDC-direction12 - BBE2AA11 FFR3AA11 1").getGroupId().get()); } diff --git a/data/result-exporter/swe-cne-exporter/src/test/resources/SweCNEDivergentAngleMonitoring_Z01.xml b/data/result-exporter/swe-cne-exporter/src/test/resources/SweCNEDivergentAngleMonitoring_Z01.xml index 8610867c75..2bcafda529 100644 --- a/data/result-exporter/swe-cne-exporter/src/test/resources/SweCNEDivergentAngleMonitoring_Z01.xml +++ b/data/result-exporter/swe-cne-exporter/src/test/resources/SweCNEDivergentAngleMonitoring_Z01.xml @@ -55,8 +55,8 @@ Contingency 1 name - HVDC-direction12@100.0@ - HVDC-direction12@100.0@ + HVDC-direction11@100.0@ + HVDC-direction11@100.0@ A20 @@ -99,8 +99,8 @@ Contingency 2 name - HVDC-direction11@400.0@ - HVDC-direction11@400.0@ + HVDC-direction12@400.0@ + HVDC-direction12@400.0@ A20 @@ -265,8 +265,8 @@ A18 - HVDC-direction12@100.0@ - HVDC-direction12@100.0@ + HVDC-direction11@100.0@ + HVDC-direction11@100.0@ A20 @@ -375,8 +375,8 @@ A18 - HVDC-direction11@400.0@ - HVDC-direction11@400.0@ + HVDC-direction12@400.0@ + HVDC-direction12@400.0@ A20 diff --git a/data/result-exporter/swe-cne-exporter/src/test/resources/SweCNEWithFailure_Z01.xml b/data/result-exporter/swe-cne-exporter/src/test/resources/SweCNEWithFailure_Z01.xml index 18e59dc18f..4e7a4cb9a8 100644 --- a/data/result-exporter/swe-cne-exporter/src/test/resources/SweCNEWithFailure_Z01.xml +++ b/data/result-exporter/swe-cne-exporter/src/test/resources/SweCNEWithFailure_Z01.xml @@ -67,8 +67,8 @@ Contingency 2 name - HVDC-direction11@400.0@ - HVDC-direction11@400.0@ + HVDC-direction12@400.0@ + HVDC-direction12@400.0@ A20 @@ -281,8 +281,8 @@ A18 - HVDC-direction11@400.0@ - HVDC-direction11@400.0@ + HVDC-direction12@400.0@ + HVDC-direction12@400.0@ A20 diff --git a/data/result-exporter/swe-cne-exporter/src/test/resources/SweCNE_Z01.xml b/data/result-exporter/swe-cne-exporter/src/test/resources/SweCNE_Z01.xml index aaec40f33f..6eb42673e6 100644 --- a/data/result-exporter/swe-cne-exporter/src/test/resources/SweCNE_Z01.xml +++ b/data/result-exporter/swe-cne-exporter/src/test/resources/SweCNE_Z01.xml @@ -55,8 +55,8 @@ Contingency 1 name - HVDC-direction12@100.0@ - HVDC-direction12@100.0@ + HVDC-direction11@100.0@ + HVDC-direction11@100.0@ A20 @@ -99,8 +99,8 @@ Contingency 2 name - HVDC-direction11@400.0@ - HVDC-direction11@400.0@ + HVDC-direction12@400.0@ + HVDC-direction12@400.0@ A20 @@ -271,8 +271,8 @@ A18 - HVDC-direction12@100.0@ - HVDC-direction12@100.0@ + HVDC-direction11@100.0@ + HVDC-direction11@100.0@ A20 @@ -381,8 +381,8 @@ A18 - HVDC-direction11@400.0@ - HVDC-direction11@400.0@ + HVDC-direction12@400.0@ + HVDC-direction12@400.0@ A20 diff --git a/tests/src/test/resources/com/powsybl/openrao/tests/features/epic21_cim_crac_swe_d2/US21_6.feature b/tests/src/test/resources/com/powsybl/openrao/tests/features/epic21_cim_crac_swe_d2/US21_6.feature index 023df4434e..3b3bcac13a 100644 --- a/tests/src/test/resources/com/powsybl/openrao/tests/features/epic21_cim_crac_swe_d2/US21_6.feature +++ b/tests/src/test/resources/com/powsybl/openrao/tests/features/epic21_cim_crac_swe_d2/US21_6.feature @@ -20,8 +20,8 @@ Feature: US 21.6 : Import HVDC Range Actions | HVDC-direction1 + HVDC-direction2 - BBE2AA12 FFR3AA12 1 | HVDC-direction1 + HVDC-direction2 - BBE2AA12 FFR3AA12 1 | BBE2AA12 FFR3AA12 1 | BBE2AA11 FFR3AA11 1 + BBE2AA12 FFR3AA12 1 | 0.0 | And the HVDC range actions should have the following ranges: | HvdcRangeActionId | Ranges | RangeType | Min | Max | - | HVDC-direction1 + HVDC-direction2 - BBE2AA11 FFR3AA11 1 | 1 | ABSOLUTE | -1500.0 | 1000.0 | - | HVDC-direction1 + HVDC-direction2 - BBE2AA12 FFR3AA12 1 | 1 | ABSOLUTE | -1500.0 | 1000.0 | + | HVDC-direction1 + HVDC-direction2 - BBE2AA11 FFR3AA11 1 | 1 | ABSOLUTE | -1000.0 | 1500.0 | + | HVDC-direction1 + HVDC-direction2 - BBE2AA12 FFR3AA12 1 | 1 | ABSOLUTE | -1000.0 | 1500.0 | And the remedial actions should have the following usage rules: | RemedialActionId | UsageRules | Rule | Method | Instant | ContingencyId | FlowCnecId | | HVDC-direction1 + HVDC-direction2 - BBE2AA11 FFR3AA11 1 | 1 | OnContingencyState | Forced | auto | Co-1 | |