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 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 @@ -23,7 +23,6 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -400,11 +399,11 @@ BusExt getConnectableBus(int node) {
});
// if nothing found, just take the first bus
if (connectableBus2[0] == null) {
Iterator<CalculatedBus> it = getBuses().iterator();
if (!it.hasNext()) {
throw new AssertionError("Should not happen");
Collection<CalculatedBus> buses = getBuses();
if (buses.isEmpty()) { // if the whole voltage level is disconnected, return null
return null;
}
return it.next();
return buses.iterator().next();
}
return connectableBus2[0];
}
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")));
}
}