Skip to content

Commit

Permalink
change DC slack distribution usage conditions
Browse files Browse the repository at this point in the history
Signed-off-by: vmouradian <[email protected]>
  • Loading branch information
vmouradian committed Dec 18, 2024
1 parent 3ffc89a commit 1a417ae
Showing 1 changed file with 12 additions and 21 deletions.
33 changes: 12 additions & 21 deletions src/main/java/com/powsybl/openloadflow/dc/DcLoadFlowEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public DcLoadFlowResult run() {
RunningContext runningContext = new RunningContext();
List<DcOuterLoop> outerLoops = parameters.getOuterLoops();

boolean distributedSlack = parameters.isDistributedSlack() || areaInterchangeControlFallback();
boolean distributedSlack = isDistributedSlack();

List<DcOuterLoop> activeOuterLoops = outerLoops.stream()
.toList();
Expand All @@ -209,16 +209,9 @@ public DcLoadFlowResult run() {
boolean useActiveLimits = parameters.getNetworkParameters().isUseActiveLimits();
ActivePowerDistribution activePowerDistribution = ActivePowerDistribution.create(balanceType, false, useActiveLimits);
var result = activePowerDistribution.run(network, initialSlackBusActivePowerMismatch);
final LfGenerator referenceGenerator;
final OpenLoadFlowParameters.SlackDistributionFailureBehavior behavior;
if (parameters.isAreaInterchangeControl()) {
// actual behavior will be handled by the outerloop itself, just leave on slack bus here
behavior = OpenLoadFlowParameters.SlackDistributionFailureBehavior.LEAVE_ON_SLACK_BUS;
referenceGenerator = null;
} else {
behavior = parameters.getSlackDistributionFailureBehavior();
referenceGenerator = context.getNetwork().getReferenceGenerator();
}
final LfGenerator referenceGenerator = context.getNetwork().getReferenceGenerator();
final OpenLoadFlowParameters.SlackDistributionFailureBehavior behavior = parameters.getSlackDistributionFailureBehavior();

ActivePowerDistribution.ResultWithFailureBehaviorHandling resultWbh = ActivePowerDistribution.handleDistributionFailureBehavior(
behavior,
referenceGenerator,
Expand Down Expand Up @@ -331,18 +324,16 @@ public static <T> List<DcLoadFlowResult> run(T network, LfNetworkLoader<T> netwo
}

/**
* If Area Interchange Control is activated but the network has no area, we remove the AIC outer loop and fall back to distributed slack
* If Area Interchange Control is activated, slack distribution is used only if the network has no Area. Otherwise, it will be entirely handled by the AIC outer loop
* If Area Interchange Control is not activated, slack distribution is used according to the parameter
*/
boolean areaInterchangeControlFallback() {
List<DcOuterLoop> outerLoops = context.getParameters().getOuterLoops();
boolean aicOuterLoop = outerLoops.stream().anyMatch(DcAreaInterchangeControlOuterLoop.class::isInstance);
if (aicOuterLoop && !context.getNetwork().hasArea()) {
context.getParameters().setOuterLoops(outerLoops.stream()
.filter(ol -> !(ol instanceof DcAreaInterchangeControlOuterLoop))
.toList());
return true;
boolean isDistributedSlack() {
boolean hasAicOuterLoop = context.getParameters().getOuterLoops().stream().anyMatch(DcAreaInterchangeControlOuterLoop.class::isInstance);
if (hasAicOuterLoop) {
return !context.getNetwork().hasArea();
} else {
return context.getParameters().isDistributedSlack();
}
return false;
}

}

0 comments on commit 1a417ae

Please sign in to comment.