Skip to content

Commit

Permalink
SVC and Shunt export change after review (#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 15, 2024
1 parent 611d144 commit bc1218f
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ private void addIidmMappingsShuntCompensators(Network network) {
continue;
}
String regulatingControlId = shuntCompensator.getProperty(Conversion.CGMES_PREFIX_ALIAS_PROPERTIES + REGULATING_CONTROL);
if (regulatingControlId == null && (shuntCompensator.isVoltageRegulatorOn() || !Objects.equals(shuntCompensator, shuntCompensator.getRegulatingTerminal().getConnectable()))) {
if (regulatingControlId == null && SteadyStateHypothesisExport.isValidVoltageSetpoint(shuntCompensator.getTargetV())) {
regulatingControlId = namingStrategy.getCgmesId(ref(shuntCompensator), Part.REGULATING_CONTROL);
shuntCompensator.setProperty(Conversion.CGMES_PREFIX_ALIAS_PROPERTIES + REGULATING_CONTROL, regulatingControlId);
}
Expand All @@ -533,7 +533,12 @@ private void addIidmMappingsShuntCompensators(Network network) {
private void addIidmMappingsStaticVarCompensators(Network network) {
for (StaticVarCompensator svc : network.getStaticVarCompensators()) {
String regulatingControlId = svc.getProperty(Conversion.CGMES_PREFIX_ALIAS_PROPERTIES + REGULATING_CONTROL);
if (regulatingControlId == null && (StaticVarCompensator.RegulationMode.VOLTAGE.equals(svc.getRegulationMode()) || !Objects.equals(svc, svc.getRegulatingTerminal().getConnectable()))) {
boolean validVoltageSetpoint = SteadyStateHypothesisExport.isValidVoltageSetpoint(svc.getVoltageSetpoint());
boolean validReactiveSetpoint = SteadyStateHypothesisExport.isValidReactivePowerSetpoint(svc.getReactivePowerSetpoint());
if (regulatingControlId == null && (
svc.getRegulationMode() == StaticVarCompensator.RegulationMode.VOLTAGE ||
svc.getRegulationMode() == StaticVarCompensator.RegulationMode.REACTIVE_POWER ||
validVoltageSetpoint && !validReactiveSetpoint || !validVoltageSetpoint && validReactiveSetpoint)) {
regulatingControlId = namingStrategy.getCgmesId(ref(svc), Part.REGULATING_CONTROL);
svc.setProperty(Conversion.CGMES_PREFIX_ALIAS_PROPERTIES + REGULATING_CONTROL, regulatingControlId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -605,24 +605,15 @@ private static void writeStaticVarCompensators(Network network, Map<Terminal, St
private static String getSvcMode(StaticVarCompensator svc) {
String mode = RegulatingControlEq.REGULATING_CONTROL_VOLTAGE;
StaticVarCompensator.RegulationMode regulationMode = svc.getRegulationMode();
// FIXME: remove RegulationMode.OFF when #2790 is done
if (regulationMode == StaticVarCompensator.RegulationMode.REACTIVE_POWER
|| regulationMode == StaticVarCompensator.RegulationMode.OFF
&& isValidSvcReactivePowerSetpoint(svc.getReactivePowerSetpoint())
&& !isValidSvcVoltageSetpoint(svc.getVoltageSetpoint())) {
&& SteadyStateHypothesisExport.isValidReactivePowerSetpoint(svc.getReactivePowerSetpoint())
&& !SteadyStateHypothesisExport.isValidVoltageSetpoint(svc.getVoltageSetpoint())) {
mode = RegulatingControlEq.REGULATING_CONTROL_REACTIVE_POWER;
}
return mode;
}

private static boolean isValidSvcVoltageSetpoint(double v) {
return Double.isFinite(v) && v > 0;
}

private static boolean isValidSvcReactivePowerSetpoint(double q) {
return Double.isFinite(q);
}

private static void writeLines(Network network, Map<Terminal, String> mapTerminal2Id, String cimNamespace, String euNamespace, String valueAttributeName, String limitTypeAttributeName, String limitKindClassName, boolean writeInfiniteDuration, XMLStreamWriter writer, CgmesExportContext context) throws XMLStreamException {
for (Line line : network.getLines()) {
String baseVoltage = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,11 +389,11 @@ private static void addRegulatingControlView(Generator g, Map<String, List<Regul
}
}

private static boolean isValidSvcVolatgeSetpoint(double v) {
public static boolean isValidVoltageSetpoint(double v) {
return Double.isFinite(v) && v > 0;
}

private static boolean isValidSvcReactivePowerSetpoint(double q) {
public static boolean isValidReactivePowerSetpoint(double q) {
return Double.isFinite(q);
}

Expand All @@ -418,13 +418,12 @@ private static void writeStaticVarCompensators(Network network, String cimNamesp
// Regulating control could be reactive power or voltage
double targetValue;
String multiplier;
// FIXME: remove RegulationMode.OFF when #2790 is done
if (regulationMode == StaticVarCompensator.RegulationMode.VOLTAGE
|| regulationMode == StaticVarCompensator.RegulationMode.OFF && isValidSvcVolatgeSetpoint(svc.getVoltageSetpoint()) && !isValidSvcReactivePowerSetpoint(svc.getReactivePowerSetpoint())) {
|| regulationMode == StaticVarCompensator.RegulationMode.OFF && isValidVoltageSetpoint(svc.getVoltageSetpoint()) && !isValidReactivePowerSetpoint(svc.getReactivePowerSetpoint())) {
targetValue = svc.getVoltageSetpoint();
multiplier = "k";
} else if (regulationMode == StaticVarCompensator.RegulationMode.REACTIVE_POWER
|| regulationMode == StaticVarCompensator.RegulationMode.OFF && isValidSvcReactivePowerSetpoint(svc.getReactivePowerSetpoint()) && !isValidSvcVolatgeSetpoint(svc.getVoltageSetpoint())) {
|| regulationMode == StaticVarCompensator.RegulationMode.OFF && isValidReactivePowerSetpoint(svc.getReactivePowerSetpoint()) && !isValidVoltageSetpoint(svc.getVoltageSetpoint())) {
targetValue = svc.getReactivePowerSetpoint();
multiplier = "M";
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1086,7 +1086,7 @@ void staticVarCompensatorRegulatingControlEQTest() throws IOException {
// Local
network = SvcTestCaseFactory.createLocalReactiveControl();
eq = getEQ(network, baseName, tmpDir, exportParams);
testRcEqRCWithoutAttribute(eq, "_SVC2_RC", "_SVC2_SVC_T_1", "reactivePower");
testRcEqRcWithAttribute(eq, "_SVC2_RC", "_SVC2_SVC_T_1", "reactivePower");

// Remote
network = SvcTestCaseFactory.createRemoteReactiveControl();
Expand All @@ -1100,18 +1100,18 @@ void staticVarCompensatorRegulatingControlEQTest() throws IOException {
testRcEqRCWithoutAttribute(eq, "_SVC2_RC", "_SVC2_SVC_T_1", "dummy");
network = SvcTestCaseFactory.createLocalOffReactiveTarget();
eq = getEQ(network, baseName, tmpDir, exportParams);
testRcEqRCWithoutAttribute(eq, "_SVC2_RC", "_SVC2_SVC_T_1", "dummy");
testRcEqRcWithAttribute(eq, "_SVC2_RC", "_SVC2_SVC_T_1", "reactivePower");
network = SvcTestCaseFactory.createLocalOffVoltageTarget();
eq = getEQ(network, baseName, tmpDir, exportParams);
testRcEqRCWithoutAttribute(eq, "_SVC2_RC", "_SVC2_SVC_T_1", "dummy");
testRcEqRcWithAttribute(eq, "_SVC2_RC", "_SVC2_SVC_T_1", "voltage");
network = SvcTestCaseFactory.createLocalOffBothTarget();
eq = getEQ(network, baseName, tmpDir, exportParams);
testRcEqRCWithoutAttribute(eq, "_SVC2_RC", "_SVC2_SVC_T_1", "dummy");

// Remote
network = SvcTestCaseFactory.createRemoteOffNoTarget();
eq = getEQ(network, baseName, tmpDir, exportParams);
testRcEqRcWithAttribute(eq, "_SVC2_RC", "_L2_EC_T_1", "voltage");
testRcEqRCWithoutAttribute(eq, "_SVC2_RC", "_L2_EC_T_1", "dummy");
network = SvcTestCaseFactory.createRemoteOffReactiveTarget();
eq = getEQ(network, baseName, tmpDir, exportParams);
testRcEqRcWithAttribute(eq, "_SVC2_RC", "_L2_EC_T_1", "reactivePower");
Expand All @@ -1120,7 +1120,7 @@ void staticVarCompensatorRegulatingControlEQTest() throws IOException {
testRcEqRcWithAttribute(eq, "_SVC2_RC", "_L2_EC_T_1", "voltage");
network = SvcTestCaseFactory.createRemoteOffBothTarget();
eq = getEQ(network, baseName, tmpDir, exportParams);
testRcEqRcWithAttribute(eq, "_SVC2_RC", "_L2_EC_T_1", "voltage");
testRcEqRCWithoutAttribute(eq, "_SVC2_RC", "_L2_EC_T_1", "dummy");
}
}

Expand Down Expand Up @@ -1153,7 +1153,16 @@ void shuntCompensatorRegulatingControlEQTest() throws IOException {

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

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

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

// SC nonlinear
network = ShuntTestCaseFactory.createNonLinear();
Expand All @@ -1173,7 +1182,15 @@ void shuntCompensatorRegulatingControlEQTest() throws IOException {

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

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ void staticVarCompensatorRegulatingControlSSHTest() throws IOException {
// Local
network = SvcTestCaseFactory.createLocalReactiveControl();
ssh = getSSH(network, baseName, tmpDir, exportParams);
testRcEqRCWithoutAttribute(ssh, "_SVC2_RC");
testRcEqRcWithAttribute(ssh, "_SVC2_RC", "false", "true", "0", "350", "M");

// Remote
network = SvcTestCaseFactory.createRemoteReactiveControl();
Expand All @@ -553,18 +553,18 @@ void staticVarCompensatorRegulatingControlSSHTest() throws IOException {
testRcEqRCWithoutAttribute(ssh, "_SVC2_RC");
network = SvcTestCaseFactory.createLocalOffReactiveTarget();
ssh = getSSH(network, baseName, tmpDir, exportParams);
testRcEqRCWithoutAttribute(ssh, "_SVC2_RC");
testRcEqRcWithAttribute(ssh, "_SVC2_RC", "false", "false", "0", "350", "M");
network = SvcTestCaseFactory.createLocalOffVoltageTarget();
ssh = getSSH(network, baseName, tmpDir, exportParams);
testRcEqRCWithoutAttribute(ssh, "_SVC2_RC");
testRcEqRcWithAttribute(ssh, "_SVC2_RC", "false", "false", "0", "390", "k");
network = SvcTestCaseFactory.createLocalOffBothTarget();
ssh = getSSH(network, baseName, tmpDir, exportParams);
testRcEqRCWithoutAttribute(ssh, "_SVC2_RC");

// Remote
network = SvcTestCaseFactory.createRemoteOffNoTarget();
ssh = getSSH(network, baseName, tmpDir, exportParams);
testRcEqRcWithAttribute(ssh, "_SVC2_RC", "false", "false", "0", "0", "k");
testRcEqRCWithoutAttribute(ssh, "_SVC2_RC");
network = SvcTestCaseFactory.createRemoteOffReactiveTarget();
ssh = getSSH(network, baseName, tmpDir, exportParams);
testRcEqRcWithAttribute(ssh, "_SVC2_RC", "false", "false", "0", "350", "M");
Expand All @@ -573,7 +573,7 @@ void staticVarCompensatorRegulatingControlSSHTest() throws IOException {
testRcEqRcWithAttribute(ssh, "_SVC2_RC", "false", "false", "0", "390", "k");
network = SvcTestCaseFactory.createRemoteOffBothTarget();
ssh = getSSH(network, baseName, tmpDir, exportParams);
testRcEqRcWithAttribute(ssh, "_SVC2_RC", "false", "false", "0", "0", "k");
testRcEqRCWithoutAttribute(ssh, "_SVC2_RC");
}
}

Expand Down Expand Up @@ -606,7 +606,16 @@ void shuntCompensatorRegulatingControlSSHTest() throws IOException {

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

network = ShuntTestCaseFactory.createLocalLinearNoTarget();
ssh = getSSH(network, baseName, tmpDir, exportParams);
testTcTccWithoutAttribute(ssh, "_SHUNT_RC", "", "", "", "", "");

network = ShuntTestCaseFactory.createRemoteLinearNoTarget();
ssh = getSSH(network, baseName, tmpDir, exportParams);
testTcTccWithoutAttribute(ssh, "_SHUNT_RC", "", "", "", "", "");

// SC nonlinear
network = ShuntTestCaseFactory.createNonLinear();
Expand All @@ -626,7 +635,16 @@ void shuntCompensatorRegulatingControlSSHTest() throws IOException {

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

network = ShuntTestCaseFactory.createLocalNonLinearNoTarget();
ssh = getSSH(network, baseName, tmpDir, exportParams);
testTcTccWithoutAttribute(ssh, "_SHUNT_RC", "", "", "", "", "");

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,29 @@ public static Network createDisabledShunt(Network network) {
return network;
}

private static Network createShuntWithNoTarget(Network network) {
network.getShuntCompensator(SHUNT)
.setVoltageRegulatorOn(false)
.setTargetV(Double.NaN);
return network;
}

public static Network createRemoteLinearNoTarget() {
return createShuntWithNoTarget(create());
}

public static Network createRemoteNonLinearNoTarget() {
return createShuntWithNoTarget(createNonLinear());
}

public static Network createLocalLinearNoTarget() {
return createShuntWithNoTarget(createLocalLinear());
}

public static Network createLocalNonLinearNoTarget() {
return createShuntWithNoTarget(createLocalNonLinear());
}

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

0 comments on commit bc1218f

Please sign in to comment.