Skip to content

Commit

Permalink
Fix isElementConnectedToComponent removing disabled lines from compon…
Browse files Browse the repository at this point in the history
…ent even if both ends are still connected.

Signed-off-by: Hadrien <hadrien.godard@artelys.com>
  • Loading branch information
Hadrien-Godard committed May 27, 2022
1 parent b9e84c5 commit 770757d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ protected boolean isElementConnectedToComponent(LfElement element, Set<LfBus> co
if (element instanceof LfBus) {
return component.contains(element);
} else if (element instanceof LfBranch) {
return component.contains(((LfBranch) element).getBus1()) && component.contains(((LfBranch) element).getBus2());
return component.contains(((LfBranch) element).getBus1()) && component.contains(((LfBranch) element).getBus2()) && !element.isDisabled();
}
throw new PowsyblException("Cannot compute connectivity for variable element of class: " + element.getClass().getSimpleName());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,24 +289,23 @@ public void analyse(Network network, List<PropagatedContingency> contingencies,

Map<LfBus, Double> postContingencySlackParticipationByBus;

// Sensitivity values 0 and function reference NaN in case of a sensitivity on a disabled branch
contingencyFactors.stream()
.filter(lfFactor -> lfFactor.getFunctionElement() instanceof LfBranch)
.filter(lfFactor -> lfContingency.getDisabledBranches().contains(lfFactor.getFunctionElement()))
.forEach(lfFactor -> {
lfFactor.setSensitivityValuePredefinedResult(0d);
lfFactor.setFunctionPredefinedResult(Double.NaN);
});
// Sensitivity values 0 in case of a sensitivity from the transformer phase of a disabled transformer
contingencyFactors.stream()
.filter(lfFactor -> lfFactor.getVariableType().equals(SensitivityVariableType.TRANSFORMER_PHASE))
.filter(lfFactor -> lfContingency.getDisabledBranches().contains(lfNetwork.getBranchById(lfFactor.getVariableId())))
.forEach(lfFactor -> lfFactor.setSensitivityValuePredefinedResult(0d));

if (lfContingency.getDisabledBuses().isEmpty()) {
// contingency not breaking connectivity
LOGGER.info("Contingency {} without loss of connectivity", lfContingency.getId());
postContingencySlackParticipationByBus = slackParticipationByBus;
// Sensitivity values 0 and function reference NaN in case of a sensitivity on a disabled branch
contingencyFactors.stream()
.filter(lfFactor -> lfFactor.getFunctionElement() instanceof LfBranch)
.filter(lfFactor -> lfContingency.getDisabledBranches().contains(lfFactor.getFunctionElement()))
.forEach(lfFactor -> {
lfFactor.setSensitivityValuePredefinedResult(0d);
lfFactor.setFunctionPredefinedResult(Double.NaN);
});
// Sensitivity values 0 in case of a sensitivity from the transformer phase of a disabled transformer
contingencyFactors.stream()
.filter(lfFactor -> lfFactor.getVariableType().equals(SensitivityVariableType.TRANSFORMER_PHASE))
.filter(lfFactor -> lfContingency.getDisabledBranches().contains(lfNetwork.getBranchById(lfFactor.getVariableId())))
.forEach(lfFactor -> lfFactor.setSensitivityValuePredefinedResult(0d));
} else {
// contingency breaking connectivity
LOGGER.info("Contingency {} with loss of connectivity", lfContingency.getId());
Expand Down

0 comments on commit 770757d

Please sign in to comment.