Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
  • Loading branch information
geofjamg committed Dec 4, 2024
1 parent 44d8e42 commit 11b9ea1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,11 @@ public void allocateVariantArrayElement(int[] indexes, int sourceIndex) {
private void convertToBusBreakerModel() {
BusBreakerTopologyModel newTopologyModel = new BusBreakerTopologyModel(this);

// remove busbar sections because not needed in a bus/breaker topology
for (BusbarSection bbs : topologyModel.getNodeBreakerView().getBusbarSections()) {
bbs.remove();
}

for (Bus bus : topologyModel.getBusBreakerView().getBuses()) {
// no notification, this is just a mutation of a calculation bus to a configured bus
ConfiguredBusImpl configuredBus = new ConfiguredBusImpl(bus.getId(), bus.getOptionalName().orElse(null), bus.isFictitious(), this);
Expand Down Expand Up @@ -664,13 +669,10 @@ record TopologyModelInfos(TerminalExt terminal, String connectableBusId, boolean
AbstractConnectable<?> connectable = oldTerminalExt.getConnectable();

// create the new terminal with new type
TerminalExt newTerminalExt = null;
if (oldTerminalExt.getConnectable().getType() != IdentifiableType.BUSBAR_SECTION) {
newTerminalExt = new TerminalBuilder(networkRef, this, oldTerminalExt.getSide())
.setBus(infos.connected ? infos.connectableBusId() : null)
.setConnectableBus(infos.connectableBusId())
.build();
}
TerminalExt newTerminalExt = new TerminalBuilder(networkRef, this, oldTerminalExt.getSide())
.setBus(infos.connected ? infos.connectableBusId() : null)
.setConnectableBus(infos.connectableBusId())
.build();

connectable.replaceTerminal(oldTerminalExt, newTopologyModel, newTerminalExt, false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
import java.util.Collections;
import java.util.List;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.*;

/**
* @author Geoffroy Jamgotchian {@literal <geoffroy.jamgotchian at rte-france.com>}
Expand Down Expand Up @@ -59,7 +58,11 @@ void testNodeBreakerToBusBreaker() {
assertEquals(List.of("VSC1", "LD2", "LD3", "LD4", "LCC1"), busesBbModel.get(1).getConnectedTerminalStream().map(t -> t.getConnectable().getId()).toList());
// only retained switches have been kept
assertEquals(List.of("S1VL2_COUPLER"), vl.getBusBreakerView().getSwitchStream().map(Identifiable::getId).toList());
assertEquals(List.of(new RemovalNetworkEvent("S1VL2_BBS1_TWT_DISCONNECTOR", false),
assertEquals(List.of(new RemovalNetworkEvent("S1VL2_BBS1", false),
new RemovalNetworkEvent("S1VL2_BBS1", true),
new RemovalNetworkEvent("S1VL2_BBS2", false),
new RemovalNetworkEvent("S1VL2_BBS2", true),
new RemovalNetworkEvent("S1VL2_BBS1_TWT_DISCONNECTOR", false),
new RemovalNetworkEvent("S1VL2_BBS2_TWT_DISCONNECTOR", false),
new RemovalNetworkEvent("S1VL2_TWT_BREAKER", false),
new RemovalNetworkEvent("S1VL2_BBS1_VSC1_DISCONNECTOR", false),
Expand Down Expand Up @@ -128,6 +131,10 @@ void testNodeBreakerToBusBreaker() {

// check regulating terminal has been correctly updated
assertEquals("S1VL2_0", gh1.getRegulatingTerminal().getBusBreakerView().getBus().getId());

// check busbar sections have been removed
assertNull(network.getBusbarSection("S1VL2_BBS1"));
assertNull(network.getBusbarSection("S1VL2_BBS2"));
}

@Test
Expand All @@ -143,7 +150,7 @@ void testNodeBreakerToBusBreakerOneElementDisconnected() {
assertEquals(List.of("S1VL2_BBS2", "VSC1", "LD2", "LD3", "LD4", "LCC1"), busesNbModel.get(1).getConnectedTerminalStream().map(t -> t.getConnectable().getId()).toList());
assertEquals(List.of("GH2"), busesNbModel.get(2).getConnectedTerminalStream().map(t -> t.getConnectable().getId()).toList());
vl.convertToTopology(TopologyKind.BUS_BREAKER);
assertEquals(65, eventRecorder.getEvents().size());
assertEquals(69, eventRecorder.getEvents().size());

var busesBbModel = vl.getBusBreakerView().getBusStream().toList();
assertEquals(3, busesBbModel.size());
Expand Down

0 comments on commit 11b9ea1

Please sign in to comment.