From 4d197f26d0dd4a60c382b08a2b2e730799476371 Mon Sep 17 00:00:00 2001 From: stojkovicn Date: Thu, 9 May 2024 09:22:27 +0200 Subject: [PATCH] Test RTC TCC export (#2920). Signed-off-by: stojkovicn --- .../test/export/EquipmentExportTest.java | 34 +++++++++++++++++++ .../SteadyStateHypothesisExportTest.java | 34 +++++++++++++++++++ .../test/EurostagTutorialExample1Factory.java | 24 +++++++++++++ 3 files changed, 92 insertions(+) diff --git a/cgmes/cgmes-conversion/src/test/java/com/powsybl/cgmes/conversion/test/export/EquipmentExportTest.java b/cgmes/cgmes-conversion/src/test/java/com/powsybl/cgmes/conversion/test/export/EquipmentExportTest.java index 2425b2096c4..c00bbbcbe63 100644 --- a/cgmes/cgmes-conversion/src/test/java/com/powsybl/cgmes/conversion/test/export/EquipmentExportTest.java +++ b/cgmes/cgmes-conversion/src/test/java/com/powsybl/cgmes/conversion/test/export/EquipmentExportTest.java @@ -29,6 +29,7 @@ import com.powsybl.computation.local.LocalComputationManager; import com.powsybl.iidm.network.*; import com.powsybl.iidm.network.ThreeSides; +import com.powsybl.iidm.network.test.EurostagTutorialExample1Factory; import com.powsybl.iidm.network.test.PhaseShifterTestCaseFactory; import com.powsybl.iidm.network.test.ThreeWindingsTransformerNetworkFactory; import com.powsybl.iidm.serde.ExportOptions; @@ -1004,6 +1005,39 @@ void phaseTapChangerTapChangerControlEQTest() throws IOException { } } + @Test + void ratioTapChangerTapChangerControlEQTest() throws IOException { + String exportFolder = "/test-rtc-tcc"; + String baseName = "testRtcTcc"; + Network network; + String eq; + try (FileSystem fs = Jimfs.newFileSystem(Configuration.unix())) { + Path tmpDir = Files.createDirectory(fs.getPath(exportFolder)); + Properties exportParams = new Properties(); + exportParams.put(CgmesExport.PROFILES, "EQ"); + + // RTC local with VOLTAGE + network = EurostagTutorialExample1Factory.create(); + eq = getEQ(network, baseName, tmpDir, exportParams); + testTcTccWithAttribute(eq, "_NHV2_NLOAD_RTC_RC", "_NHV2_NLOAD_PT_T_2", "voltage"); + + // RTC local with REACTIVE_POWER + network = EurostagTutorialExample1Factory.createWithReactiveTcc(); + eq = getEQ(network, baseName, tmpDir, exportParams); + testTcTccWithAttribute(eq, "_NHV2_NLOAD_RTC_RC", "_NHV2_NLOAD_PT_T_2", "reactivePower"); + + // RTC remote with VOLTAGE + network = EurostagTutorialExample1Factory.createRemoteVoltageTcc(); + eq = getEQ(network, baseName, tmpDir, exportParams); + testTcTccWithAttribute(eq, "_NHV2_NLOAD_RTC_RC", "_GEN_SM_T_1", "voltage"); + + // RTC remote with REACTIVE_POWER + network = EurostagTutorialExample1Factory.createRemoteReactiveTcc(); + eq = getEQ(network, baseName, tmpDir, exportParams); + testTcTccWithAttribute(eq, "_NHV2_NLOAD_RTC_RC", "_GEN_SM_T_1", "reactivePower"); + } + } + private void testTcTccWithoutAttribute(String eq, String rcID, String terID, String rcMode) { assertFalse(eq.contains("cim:TapChangerControl rdf:ID=\"" + rcID + "\"")); assertFalse(eq.contains("cim:TapChanger.TapChangerControl rdf:resource=\"#" + rcID + "\"")); diff --git a/cgmes/cgmes-conversion/src/test/java/com/powsybl/cgmes/conversion/test/export/SteadyStateHypothesisExportTest.java b/cgmes/cgmes-conversion/src/test/java/com/powsybl/cgmes/conversion/test/export/SteadyStateHypothesisExportTest.java index e59916088d8..fbf83de2a11 100644 --- a/cgmes/cgmes-conversion/src/test/java/com/powsybl/cgmes/conversion/test/export/SteadyStateHypothesisExportTest.java +++ b/cgmes/cgmes-conversion/src/test/java/com/powsybl/cgmes/conversion/test/export/SteadyStateHypothesisExportTest.java @@ -25,6 +25,7 @@ import com.powsybl.iidm.network.ImportConfig; import com.powsybl.iidm.network.Network; import com.powsybl.iidm.network.NetworkFactory; +import com.powsybl.iidm.network.test.EurostagTutorialExample1Factory; import com.powsybl.iidm.network.test.PhaseShifterTestCaseFactory; import com.powsybl.iidm.serde.NetworkSerDe; import org.apache.commons.lang3.tuple.Pair; @@ -452,6 +453,39 @@ void phaseTapChangerTapChangerControlSSHTest() throws IOException { } } + @Test + void ratioTapChangerTapChangerControlSSHTest() throws IOException { + String exportFolder = "/test-rtc-tcc"; + String baseName = "testRtcTcc"; + Network network; + String ssh; + try (FileSystem fs = Jimfs.newFileSystem(Configuration.unix())) { + Path tmpDir = Files.createDirectory(fs.getPath(exportFolder)); + Properties exportParams = new Properties(); + exportParams.put(CgmesExport.PROFILES, "SSH"); + + // RTC local with VOLTAGE + network = EurostagTutorialExample1Factory.create(); + ssh = getSSH(network, baseName, tmpDir, exportParams); + testTcTccWithAttribute(ssh, "_NHV2_NLOAD_RTC_RC", "true", "true", "0", "158", "k"); + + // RTC local with REACTIVE_POWER + network = EurostagTutorialExample1Factory.createWithReactiveTcc(); + ssh = getSSH(network, baseName, tmpDir, exportParams); + testTcTccWithAttribute(ssh, "_NHV2_NLOAD_RTC_RC", "true", "true", "0", "100", "M"); + + // RTC remote with VOLTAGE + network = EurostagTutorialExample1Factory.createRemoteVoltageTcc(); + ssh = getSSH(network, baseName, tmpDir, exportParams); + testTcTccWithAttribute(ssh, "_NHV2_NLOAD_RTC_RC", "true", "true", "0", "158", "k"); + + // RTC remote with REACTIVE_POWER + network = EurostagTutorialExample1Factory.createRemoteReactiveTcc(); + ssh = getSSH(network, baseName, tmpDir, exportParams); + testTcTccWithAttribute(ssh, "_NHV2_NLOAD_RTC_RC", "true", "true", "0", "100", "M"); + } + } + private void testTcTccWithoutAttribute(String ssh, String rcID, String discrete, String enabled, String deadband, String target, String multiplier) { assertFalse(ssh.contains("cim:TapChangerControl rdf:about=\"#" + rcID + "\"")); assertFalse(ssh.contains("" + discrete + "")); diff --git a/iidm/iidm-test/src/main/java/com/powsybl/iidm/network/test/EurostagTutorialExample1Factory.java b/iidm/iidm-test/src/main/java/com/powsybl/iidm/network/test/EurostagTutorialExample1Factory.java index 7a404c9ce7a..fa62def56b2 100644 --- a/iidm/iidm-test/src/main/java/com/powsybl/iidm/network/test/EurostagTutorialExample1Factory.java +++ b/iidm/iidm-test/src/main/java/com/powsybl/iidm/network/test/EurostagTutorialExample1Factory.java @@ -872,4 +872,28 @@ public static Network createWithVoltageAngleLimit() { return network; } + + public static Network createWithReactiveTcc() { + Network network = create(); + network.getTwoWindingsTransformer("NHV2_NLOAD") + .getRatioTapChanger() + .setRegulationMode(RatioTapChanger.RegulationMode.REACTIVE_POWER) + .setRegulationValue(100); + return network; + } + + public static Network createRemoteReactiveTcc() { + return createRemoteTcc(createWithReactiveTcc()); + } + + public static Network createRemoteVoltageTcc() { + return createRemoteTcc(create()); + } + + private static Network createRemoteTcc(Network network) { + network.getTwoWindingsTransformer("NHV2_NLOAD") + .getRatioTapChanger() + .setRegulationTerminal(network.getGenerator("GEN").getTerminal()); + return network; + } }