Skip to content

Commit 814ae31

Browse files
Filter disabled generators when computing bus Q limits (#1220)
Signed-off-by: Didier Vidal <[email protected]> Co-authored-by: Damien Jeandemange <[email protected]>
1 parent ab057bb commit 814ae31

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

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

+1
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,7 @@ public double getMaxP() {
451451

452452
private double getLimitQ(ToDoubleFunction<LfGenerator> limitQ) {
453453
return generators.stream()
454+
.filter(g -> !g.isDisabled())
454455
.mapToDouble(generator -> (generator.getGeneratorControlType() == LfGenerator.GeneratorControlType.VOLTAGE ||
455456
generator.getGeneratorControlType() == LfGenerator.GeneratorControlType.REMOTE_REACTIVE_POWER) ?
456457
limitQ.applyAsDouble(generator) : generator.getTargetQ()).sum();

src/test/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysisTest.java

+34
Original file line numberDiff line numberDiff line change
@@ -4560,4 +4560,38 @@ void testHvdcRegularSeparation() {
45604560
assertActivePowerEquals(-195.600, cs3.getTerminal());
45614561
assertActivePowerEquals(-104.400, g4.getTerminal());
45624562
}
4563+
4564+
@Test
4565+
void testTwoGeneratorsAtSameBus() {
4566+
Network network = FourBusNetworkFactory.createWithTwoGeneratorsAtBus2();
4567+
network.getBusBreakerView().getBus("b2")
4568+
.getGeneratorStream()
4569+
.forEach(g -> {
4570+
g.setTargetV(1.5);
4571+
g.newMinMaxReactiveLimits()
4572+
.setMinQ(-6.5)
4573+
.setMaxQ(6.5)
4574+
.add();
4575+
g.setTargetQ(1);
4576+
4577+
});
4578+
4579+
List<StateMonitor> monitors = List.of(new StateMonitor(ContingencyContext.all(), Set.of("l12", "l23"), Set.of("b2_vl"), Collections.emptySet()));
4580+
List<Contingency> contingencies = List.of(new Contingency("g5", new GeneratorContingency("g5")));
4581+
SecurityAnalysisResult result = runSecurityAnalysis(network, contingencies, monitors);
4582+
NetworkResult networkResult = result.getPostContingencyResults().get(0).getNetworkResult();
4583+
double v = networkResult.getBusResult("b2").getV();
4584+
double q = -networkResult.getBranchResult("l12").getQ2() - networkResult.getBranchResult("l23").getQ1();
4585+
4586+
// test that G2 has reached its reactive limits
4587+
assertEquals(1.294, v, DELTA_V);
4588+
assertEquals(-6.5, q, 1e-2); // use precision in sync with default OpenLoadFlowParameters
4589+
4590+
// The N case is the same
4591+
network.getGenerator("g5").disconnect();
4592+
runLoadFlow(network, new LoadFlowParameters());
4593+
assertVoltageEquals(1.294, network.getBusBreakerView().getBus("b2"));
4594+
assertReactivePowerEquals(-6.5, network.getGenerator("g2").getTerminal());
4595+
4596+
}
45634597
}

0 commit comments

Comments
 (0)