Skip to content

Commit f755592

Browse files
Merge branch 'main' into fix-slack-ac-dc
2 parents d514ec1 + 64cfda2 commit f755592

3 files changed

Lines changed: 53 additions & 6 deletions

File tree

src/main/java/com/powsybl/openloadflow/network/impl/LfNetworkLoaderImpl.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,8 @@ private static void checkAndCreateVoltageControl(LfBus controllerBus,
176176
.anyMatch(lfGenerator -> !checkUniqueControlledBus(controlledBus, lfGenerator.getControlledBus(), controllerBus, parameters.isDisableInconsistentVoltageControls()));
177177

178178
// Check if target voltage is the same for the generators of current controller bus which have voltage control on
179-
boolean inconsistentTargetVoltages = !inconsistentControlledBus && voltageControlGenerators.stream().skip(1)
179+
boolean inconsistentTargetVoltages = voltageControlGenerators.stream().skip(1)
180+
.filter(lfGenerator -> Objects.equals(lfGenerator.getControlledBus(), controlledBus))
180181
.anyMatch(lfGenerator -> !checkUniqueTargetVControllerBus(lfGenerator, controllerTargetV, controllerBus, lfGenerator.getControlledBus(), parameters.isDisableInconsistentVoltageControls()));
181182

182183
if (parameters.isDisableInconsistentVoltageControls() && (inconsistentControlledBus || inconsistentTargetVoltages)) {
@@ -248,10 +249,10 @@ private static void checkUniqueTargetVControlledBus(double controllerTargetV, Lf
248249
if (deltaTargetV * controlledBus.getNominalV() > TARGET_V_EPSILON) {
249250
String busesId = vc.getControllerElements().stream().map(LfBus::getId).collect(Collectors.joining(", "));
250251
LOGGER.error("Bus '{}' control voltage of bus '{}' which is already controlled by buses '{}' with a different target voltage: {} (kept) and {} (ignored)",
251-
controllerBus.getId(), controlledBus.getId(), busesId, controllerTargetV * controlledBus.getNominalV(),
252-
voltageControlTargetV * controlledBus.getNominalV());
253-
Reports.reportBusAlreadyControlledWithDifferentTargetV(controllerBus.getNetwork().getReportNode(), controllerBus.getId(), controlledBus.getId(), busesId, controllerTargetV * controlledBus.getNominalV(),
254-
voltageControlTargetV * controlledBus.getNominalV());
252+
controllerBus.getId(), controlledBus.getId(), busesId, voltageControlTargetV * controlledBus.getNominalV(),
253+
controllerTargetV * controlledBus.getNominalV());
254+
Reports.reportBusAlreadyControlledWithDifferentTargetV(controllerBus.getNetwork().getReportNode(), controllerBus.getId(), controlledBus.getId(), busesId, voltageControlTargetV * controlledBus.getNominalV(),
255+
controllerTargetV * controlledBus.getNominalV());
255256
}
256257
}
257258

src/test/java/com/powsybl/openloadflow/ac/GeneratorTargetVoltageInconsistencyTest.java

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import com.powsybl.openloadflow.network.impl.Networks;
1515
import com.powsybl.openloadflow.util.LoadFlowAssert;
1616
import com.powsybl.openloadflow.util.PerUnit;
17+
import com.powsybl.openloadflow.util.report.PowsyblOpenLoadFlowReportResourceBundle;
1718
import org.junit.jupiter.api.Test;
1819

1920
import java.io.IOException;
@@ -357,4 +358,49 @@ void remoteAndLocalTestWithDisabling() {
357358
LoadFlowAssert.assertReportContains(".*Generators \\[g1\\, g2\\] are connected to the same bus vl1\\_0 but control the voltage of different buses \\(vl1\\_0 and vl2\\_0\\)\\: disabling voltage control", reportNode);
358359
assertEquals(150.0, lfNetwork.getBusById("vl1_0").getGenerationTargetQ() * PerUnit.SB);
359360
}
361+
362+
@Test
363+
void remoteAndLocalTestWithInconsistentTargetVoltage() throws IOException {
364+
Network network = createLocalInconsistentTargetVoltageNetwork();
365+
Generator g2 = network.getGenerator("g2");
366+
g2.setRegulatingTerminal(network.getLoad("ld2").getTerminal()).setTargetV(400.0);
367+
VoltageLevel vl1 = network.getVoltageLevel("vl1");
368+
vl1.newGenerator()
369+
.setId("g3")
370+
.setBus("b1")
371+
.setConnectableBus("b1")
372+
.setEnergySource(EnergySource.THERMAL)
373+
.setMinP(0)
374+
.setMaxP(200)
375+
.setTargetP(100)
376+
.setTargetV(24)
377+
.setVoltageRegulatorOn(true)
378+
.add();
379+
380+
LfNetworkParameters parameters = new LfNetworkParameters()
381+
.setGeneratorVoltageRemoteControl(true);
382+
383+
ReportNode reportNode = ReportNode.newRootReportNode()
384+
.withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME, PowsyblTestReportResourceBundle.TEST_BASE_NAME)
385+
.withMessageTemplate("testReport")
386+
.build();
387+
List<LfNetwork> networkList = Networks.load(network, parameters, reportNode);
388+
LfNetwork lfNetwork = networkList.get(0);
389+
LfBus lfBus = lfNetwork.getBusById("vl1_0");
390+
Optional<GeneratorVoltageControl> sharedVoltageControl = lfBus.getGeneratorVoltageControl();
391+
assertTrue(sharedVoltageControl.isPresent());
392+
LoadFlowAssert.assertTxtReportEquals("""
393+
+ Test Report
394+
+ Network CC0 SC0
395+
Generators [g1, g2, g3] are connected to the same bus vl1_0 but control the voltage of different buses: vl1_0 (kept) and vl2_0 (rejected)
396+
Generators [g1, g2, g3] are connected to the same bus vl1_0 with different target voltages: 23 kV (kept) and 24 kV (rejected)
397+
+ Network info
398+
Network has 2 buses and 1 branches
399+
Network balance: active generation=300 MW, active load=99.9 MW, reactive generation=0 MVar, reactive load=80 MVar
400+
Angle reference bus: vl1_0
401+
Slack bus: vl1_0
402+
""",
403+
reportNode);
404+
assertEquals(23.0, sharedVoltageControl.get().getTargetValue() * lfBus.getNominalV());
405+
}
360406
}

src/test/resources/busAlreadyControlledWithDifferentTargetVReport.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
+ Test Report
22
+ Network CC0 SC0
3-
Bus vl1_0 controls voltage of bus vl2_0 which is already controlled by buses [vl2_0, vl1_0] with a different target voltage: 412 kV (kept) and 413 kV (ignored)
3+
Bus vl1_0 controls voltage of bus vl2_0 which is already controlled by buses [vl2_0, vl1_0] with a different target voltage: 413 kV (kept) and 412 kV (ignored)
44
+ Network info
55
Network has 3 buses and 2 branches
66
Network balance: active generation=200 MW, active load=99.9 MW, reactive generation=0 MVar, reactive load=80 MVar

0 commit comments

Comments
 (0)