Skip to content

Commit

Permalink
BBranch calculated connectable bus from NB view can be null (#1008)
Browse files Browse the repository at this point in the history
* BBranch calculated connectable bus from NB view can be null

Signed-off-by: RALAMBOTIANA MIORA <[email protected]>

* use isEmpty

Signed-off-by: Luma Zamarreño <[email protected]>
  • Loading branch information
miovd authored and zamarrenolm committed Nov 12, 2019
1 parent c7aa6df commit ed24b0d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
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")));
}
}

0 comments on commit ed24b0d

Please sign in to comment.