-
Notifications
You must be signed in to change notification settings - Fork 0
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
include node id in loadflow result #147
Changes from 11 commits
ec67836
615a1d3
db53de1
31523b6
fe07be0
db60742
0833f0e
3de893d
d3385c7
203779f
698ed4e
c235475
50f14d9
399002b
71b2670
8e93fbc
2e14a23
f9917d2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package org.gridsuite.loadflow.server.utils; | ||
|
||
import com.powsybl.iidm.network.*; | ||
import com.powsybl.security.BusBreakerViolationLocation; | ||
import com.powsybl.security.LimitViolation; | ||
import com.powsybl.security.NodeBreakerViolationLocation; | ||
import com.powsybl.security.ViolationLocation; | ||
|
||
import java.util.*; | ||
|
||
import static com.powsybl.security.ViolationLocation.Type.NODE_BREAKER; | ||
|
||
public final class LoadflowResultsUtils { | ||
|
||
private LoadflowResultsUtils() { | ||
} | ||
|
||
public static String getIdFromViolation(LimitViolation limitViolation, Network network) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. getViolationLocationId ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
Optional<ViolationLocation> violationLocation = limitViolation.getViolationLocation(); | ||
if (violationLocation.isEmpty()) { | ||
return limitViolation.getSubjectId(); | ||
} | ||
|
||
ViolationLocation location = violationLocation.get(); | ||
if (location.getType() == NODE_BREAKER) { | ||
NodeBreakerViolationLocation nodeBreakerViolationLocation = (NodeBreakerViolationLocation) location; | ||
return getBusIdOrVlIdNodeBreaker(nodeBreakerViolationLocation, network); | ||
} else { | ||
BusBreakerViolationLocation busBreakerViolationLocation = (BusBreakerViolationLocation) location; | ||
return getBusIdOrVlIdBusBreaker(busBreakerViolationLocation, network, limitViolation.getSubjectId()); | ||
} | ||
} | ||
|
||
public static String getBusIdOrVlIdNodeBreaker(NodeBreakerViolationLocation nodeBreakerViolationLocation, Network network) { | ||
VoltageLevel vl = network.getVoltageLevel(nodeBreakerViolationLocation.getVoltageLevelId()); | ||
|
||
List<String> busIds = nodeBreakerViolationLocation.getNodes().stream() | ||
.map(node -> vl.getNodeBreakerView().getTerminal(node)) | ||
.filter(Objects::nonNull) | ||
.map(Terminal::getConnectable) | ||
.filter(t -> t.getType() == IdentifiableType.BUSBAR_SECTION) | ||
.map(busBar -> ((BusbarSection) busBar).getTerminal().getBusView().getBus()) | ||
.filter(Objects::nonNull) | ||
.map(Bus::getId) | ||
.distinct() | ||
.toList(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In nodebreaker we want busbar sections ids and not bus ids There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done in powsybl-ws-commons |
||
|
||
return formatNodeId(busIds, nodeBreakerViolationLocation.getVoltageLevelId()); | ||
} | ||
|
||
public static String formatNodeId(List<String> nodesIds, String subjectId) { | ||
if (nodesIds.size() == 1) { | ||
return nodesIds.get(0); | ||
} else if (nodesIds.isEmpty()) { | ||
return subjectId; | ||
} else { | ||
return subjectId + " (" + String.join(", ", nodesIds) + " )"; | ||
} | ||
} | ||
|
||
public static String getBusIdOrVlIdBusBreaker(BusBreakerViolationLocation busBreakerViolationLocation, Network network, String subjectId) { | ||
List<String> busBreakerIds = busBreakerViolationLocation | ||
.getBusBreakerView(network) | ||
.getBusStream() | ||
.map(Identifiable::getId) | ||
.distinct().toList(); | ||
return formatNodeId(busBreakerIds, subjectId); | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why all methods are public
It's used only by LoadFlowWorkerService
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this code has been moved to powsybl-ws-commons , to avoid duplicating it for security-analysis-server