Skip to content

Commit

Permalink
Test Generator RC 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 be45894 commit 6a707ad
Show file tree
Hide file tree
Showing 3 changed files with 127 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.extensions.RemoteReactivePowerControl;
import com.powsybl.iidm.network.test.*;
import com.powsybl.iidm.serde.ExportOptions;
import com.powsybl.iidm.serde.NetworkSerDe;
Expand Down Expand Up @@ -1194,6 +1195,51 @@ void shuntCompensatorRegulatingControlEQTest() throws IOException {
}
}

@Test
void generatorRegulatingControlEQTest() throws IOException {
String exportFolder = "/test-gen-rc";
String baseName = "testGenRc";
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");

// Generator local voltage
network = EurostagTutorialExample1Factory.create();
eq = getEQ(network, baseName, tmpDir, exportParams);
testRcEqRcWithAttribute(eq, "_GEN_RC", "_GEN_SM_T_1", "voltage");
network.getGenerator("GEN").setVoltageRegulatorOn(false);
eq = getEQ(network, baseName, tmpDir, exportParams);
testRcEqRcWithAttribute(eq, "_GEN_RC", "_GEN_SM_T_1", "voltage");

// Generator remote voltage
network = EurostagTutorialExample1Factory.createWithRemoteVoltageGenerator();
eq = getEQ(network, baseName, tmpDir, exportParams);
testRcEqRcWithAttribute(eq, "_GEN_RC", "_NHV2_NLOAD_PT_T_1", "voltage");
network.getGenerator("GEN").setVoltageRegulatorOn(false);
eq = getEQ(network, baseName, tmpDir, exportParams);
testRcEqRcWithAttribute(eq, "_GEN_RC", "_NHV2_NLOAD_PT_T_1", "voltage");

// Generator with local reactive
network = EurostagTutorialExample1Factory.createWithLocalReactiveGenerator();
eq = getEQ(network, baseName, tmpDir, exportParams);
testRcEqRcWithAttribute(eq, "_GEN_RC", "_GEN_SM_T_1", "reactivePower");
network.getGenerator("GEN").getExtension(RemoteReactivePowerControl.class).setEnabled(false);
eq = getEQ(network, baseName, tmpDir, exportParams);
testRcEqRcWithAttribute(eq, "_GEN_RC", "_GEN_SM_T_1", "reactivePower");

// Generator with remote reactive
network = EurostagTutorialExample1Factory.createWithRemoteReactiveGenerator();
eq = getEQ(network, baseName, tmpDir, exportParams);
testRcEqRcWithAttribute(eq, "_GEN_RC", "_NHV2_NLOAD_PT_T_1", "reactivePower");
network.getGenerator("GEN").getExtension(RemoteReactivePowerControl.class).setEnabled(false);
eq = getEQ(network, baseName, tmpDir, exportParams);
testRcEqRcWithAttribute(eq, "_GEN_RC", "_NHV2_NLOAD_PT_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.extensions.RemoteReactivePowerControl;
import com.powsybl.iidm.network.test.EurostagTutorialExample1Factory;
import com.powsybl.iidm.network.test.PhaseShifterTestCaseFactory;
import com.powsybl.iidm.network.test.ShuntTestCaseFactory;
Expand Down Expand Up @@ -577,6 +578,51 @@ void shuntCompensatorRegulatingControlSSHTest() throws IOException {
}
}

@Test
void generatorRegulatingControlSSHTest() throws IOException {
String exportFolder = "/test-gen-rc";
String baseName = "testGenRc";
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");

// Generator local voltage
network = EurostagTutorialExample1Factory.create();
ssh = getSSH(network, baseName, tmpDir, exportParams);
testRcEqRcWithAttribute(ssh, "_GEN_RC", "false", "true", "0", "24.5", "k");
network.getGenerator("GEN").setVoltageRegulatorOn(false);
ssh = getSSH(network, baseName, tmpDir, exportParams);
testRcEqRcWithAttribute(ssh, "_GEN_RC", "false", "false", "0", "24.5", "k");

// Generator remote voltage
network = EurostagTutorialExample1Factory.createWithRemoteVoltageGenerator();
ssh = getSSH(network, baseName, tmpDir, exportParams);
testRcEqRcWithAttribute(ssh, "_GEN_RC", "false", "true", "0", "24.5", "k");
network.getGenerator("GEN").setVoltageRegulatorOn(false);
ssh = getSSH(network, baseName, tmpDir, exportParams);
testRcEqRcWithAttribute(ssh, "_GEN_RC", "false", "false", "0", "24.5", "k");

// Generator with local reactive
network = EurostagTutorialExample1Factory.createWithLocalReactiveGenerator();
ssh = getSSH(network, baseName, tmpDir, exportParams);
testRcEqRcWithAttribute(ssh, "_GEN_RC", "false", "true", "0", "200", "M");
network.getGenerator("GEN").getExtension(RemoteReactivePowerControl.class).setEnabled(false);
ssh = getSSH(network, baseName, tmpDir, exportParams);
testRcEqRcWithAttribute(ssh, "_GEN_RC", "false", "false", "0", "200", "M");

// Generator with remote reactive
network = EurostagTutorialExample1Factory.createWithRemoteReactiveGenerator();
ssh = getSSH(network, baseName, tmpDir, exportParams);
testRcEqRcWithAttribute(ssh, "_GEN_RC", "false", "true", "0", "200", "M");
network.getGenerator("GEN").getExtension(RemoteReactivePowerControl.class).setEnabled(false);
ssh = getSSH(network, baseName, tmpDir, exportParams);
testRcEqRcWithAttribute(ssh, "_GEN_RC", "false", "false", "0", "200", "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 @@ -8,6 +8,7 @@
package com.powsybl.iidm.network.test;

import com.powsybl.iidm.network.*;
import com.powsybl.iidm.network.extensions.RemoteReactivePowerControlAdder;
import java.time.ZonedDateTime;

/**
Expand Down Expand Up @@ -950,4 +951,38 @@ private static Network createRemoteTcc(Network network) {

return network;
}

public static Network createWithRemoteVoltageGenerator() {
return addRemoteVoltageGenerator(create());
}

public static Network createWithRemoteReactiveGenerator() {
return addRemoteReactiveGenerator(create());
}

public static Network createWithLocalReactiveGenerator() {
return addLocalReactiveGenerator(create());
}

private static Network addLocalReactiveGenerator(Network network) {
return addReactiveGenerator(network, network.getGenerator("GEN").getRegulatingTerminal());
}

private static Network addRemoteReactiveGenerator(Network network) {
return addReactiveGenerator(network, network.getTwoWindingsTransformer(NHV2_NLOAD).getTerminal1());
}

private static Network addReactiveGenerator(Network network, Terminal terminal) {
network.getGenerator("GEN").newExtension(RemoteReactivePowerControlAdder.class)
.withRegulatingTerminal(terminal)
.withTargetQ(200)
.withEnabled(true).add();
return network;
}

private static Network addRemoteVoltageGenerator(Network network) {
network.getGenerator("GEN")
.setRegulatingTerminal(network.getTwoWindingsTransformer(NHV2_NLOAD).getTerminal1());
return network;
}
}

0 comments on commit 6a707ad

Please sign in to comment.