Skip to content

Commit

Permalink
Test RTC TCC export (#2920).
Browse files Browse the repository at this point in the history
Signed-off-by: stojkovicn <nemanja.stojkovic@rte-france.com>
Signed-off-by: nemanja-st <nemanja.stojkovic@redstork-solutions.com>
  • Loading branch information
stojkovicn authored and nemanja-st committed Jul 23, 2024
1 parent 2387807 commit eddf3b5
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -1046,6 +1047,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 + "\""));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -424,6 +425,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("<cim:RegulatingControl.discrete>" + discrete + "</cim:RegulatingControl.discrete>"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -923,6 +923,30 @@ public static Network createWithTieLinesAndAreas(NetworkFactory networkFactory)
.addVoltageLevel(network.getVoltageLevel(VLHV2))
.addVoltageLevel(network.getVoltageLevel(VLLOAD))
.add();
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;
}
Expand Down

0 comments on commit eddf3b5

Please sign in to comment.