Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix load contingency #458

Merged
merged 4 commits into from
Feb 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,10 @@ private static PropagatedContingency create(Network network, Contingency conting
for (Load load : loadsToLose) {
Bus bus = withBreakers ? load.getTerminal().getBusBreakerView().getBus()
: load.getTerminal().getBusView().getBus();
loadIdsToShift.computeIfAbsent(bus.getId(), k -> new PowerShift())
.add(getLoadPowerShift(load, slackDistributionOnConformLoad));
if (bus != null) {
loadIdsToShift.computeIfAbsent(bus.getId(), k -> new PowerShift())
.add(getLoadPowerShift(load, slackDistributionOnConformLoad));
}
}
for (ShuntCompensator shunt : shuntsToLose) {
double nominalV = shunt.getTerminal().getVoltageLevel().getNominalV();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,14 @@ private static void setSlackBusId(LoadFlowParameters lfParameters, String slackB
.setSlackBusId(slackBusId);
}

private static PostContingencyResult getPostContingencyResult(SecurityAnalysisResult result, String contingencyId) {
private static Optional<PostContingencyResult> getOptionalPostContingencyResult(SecurityAnalysisResult result, String contingencyId) {
return result.getPostContingencyResults().stream()
.filter(r -> r.getContingency().getId().equals(contingencyId))
.findFirst()
.findFirst();
}

private static PostContingencyResult getPostContingencyResult(SecurityAnalysisResult result, String contingencyId) {
return getOptionalPostContingencyResult(result, contingencyId)
.orElseThrow();
}

Expand Down Expand Up @@ -985,6 +989,19 @@ void testSaWithLoadContingency() {
assertEquals(99.997, l4ContingencyResult.getBranchResult("l34").getP2(), LoadFlowAssert.DELTA_POWER);
}

@Test
void testSaWithDisconnectedLoadContingency() {
Network network = DistributedSlackNetworkFactory.createNetworkWithLoads();
network.getLoad("l2").getTerminal().disconnect();

List<Contingency> contingencies = List.of(new Contingency("l2", new LoadContingency("l2")));

SecurityAnalysisResult result = runSecurityAnalysis(network, contingencies);

// load is disconnected, contingency is skipped
assertFalse(getOptionalPostContingencyResult(result, "l2").isPresent());
}

@Test
void testSaWithLoadDetailContingency() {
Network network = DistributedSlackNetworkFactory.createNetworkWithLoads();
Expand Down