Skip to content

Commit

Permalink
Add configuration similar to the one in AbstractMainConnectedComponen…
Browse files Browse the repository at this point in the history
…tWithSwitchTest, with buses in bus breaker view between retained switches and with no equipments.

Signed-off-by: Franck LECUYER <[email protected]>
  • Loading branch information
FranckLecuyer committed Oct 3, 2024
1 parent ebe387e commit 16edded
Showing 1 changed file with 48 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.function.Supplier;
import java.util.stream.Collectors;

import static org.junit.Assert.assertEquals;
Expand All @@ -27,13 +28,14 @@
public class VoltageLevelSetVTest {
@Test
public void testWithMultipleBusInBusBreakerAndBusView() {
Network network = Network.create("test_mcc", "test");

VoltageLevelImpl vl1 = createNodeBreaker(network);
VoltageLevelImpl vl2 = createBusBreaker(network);

testSetVMultipleBusAcrossViews(vl1, NBVL_BUSBREAKERVIEWBUS_TO_BUSVIEWBUS, NBVL_BUSVIEWBUS_TO_BUSBREAKERVIEWBUS);
testSetVMultipleBusAcrossViews(vl2, BBVL_CONFIGUREDBUS_TO_BUSVIEWBUS, BBVL_BUSVIEWBUS_TO_CONFIGUREDBUS);
testSetVMultipleBusAcrossViews(() -> {
Network network = Network.create("test_mcc", "test");
return createNodeBreaker(network);
}, NBVL_BUSBREAKERVIEWBUS_TO_BUSVIEWBUS, NBVL_BUSVIEWBUS_TO_BUSBREAKERVIEWBUS);
testSetVMultipleBusAcrossViews(() -> {
Network network = Network.create("test_mcc", "test");
return createBusBreaker(network);
}, BBVL_CONFIGUREDBUS_TO_BUSVIEWBUS, BBVL_BUSVIEWBUS_TO_CONFIGUREDBUS);
}

private static final Map<String, String> NBVL_BUSBREAKERVIEWBUS_TO_BUSVIEWBUS = new TreeMap<>(Map.of(
Expand All @@ -43,7 +45,10 @@ public void testWithMultipleBusInBusBreakerAndBusView() {
"VL1_4", "VL1_4",
"VL1_10", "",
"VL1_11", "VL1_0",
"VL1_5", ""
"VL1_5", "",
"VL1_12", "",
"VL1_13", "",
"VL1_14", ""
));
private static final Map<String, List<String>> NBVL_BUSVIEWBUS_TO_BUSBREAKERVIEWBUS = invertMap(NBVL_BUSBREAKERVIEWBUS_TO_BUSVIEWBUS);

Expand Down Expand Up @@ -168,6 +173,37 @@ private static VoltageLevelImpl createNodeBreaker(Network network) {
.add();
vl1.newLoad().setId("VL1L6").setNode(11).setP0(1).setQ0(1).add().getTerminal().setP(0.001).setQ(1);

// add busbar section BBS7 with 3 retained switches between BBS7 and BBS6, so there are buses in bus breaker view
// between 2 retained switches and without equipment
vl1.getNodeBreakerView().newBusbarSection()
.setId("BBS7")
.setNode(12)
.add();
vl1.getNodeBreakerView().newSwitch()
.setId("VL1SW8")
.setKind(SwitchKind.DISCONNECTOR)
.setRetained(true)
.setOpen(false)
.setNode1(5)
.setNode2(13)
.add();
vl1.getNodeBreakerView().newSwitch()
.setId("VL1SW9")
.setKind(SwitchKind.DISCONNECTOR)
.setRetained(true)
.setOpen(false)
.setNode1(12)
.setNode2(14)
.add();
vl1.getNodeBreakerView().newSwitch()
.setId("VL1SW10")
.setKind(SwitchKind.BREAKER)
.setRetained(true)
.setOpen(false)
.setNode1(13)
.setNode2(14)
.add();

return (VoltageLevelImpl) vl1;
}

Expand Down Expand Up @@ -226,15 +262,13 @@ private static VoltageLevelImpl createBusBreaker(Network network) {
return (VoltageLevelImpl) vl2;
}

private void testSetVMultipleBusAcrossViews(VoltageLevelImpl vl, Map<String, String> busBreakerViewBusToBusViewBus, Map<String, List<String>> busViewBusToBusBreakerViewBus) {
private void testSetVMultipleBusAcrossViews(Supplier<VoltageLevel> supplier, Map<String, String> busBreakerViewBusToBusViewBus, Map<String, List<String>> busViewBusToBusBreakerViewBus) {

VoltageLevel vl = supplier.get();
for (Map.Entry<String, String > entry : busBreakerViewBusToBusViewBus.entrySet()) {
String busbreakerviewbusid = entry.getKey();
String busviewbusid = entry.getValue();

// should we replace with new network for each test ??
vl.invalidateCalculatedBuses(); // but this keeps previous v values
// TODO this forces a computation of all busviews
// need to test when views are not initialized
for (Bus bbvb : vl.getBusBreakerView().getBuses()) {
bbvb.setV(Double.NaN);
}
Expand All @@ -261,14 +295,11 @@ private void testSetVMultipleBusAcrossViews(VoltageLevelImpl vl, Map<String, Str
}
}

vl = supplier.get();
for (Map.Entry<String, List<String> > entry : busViewBusToBusBreakerViewBus.entrySet()) {
String busviewbusid = entry.getKey();
List<String> busbreakerviewbusids = entry.getValue();

// should we replace with new network for each test ??
vl.invalidateCalculatedBuses(); // but this keeps previous v values
// TODO this forces a computation of all busviews
// need to test when views are not initialized
for (Bus bbvb : vl.getBusBreakerView().getBuses()) {
bbvb.setV(Double.NaN);
}
Expand Down

0 comments on commit 16edded

Please sign in to comment.