Skip to content

Commit

Permalink
Test Shunt compensator RC export (#2920).
Browse files Browse the repository at this point in the history
Signed-off-by: stojkovicn <nemanja.stojkovic@rte-france.com>
  • Loading branch information
stojkovicn committed May 9, 2024
1 parent b2dcaf1 commit 7912758
Show file tree
Hide file tree
Showing 3 changed files with 144 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,10 @@
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.SvcTestCaseFactory;
import com.powsybl.iidm.network.test.ThreeWindingsTransformerNetworkFactory;
import com.powsybl.iidm.network.test.*;
import com.powsybl.iidm.serde.ExportOptions;
import com.powsybl.iidm.serde.NetworkSerDe;
import com.powsybl.iidm.serde.XMLImporter;
import com.powsybl.iidm.network.test.FourSubstationsNodeBreakerFactory;
import com.powsybl.iidm.network.util.BranchData;
import com.powsybl.iidm.network.util.TwtData;

Expand Down Expand Up @@ -1103,6 +1099,59 @@ void staticVarCompensatorRegulatingControlEQTest() throws IOException {
}
}

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

// SC linear
network = ShuntTestCaseFactory.create();
eq = getEQ(network, baseName, tmpDir, exportParams);
testRcEqRcWithAttribute(eq, "_SHUNT_RC", "_LOAD_EC_T_1", "voltage");
testRcEqRCWithoutAttribute(eq, "", "", "reactivePower");

network = ShuntTestCaseFactory.createLocalLinear();
eq = getEQ(network, baseName, tmpDir, exportParams);
testRcEqRcWithAttribute(eq, "_SHUNT_RC", "_SHUNT_SC_T_1", "voltage");
testRcEqRCWithoutAttribute(eq, "", "", "reactivePower");

network = ShuntTestCaseFactory.createDisabledRemoteLinear();
eq = getEQ(network, baseName, tmpDir, exportParams);
testRcEqRcWithAttribute(eq, "_SHUNT_RC", "_LOAD_EC_T_1", "voltage");
testRcEqRCWithoutAttribute(eq, "", "", "reactivePower");

network = ShuntTestCaseFactory.createDisabledLocalLinear();
eq = getEQ(network, baseName, tmpDir, exportParams);
testRcEqRCWithoutAttribute(eq, "_SHUNT_RC", "_SHUNT_SC_T_1", "voltage");

// SC nonlinear
network = ShuntTestCaseFactory.createNonLinear();
eq = getEQ(network, baseName, tmpDir, exportParams);
testRcEqRcWithAttribute(eq, "_SHUNT_RC", "_LOAD_EC_T_1", "voltage");
testRcEqRCWithoutAttribute(eq, "", "", "reactivePower");

network = ShuntTestCaseFactory.createLocalNonLinear();
eq = getEQ(network, baseName, tmpDir, exportParams);
testRcEqRcWithAttribute(eq, "_SHUNT_RC", "_SHUNT_SC_T_1", "voltage");
testRcEqRCWithoutAttribute(eq, "", "", "reactivePower");

network = ShuntTestCaseFactory.createDisabledRemoteNonLinear();
eq = getEQ(network, baseName, tmpDir, exportParams);
testRcEqRcWithAttribute(eq, "_SHUNT_RC", "_LOAD_EC_T_1", "voltage");
testRcEqRCWithoutAttribute(eq, "", "", "reactivePower");

network = ShuntTestCaseFactory.createDisabledLocalNonLinear();
eq = getEQ(network, baseName, tmpDir, exportParams);
testRcEqRCWithoutAttribute(eq, "_SHUNT_RC", "_SHUNT_SC_T_1", "voltage");
}
}

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 @@ -27,6 +27,7 @@
import com.powsybl.iidm.network.NetworkFactory;
import com.powsybl.iidm.network.test.EurostagTutorialExample1Factory;
import com.powsybl.iidm.network.test.PhaseShifterTestCaseFactory;
import com.powsybl.iidm.network.test.ShuntTestCaseFactory;
import com.powsybl.iidm.network.test.SvcTestCaseFactory;
import com.powsybl.iidm.serde.NetworkSerDe;
import org.apache.commons.lang3.tuple.Pair;
Expand Down Expand Up @@ -551,6 +552,59 @@ void staticVarCompensatorRegulatingControlSSHTest() throws IOException {
}
}

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

