Skip to content

Commit

Permalink
Fix slack distribution outerloop incorrect stable status (#1157)
Browse files Browse the repository at this point in the history
Signed-off-by: Damien Jeandemange <[email protected]>
  • Loading branch information
jeandemanged authored Dec 18, 2024
1 parent 78cf08a commit c7f69ad
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,10 @@ public Result run(LfGenerator referenceGenerator, Collection<LfBus> buses, doubl
iteration++;
}

// Identify if injections moved significantly, used e.g. to establish stable/unstable outer loop status.
// The 0.9 magic factor is to handle potential rounding issues.
final boolean movedBuses = initialP.entrySet().stream()
.anyMatch(e -> Math.abs(e.getKey().getTargetP() - e.getValue()) > P_RESIDUE_EPS);
.mapToDouble(e -> Math.abs(e.getKey().getTargetP() - e.getValue())).sum() > P_RESIDUE_EPS * 0.9;

return new Result(iteration, remainingMismatch, movedBuses);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -642,4 +642,14 @@ void testSlackMismatchChangingSignReferenceGenerator() {
assertActivePowerEquals(-90.000, g3.getTerminal());
assertActivePowerEquals(-90.000, g4.getTerminal());
}

@Test
void testEpsilonDistribution() {
parametersExt.setSlackBusPMaxMismatch(0.1);
network = DistributedSlackNetworkFactory.createWithEpsilonDistribution();
LoadFlowResult result = loadFlowRunner.run(network, parameters);
assertTrue(result.isFullyConverged());
assertEquals(0.0, result.getComponentResults().get(0).getSlackBusResults().get(0).getActivePowerMismatch(), LoadFlowAssert.DELTA_POWER);
assertEquals(0.15, result.getComponentResults().get(0).getDistributedActivePower(), LoadFlowAssert.DELTA_POWER);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -222,4 +222,15 @@ public static Network createWithBattery() {
.add();
return network;
}

public static Network createWithEpsilonDistribution() {
// 0.15 MW slack mismatch to be distributed over 1000 generators
Network network = Network.create("distributed-generation-slack-bus", "code");
Bus b = createBus(network, "bus");
createLoad(b, "load", 1000.15);
for (int i = 0; i < 1000; i++) {
createGenerator(b, "g" + i, 1.0);
}
return network;
}
}

0 comments on commit c7f69ad

Please sign in to comment.