From e0c78c2e1336763a6b5d662a16d8bcb6cd307463 Mon Sep 17 00:00:00 2001 From: Luma Date: Fri, 28 Jun 2024 13:50:30 +0200 Subject: [PATCH] CGMES: Fix equivalent injection missing regulation target (#3087) * fix equivalent injection missing regulation target Signed-off-by: Luma --- .../EquivalentInjectionConversion.java | 7 +- .../test/EquivalentInjectionImportTest.java | 64 ++++++++++++++ .../resources/issues/ei_regulation_EQ.xml | 83 +++++++++++++++++++ .../resources/issues/ei_regulation_EQ_BD.xml | 31 +++++++ .../ei_regulation_missing_target_SSH.xml | 18 ++++ .../issues/ei_regulation_with_target_SSH.xml | 19 +++++ .../ei_regulation_with_target_zero_SSH.xml | 19 +++++ 7 files changed, 237 insertions(+), 4 deletions(-) create mode 100644 cgmes/cgmes-conversion/src/test/java/com/powsybl/cgmes/conversion/test/EquivalentInjectionImportTest.java create mode 100644 cgmes/cgmes-conversion/src/test/resources/issues/ei_regulation_EQ.xml create mode 100644 cgmes/cgmes-conversion/src/test/resources/issues/ei_regulation_EQ_BD.xml create mode 100644 cgmes/cgmes-conversion/src/test/resources/issues/ei_regulation_missing_target_SSH.xml create mode 100644 cgmes/cgmes-conversion/src/test/resources/issues/ei_regulation_with_target_SSH.xml create mode 100644 cgmes/cgmes-conversion/src/test/resources/issues/ei_regulation_with_target_zero_SSH.xml diff --git a/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/EquivalentInjectionConversion.java b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/EquivalentInjectionConversion.java index 72c9485c5df..1b23aeec791 100644 --- a/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/EquivalentInjectionConversion.java +++ b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/EquivalentInjectionConversion.java @@ -143,10 +143,9 @@ private Regulation getRegulation() { regulation.targetV = Double.NaN; if (regulation.status) { regulation.targetV = p.asDouble(REGULATION_TARGET); - if (regulation.targetV == 0) { - fixed(REGULATION_TARGET, "Target voltage value can not be zero", regulation.targetV, - voltageLevel().getNominalV()); - regulation.targetV = voltageLevel().getNominalV(); + if (Double.isNaN(regulation.targetV) || regulation.targetV == 0) { + missing("Valid target voltage value (voltage regulation is considered as off)"); + regulation.status = false; } } diff --git a/cgmes/cgmes-conversion/src/test/java/com/powsybl/cgmes/conversion/test/EquivalentInjectionImportTest.java b/cgmes/cgmes-conversion/src/test/java/com/powsybl/cgmes/conversion/test/EquivalentInjectionImportTest.java new file mode 100644 index 00000000000..40d556fe84c --- /dev/null +++ b/cgmes/cgmes-conversion/src/test/java/com/powsybl/cgmes/conversion/test/EquivalentInjectionImportTest.java @@ -0,0 +1,64 @@ +/** + * Copyright (c) 2024, RTE (http://www.rte-france.com) + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * SPDX-License-Identifier: MPL-2.0 + */ + +package com.powsybl.cgmes.conversion.test; + +import com.powsybl.commons.datasource.ResourceDataSource; +import com.powsybl.commons.datasource.ResourceSet; +import com.powsybl.commons.test.AbstractSerDeTest; +import com.powsybl.iidm.network.DanglingLine; +import com.powsybl.iidm.network.Network; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * @author Luma ZamarreƱo {@literal } + */ + +class EquivalentInjectionImportTest extends AbstractSerDeTest { + + @Test + void equivalentInjectionWithRegulationTargetTest() { + String basename = "ei_regulation"; + Network network = Network.read(new ResourceDataSource(basename, + new ResourceSet("/issues", + "ei_regulation_EQ.xml", + "ei_regulation_with_target_SSH.xml", + "ei_regulation_EQ_BD.xml"))); + DanglingLine dl = network.getDanglingLine("ACLS1"); + assertEquals(401, dl.getGeneration().getTargetV()); + assertTrue(dl.getGeneration().isVoltageRegulationOn()); + } + + @Test + void equivalentInjectionMissingRegulationTargetTest() { + String basename = "ei_regulation"; + Network network = Network.read(new ResourceDataSource(basename, + new ResourceSet("/issues", + "ei_regulation_EQ.xml", + "ei_regulation_missing_target_SSH.xml", + "ei_regulation_EQ_BD.xml"))); + DanglingLine dl = network.getDanglingLine("ACLS1"); + // No generation data has been created for the dangling line + assertNull(dl.getGeneration()); + } + + @Test + void equivalentInjectionWithRegulationTargetZeroTest() { + String basename = "ei_regulation"; + Network network = Network.read(new ResourceDataSource(basename, + new ResourceSet("/issues", + "ei_regulation_EQ.xml", + "ei_regulation_with_target_zero_SSH.xml", + "ei_regulation_EQ_BD.xml"))); + DanglingLine dl = network.getDanglingLine("ACLS1"); + // Zero is an invalid value, no generation data has been created for the dangling line + assertNull(dl.getGeneration()); + } +} diff --git a/cgmes/cgmes-conversion/src/test/resources/issues/ei_regulation_EQ.xml b/cgmes/cgmes-conversion/src/test/resources/issues/ei_regulation_EQ.xml new file mode 100644 index 00000000000..d1fffde719f --- /dev/null +++ b/cgmes/cgmes-conversion/src/test/resources/issues/ei_regulation_EQ.xml @@ -0,0 +1,83 @@ + + + 2024-06-28T11:00:00Z + 2024-06-28T11:00:00Z + 1 + Equivalent injection missing regulation target + https://www.powsybl.org/ + http://iec.ch/TC57/ns/CIM/CoreEquipment-EU/3.0 + + + + GeographicalRegionTest + GeographicalRegionTest + + + SubGeographicalRegionTest + SubGeographicalRegionTest + + + + Substation1 + Substation1 + + + + VoltageLevel1 + VoltageLevel1 + 420 + 380 + + + + + ConnectivityNode1 + Connectivity Node 1 + + + + + ACLS1 + + ACLS1 + 0.12 + 0 + 0.3 + 0.34 + + + ACLS1_T1 + ACLS1 Terminal 1 + 1 + + + + + + ACLS1_T2 + ACLS1 Terminal 2 + 2 + + + + + + + EI1 + EI1 + + + 0 + 0 + true + + + EI1_T + EI1 Terminal + 1 + + + + + + diff --git a/cgmes/cgmes-conversion/src/test/resources/issues/ei_regulation_EQ_BD.xml b/cgmes/cgmes-conversion/src/test/resources/issues/ei_regulation_EQ_BD.xml new file mode 100644 index 00000000000..43e90eddca7 --- /dev/null +++ b/cgmes/cgmes-conversion/src/test/resources/issues/ei_regulation_EQ_BD.xml @@ -0,0 +1,31 @@ + + + + 2024-06-28T11:00:00Z + 2024-06-28T11:00:00Z + 1 + Equivalent injection missing regulation target + http://iec.ch/TC57/ns/CIM/EquipmentBoundary-EU/3.0 + http://powsybl.org + + + BaseVoltage400 + Base Voltage Level 400kV + 400.0 kV + 400.0 + + + LineContainerAtBoundary1 + LineContainerAtBoundary1 + + + ConnectivityNodeAtBoundary1 + ConnectivityNodeAtBoundary1 + + + + BoundaryPoint1 + BoundaryPoint1 + + + diff --git a/cgmes/cgmes-conversion/src/test/resources/issues/ei_regulation_missing_target_SSH.xml b/cgmes/cgmes-conversion/src/test/resources/issues/ei_regulation_missing_target_SSH.xml new file mode 100644 index 00000000000..62e70216462 --- /dev/null +++ b/cgmes/cgmes-conversion/src/test/resources/issues/ei_regulation_missing_target_SSH.xml @@ -0,0 +1,18 @@ + + + 2024-06-28T11:00:00Z + 2024-06-28T11:00:00Z + 1 + Equivalent injection missing regulation target + https://www.powsybl.org/ + http://iec.ch/TC57/ns/CIM/SteadyStateHypothesis-EU/3.0 + + + + true + -100 + 10 + true + + + diff --git a/cgmes/cgmes-conversion/src/test/resources/issues/ei_regulation_with_target_SSH.xml b/cgmes/cgmes-conversion/src/test/resources/issues/ei_regulation_with_target_SSH.xml new file mode 100644 index 00000000000..8020f178e9d --- /dev/null +++ b/cgmes/cgmes-conversion/src/test/resources/issues/ei_regulation_with_target_SSH.xml @@ -0,0 +1,19 @@ + + + 2024-06-28T11:00:00Z + 2024-06-28T11:00:00Z + 1 + Equivalent injection missing regulation target + https://www.powsybl.org/ + http://iec.ch/TC57/ns/CIM/SteadyStateHypothesis-EU/3.0 + + + + true + -100 + 10 + true + + 401 + + diff --git a/cgmes/cgmes-conversion/src/test/resources/issues/ei_regulation_with_target_zero_SSH.xml b/cgmes/cgmes-conversion/src/test/resources/issues/ei_regulation_with_target_zero_SSH.xml new file mode 100644 index 00000000000..a65a9907701 --- /dev/null +++ b/cgmes/cgmes-conversion/src/test/resources/issues/ei_regulation_with_target_zero_SSH.xml @@ -0,0 +1,19 @@ + + + 2024-06-28T11:00:00Z + 2024-06-28T11:00:00Z + 1 + Equivalent injection missing regulation target + https://www.powsybl.org/ + http://iec.ch/TC57/ns/CIM/SteadyStateHypothesis-EU/3.0 + + + + true + -100 + 10 + true + + 0 + +