// SC linear
network = ShuntTestCaseFactory.create();
ssh = getSSH(network, baseName, tmpDir, exportParams);
testRcEqRcWithAttribute(ssh, "_SHUNT_RC", "true", "true", "5", "200", "k");
testTcTccWithoutAttribute(ssh, "", "", "", "", "", "M");

network = ShuntTestCaseFactory.createLocalLinear();
ssh = getSSH(network, baseName, tmpDir, exportParams);
testRcEqRcWithAttribute(ssh, "_SHUNT_RC", "true", "true", "5", "200", "k");
testTcTccWithoutAttribute(ssh, "", "", "", "", "", "M");

network = ShuntTestCaseFactory.createDisabledRemoteLinear();
ssh = getSSH(network, baseName, tmpDir, exportParams);
testRcEqRcWithAttribute(ssh, "_SHUNT_RC", "true", "false", "5", "200", "k");
testTcTccWithoutAttribute(ssh, "", "", "", "", "", "M");

network = ShuntTestCaseFactory.createDisabledLocalLinear();
ssh = getSSH(network, baseName, tmpDir, exportParams);
testRcEqRCWithoutAttribute(ssh, "_SHUNT_RC");

// SC nonlinear
network = ShuntTestCaseFactory.createNonLinear();
ssh = getSSH(network, baseName, tmpDir, exportParams);
testRcEqRcWithAttribute(ssh, "_SHUNT_RC", "true", "true", "5", "200", "k");
testTcTccWithoutAttribute(ssh, "", "", "", "", "", "M");

network = ShuntTestCaseFactory.createLocalNonLinear();
ssh = getSSH(network, baseName, tmpDir, exportParams);
testRcEqRcWithAttribute(ssh, "_SHUNT_RC", "true", "true", "5", "200", "k");
testTcTccWithoutAttribute(ssh, "", "", "", "", "", "M");

network = ShuntTestCaseFactory.createDisabledRemoteNonLinear();
ssh = getSSH(network, baseName, tmpDir, exportParams);
testRcEqRcWithAttribute(ssh, "_SHUNT_RC", "true", "false", "5", "200", "k");
testTcTccWithoutAttribute(ssh, "", "", "", "", "", "M");

network = ShuntTestCaseFactory.createDisabledLocalNonLinear();
ssh = getSSH(network, baseName, tmpDir, exportParams);
testRcEqRCWithoutAttribute(ssh, "_SHUNT_RC");
}
}

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 @@ -141,4 +141,40 @@ private static Network createBase(NetworkFactory networkFactory) {
.add();
return network;
}

public static Network createLocalLinear() {
return createLocalShunt(create());
}

public static Network createLocalShunt(Network network) {
network.getShuntCompensator(SHUNT)
.setRegulatingTerminal(network.getShuntCompensator(SHUNT).getTerminal());
return network;
}

public static Network createDisabledRemoteLinear() {
return createDisabledShunt(create());
}

public static Network createDisabledLocalLinear() {
return createDisabledShunt(createLocalLinear());
}

public static Network createDisabledRemoteNonLinear() {
return createDisabledShunt(createNonLinear());
}

public static Network createDisabledLocalNonLinear() {
return createDisabledShunt(createLocalNonLinear());
}

public static Network createDisabledShunt(Network network) {
network.getShuntCompensator(SHUNT)
.setVoltageRegulatorOn(false);
return network;
}

public static Network createLocalNonLinear() {
return createLocalShunt(createNonLinear());
}
}

0 comments on commit 7912758

Please sign in to comment.