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

BBranch calculated connectable bus from NB view can be null #1008

Merged
merged 3 commits into from
Nov 12, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -401,8 +401,8 @@ BusExt getConnectableBus(int node) {
// if nothing found, just take the first bus
if (connectableBus2[0] == null) {
Iterator<CalculatedBus> it = getBuses().iterator();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't remember why the original check is done using iterator but as getBuses() returns a Collection it would be more clear to use isEmpty()

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree on using isEmpty

if (!it.hasNext()) {
throw new AssertionError("Should not happen");
if (!it.hasNext()) { // if the whole voltage level is disconnected, return null
return null;
}
return it.next();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ private static Network createIsolatedLoadNetwork() {
VoltageLevel vl1 = s1.newVoltageLevel().setId("VL").setNominalV(1f)
.setTopologyKind(TopologyKind.NODE_BREAKER)
.add();
VoltageLevel vl2 = s1.newVoltageLevel().setId("VL2").setNominalV(1f)
.setTopologyKind(TopologyKind.NODE_BREAKER)
.add();

vl1.getNodeBreakerView()
.setNodeCount(11)
Expand Down Expand Up @@ -150,6 +153,15 @@ private static Network createIsolatedLoadNetwork() {
.setNode2(2)
.setRetained(true)
.add();

vl2.getNodeBreakerView()
.setNodeCount(1);
vl2.newLoad()
.setId("L4")
.setNode(0)
.setP0(0)
.setQ0(0)
.add();
return network;
}

Expand Down Expand Up @@ -283,5 +295,9 @@ public void testIsolatedLoadBusBranch() {
// load "L3" is not connected and has no connectable bus (the first bus is taken as connectable bus in this case)
assertNull(getBus(network.getLoad("L3")));
assertEquals("VL_0", getConnectableBus(network.getLoad("L3")).getId());

// load "L4" is not connected, has no connectable bus and is in a disconnected voltage level
assertNull(getBus(network.getLoad("L4")));
assertNull(getConnectableBus(network.getLoad("L4")));
}
}