Skip to content

Commit ca84d42

Browse files
committed
add TU
1 parent efc0ece commit ca84d42

File tree

3 files changed

+424
-209
lines changed

3 files changed

+424
-209
lines changed

src/main/java/org/gridsuite/network/map/dto/definition/extension/BusbarSectionFinderTraverser.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,27 +55,23 @@ private static BusbarResult selectBestBusbar(List<BusbarResult> results) {
5555
// Priority 1: Search for busbar with closed last switch
5656
List<BusbarResult> withClosedSwitch = results.stream().filter(r -> r.lastSwitch() != null && !r.lastSwitch().isOpen()).toList();
5757
if (!withClosedSwitch.isEmpty()) {
58-
BusbarResult best = withClosedSwitch.stream().min(Comparator.comparingInt(BusbarResult::depth)
58+
return withClosedSwitch.stream().min(Comparator.comparingInt(BusbarResult::depth)
5959
.thenComparingInt(BusbarResult::switchesBeforeLast))
6060
.get();
61-
return best;
6261
}
6362

6463
// Priority 2: Search for busbar with open last switch
6564
List<BusbarResult> withOpenSwitch = results.stream().filter(r -> r.lastSwitch() != null && r.lastSwitch().isOpen()).toList();
6665
if (!withOpenSwitch.isEmpty()) {
67-
BusbarResult best = withOpenSwitch.stream().min(Comparator.comparingInt(BusbarResult::depth)
66+
return withOpenSwitch.stream().min(Comparator.comparingInt(BusbarResult::depth)
6867
.thenComparingInt(BusbarResult::switchesBeforeLast))
6968
.get();
70-
71-
return best;
7269
}
7370

7471
// Priority 3: Busbars without switch (direct connection)
7572
List<BusbarResult> withoutSwitch = results.stream().filter(r -> r.lastSwitch() == null).toList();
7673
if (!withoutSwitch.isEmpty()) {
77-
BusbarResult best = withoutSwitch.stream().min(Comparator.comparingInt(BusbarResult::depth)).get();
78-
return best;
74+
return withoutSwitch.stream().min(Comparator.comparingInt(BusbarResult::depth)).get();
7975
}
8076

8177
// Fallback: select first busbar
@@ -111,7 +107,7 @@ private static List<BusbarResult> searchAllBusbars(VoltageLevel.NodeBreakerView
111107
SwitchInfo lastSwitch = current.lastSwitch();
112108
// Calculate number of switches BEFORE the last one
113109
int switchesBeforeLast = lastSwitch != null ? (depth - 1) : 0;
114-
results.add(new BusbarResult(busbarId, depth, switchesBeforeLast, lastSwitch, null));
110+
results.add(new BusbarResult(busbarId, depth, switchesBeforeLast, lastSwitch));
115111
continue; // Don't explore beyond busbar
116112
}
117113
}
@@ -147,7 +143,7 @@ public record SwitchInfo(String id, SwitchKind kind, boolean isOpen, int node1,
147143
/**
148144
* Record containing the result of a busbar search with selection metadata.
149145
*/
150-
public record BusbarResult(String busbarId, int depth, int switchesBeforeLast, SwitchInfo lastSwitch, String selectionReason) { }
146+
public record BusbarResult(String busbarId, int depth, int switchesBeforeLast, SwitchInfo lastSwitch) { }
151147

152148
/**
153149
* Convenience method to get only the busbar ID.

src/test/java/org/gridsuite/network/map/NetworkMapControllerTest.java

Lines changed: 0 additions & 200 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,206 +1158,6 @@ void setUp() {
11581158
.withDirection(ConnectablePosition.Direction.TOP).add()
11591159
.add();
11601160

1161-
/** VLGEN7 - Fork topology
1162-
*
1163-
* BUS1 ═══════X════════ BUS2 ═══════════════/════ BUS3
1164-
* (node0) (node5) (node7)
1165-
* | | |
1166-
* Disconnector1 Disconnector2 |
1167-
* | | |
1168-
* | | Disconnector3
1169-
* [open = true] [open = false] [open = false]
1170-
* | | |
1171-
* |____________________| ═══════════/════════ BUS4
1172-
* | |
1173-
* | |
1174-
* fork point Disconnector4
1175-
* (node8) [open = false]
1176-
* | |
1177-
* ┌───┴───┐ LINE9
1178-
* | | (→VLGEN9)
1179-
* LINE7 LINE8
1180-
* (→VLGEN4) (→VLGEN8)
1181-
*/
1182-
1183-
VoltageLevel vlgen7 = network.newVoltageLevel()
1184-
.setId("VLGEN7")
1185-
.setName("Fork Distribution Point")
1186-
.setNominalV(24.0)
1187-
.setHighVoltageLimit(30.0)
1188-
.setLowVoltageLimit(20.0)
1189-
.setTopologyKind(TopologyKind.NODE_BREAKER)
1190-
.add();
1191-
1192-
// Create busbarSections
1193-
vlgen7.getNodeBreakerView().newBusbarSection()
1194-
.setId("BUS1_NGEN7")
1195-
.setName("Primary Busbar VLGEN7")
1196-
.setNode(0)
1197-
.add();
1198-
1199-
vlgen7.getNodeBreakerView().newBusbarSection()
1200-
.setId("BUS2_NGEN7")
1201-
.setName("Secondary Busbar VLGEN7")
1202-
.setNode(5)
1203-
.add();
1204-
1205-
vlgen7.getNodeBreakerView().newBusbarSection()
1206-
.setId("BUS3_NGEN7")
1207-
.setName("Third Busbar VLGEN7")
1208-
.setNode(9)
1209-
.add();
1210-
vlgen7.getNodeBreakerView().newBusbarSection()
1211-
.setId("BUS4_NGEN7")
1212-
.setName("Fourth Busbar VLGEN7")
1213-
.setNode(13)
1214-
.add();
1215-
1216-
createSwitch(vlgen7, "SECT_BUS1", SwitchKind.DISCONNECTOR, true, 0, 6); // OPEN
1217-
createSwitch(vlgen7, "SECT_BUS2", SwitchKind.DISCONNECTOR, false, 5, 7); // CLOSED
1218-
createSwitch(vlgen7, "SECT_BUS3", SwitchKind.DISCONNECTOR, false, 9, 10); // CLOSED
1219-
createSwitch(vlgen7, "SECT_BUS4", SwitchKind.DISCONNECTOR, false, 13, 14); // CLOSED
1220-
1221-
createSwitch(vlgen7, "FORK_SW1", SwitchKind.DISCONNECTOR, false, 6, 8); // BUS1 to fork (CLOSED via node 6)
1222-
createSwitch(vlgen7, "FORK_SW2", SwitchKind.DISCONNECTOR, false, 7, 8); // BUS2 to fork (CLOSED via node 7)
1223-
1224-
// LINE7 connection from fork
1225-
createSwitch(vlgen7, "DISC_LINE7", SwitchKind.DISCONNECTOR, false, 8, 1);
1226-
createSwitch(vlgen7, "BRKR_LINE7", SwitchKind.BREAKER, false, 1, 2);
1227-
1228-
// LINE8 connection from fork
1229-
createSwitch(vlgen7, "DISC_LINE8", SwitchKind.DISCONNECTOR, false, 8, 3);
1230-
createSwitch(vlgen7, "BRKR_LINE8", SwitchKind.BREAKER, false, 3, 4);
1231-
1232-
// LINE9 connection from BUS4 (Fixed connection point)
1233-
createSwitch(vlgen7, "DISC_LINE9", SwitchKind.DISCONNECTOR, false, 14, 12); // Connect from node 14
1234-
createSwitch(vlgen7, "BRKR_LINE9", SwitchKind.BREAKER, false, 12, 11);
1235-
1236-
// Assuming VLGEN4 exists, create its switches
1237-
createSwitch(vlgen4, "DISC_VLGEN4", SwitchKind.DISCONNECTOR, false, 0, 10);
1238-
createSwitch(vlgen4, "BRKR_VLGEN4", SwitchKind.BREAKER, false, 10, 15);
1239-
1240-
// LINE7 - Fork Branch 1
1241-
network.newLine()
1242-
.setId("LINE7_FORK")
1243-
.setName("Fork Branch 1 - Primary Line")
1244-
.setVoltageLevel1("VLGEN4")
1245-
.setNode1(15) // Fixed node reference
1246-
.setVoltageLevel2("VLGEN7")
1247-
.setNode2(2)
1248-
.setR(3.0)
1249-
.setX(33.0)
1250-
.setG1(0.0)
1251-
.setB1(386E-6 / 2)
1252-
.setG2(0.0)
1253-
.setB2(386E-6 / 2)
1254-
.add();
1255-
1256-
Line line7 = network.getLine("LINE7_FORK");
1257-
line7.newExtension(ConnectablePositionAdder.class)
1258-
.newFeeder1()
1259-
.withName("LINE7_VLGEN4_Side")
1260-
.withOrder(5)
1261-
.withDirection(ConnectablePosition.Direction.BOTTOM)
1262-
.add()
1263-
.newFeeder2()
1264-
.withName("LINE7_VLGEN7_Fork_Side")
1265-
.withOrder(1)
1266-
.withDirection(ConnectablePosition.Direction.TOP)
1267-
.add()
1268-
.add();
1269-
1270-
// VLGEN8 - Fork destination 2
1271-
VoltageLevel vlgen8 = network.newVoltageLevel()
1272-
.setId("VLGEN8")
1273-
.setName("Fork Destination Point 2")
1274-
.setNominalV(24.0)
1275-
.setHighVoltageLimit(30.0)
1276-
.setLowVoltageLimit(20.0)
1277-
.setTopologyKind(TopologyKind.NODE_BREAKER)
1278-
.add();
1279-
createSwitch(vlgen8, "DISC_VLGEN8", SwitchKind.DISCONNECTOR, false, 0, 1);
1280-
createSwitch(vlgen8, "BRKR_VLGEN8", SwitchKind.BREAKER, false, 1, 2);
1281-
1282-
// LINE8 - Fork Branch 2
1283-
network.newLine()
1284-
.setId("LINE8_FORK")
1285-
.setName("Fork Branch 2 - Secondary Line")
1286-
.setVoltageLevel1("VLGEN7")
1287-
.setNode1(4)
1288-
.setVoltageLevel2("VLGEN8")
1289-
.setNode2(2)
1290-
.setR(2.5)
1291-
.setX(28.0)
1292-
.setG1(0.0)
1293-
.setB1(320E-6 / 2)
1294-
.setG2(0.0)
1295-
.setB2(320E-6 / 2)
1296-
.add();
1297-
Line line8 = network.getLine("LINE8_FORK");
1298-
line8.newExtension(ConnectablePositionAdder.class)
1299-
.newFeeder1()
1300-
.withName("LINE8_VLGEN7_Fork_Side")
1301-
.withOrder(2)
1302-
.withDirection(ConnectablePosition.Direction.BOTTOM)
1303-
.add()
1304-
.newFeeder2()
1305-
.withName("LINE8_VLGEN8_Side")
1306-
.withOrder(1)
1307-
.withDirection(ConnectablePosition.Direction.TOP)
1308-
.add()
1309-
.add();
1310-
1311-
// VLGEN9 - Independent line destination
1312-
VoltageLevel vlgen9 = network.newVoltageLevel()
1313-
.setId("VLGEN9")
1314-
.setName("Independent Line Destination")
1315-
.setNominalV(24.0)
1316-
.setHighVoltageLimit(30.0)
1317-
.setLowVoltageLimit(20.0)
1318-
.setTopologyKind(TopologyKind.NODE_BREAKER)
1319-
.add();
1320-
1321-
vlgen9.getNodeBreakerView().newBusbarSection()
1322-
.setId("BUS_NGEN9")
1323-
.setName("Main Busbar VLGEN9")
1324-
.setNode(0)
1325-
.add();
1326-
1327-
createSwitch(vlgen9, "DISC_VLGEN9", SwitchKind.DISCONNECTOR, false, 0, 1);
1328-
createSwitch(vlgen9, "BRKR_VLGEN9", SwitchKind.BREAKER, false, 1, 2);
1329-
1330-
// LINE9 - Independent line from BUS4
1331-
network.newLine()
1332-
.setId("LINE9_INDEPENDENT")
1333-
.setName("Independent Line from BUS4")
1334-
.setVoltageLevel1("VLGEN7")
1335-
.setNode1(11)
1336-
.setVoltageLevel2("VLGEN9")
1337-
.setNode2(2)
1338-
.setR(2.0)
1339-
.setX(25.0)
1340-
.setG1(0.0)
1341-
.setB1(300E-6 / 2)
1342-
.setG2(0.0)
1343-
.setB2(300E-6 / 2)
1344-
.add();
1345-
Line line9 = network.getLine("LINE9_INDEPENDENT");
1346-
line9.newExtension(ConnectablePositionAdder.class)
1347-
.newFeeder1()
1348-
.withName("LINE9_VLGEN7_Side")
1349-
.withOrder(3)
1350-
.withDirection(ConnectablePosition.Direction.BOTTOM)
1351-
.add()
1352-
.newFeeder2()
1353-
.withName("LINE9_VLGEN9_Side")
1354-
.withOrder(1)
1355-
.withDirection(ConnectablePosition.Direction.BOTTOM)
1356-
.add()
1357-
.add();
1358-
1359-
network.getVariantManager().setWorkingVariant(VariantManagerConstants.INITIAL_VARIANT_ID);
1360-
13611161
// Add new variant 2
13621162
network.getVariantManager().cloneVariant(VariantManagerConstants.INITIAL_VARIANT_ID, VARIANT_ID_2);
13631163
network.getVariantManager().setWorkingVariant(VARIANT_ID_2);

0 commit comments

Comments
 (0)