From f2f692722b5deb378b976e53148fafe6dd1da59c Mon Sep 17 00:00:00 2001 From: Nicolas Rol Date: Tue, 24 Sep 2024 14:09:26 +0200 Subject: [PATCH 01/19] add exception on Three Windings Transformers and Dangling Lines Signed-off-by: Nicolas Rol --- .../metrix/integration/dataGenerator/MetrixInputData.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/metrix-integration/src/main/java/com/powsybl/metrix/integration/dataGenerator/MetrixInputData.java b/metrix-integration/src/main/java/com/powsybl/metrix/integration/dataGenerator/MetrixInputData.java index dc993306..f60e58ca 100755 --- a/metrix-integration/src/main/java/com/powsybl/metrix/integration/dataGenerator/MetrixInputData.java +++ b/metrix-integration/src/main/java/com/powsybl/metrix/integration/dataGenerator/MetrixInputData.java @@ -391,7 +391,12 @@ private void writeBranches(boolean constantLossFactor, MetrixDie die) { // Three Windings Transformers metrixNetwork.getThreeWindingsTransformerList().forEach(twt -> { - throw new UnsupportedOperationException("TODO"); + throw new PowsyblException("Three Windings Transformers are not yet supported in metrix"); + }); + + // Dangling lines + metrixNetwork.getDanglingLineList().forEach(line -> { + throw new PowsyblException("Dangling lines are not yet supported in metrix"); }); // Switches From ac3a84c2c11bb8da3a2fb199fcf94da1046724f3 Mon Sep 17 00:00:00 2001 From: Nicolas Rol Date: Wed, 25 Sep 2024 11:21:13 +0200 Subject: [PATCH 02/19] remove dangling lines from branches (already managed as loads) + rewrite addElementToRetainedBreakersList to manage switches from BUS_BREAKER voltage levels + remove exception + add TODO on T3T Signed-off-by: Nicolas Rol --- .../metrix/integration/MetrixNetwork.java | 78 +++++++++++++------ .../dataGenerator/MetrixInputData.java | 9 +-- .../metrix/integration/MetrixNetworkTest.java | 4 +- .../metrix/mapping/SimpleMappingData.groovy | 4 - 4 files changed, 61 insertions(+), 34 deletions(-) diff --git a/metrix-integration/src/main/java/com/powsybl/metrix/integration/MetrixNetwork.java b/metrix-integration/src/main/java/com/powsybl/metrix/integration/MetrixNetwork.java index 9cc86815..eb14adf3 100755 --- a/metrix-integration/src/main/java/com/powsybl/metrix/integration/MetrixNetwork.java +++ b/metrix-integration/src/main/java/com/powsybl/metrix/integration/MetrixNetwork.java @@ -68,6 +68,7 @@ public class MetrixNetwork { private final Map mappedSwitchMap = new HashMap<>(); protected MetrixNetwork(Network network) { + // TODO: switch T3T for 3xTWT in the network using a network modification this.network = Objects.requireNonNull(network); } @@ -612,35 +613,66 @@ private void createRetainedBreakersList(Set breakerList) { private void addElementToRetainedBreakersList(Switch sw) { String switchId = sw.getId(); - VoltageLevel.NodeBreakerView nodeBreakerView = sw.getVoltageLevel().getNodeBreakerView(); - Terminal terminal1 = nodeBreakerView.getTerminal1(switchId); - Terminal terminal2 = nodeBreakerView.getTerminal2(switchId); + VoltageLevel voltageLevel = sw.getVoltageLevel(); - if (terminal1 == null || terminal1.getConnectable().getType() == IdentifiableType.BUSBAR_SECTION) { - terminal1 = terminal2; + if (voltageLevel.getTopologyKind() == TopologyKind.NODE_BREAKER) { + // Get the terminals on both sides of the switch + VoltageLevel.NodeBreakerView nodeBreakerView = voltageLevel.getNodeBreakerView(); + Terminal terminal1 = nodeBreakerView.getTerminal1(switchId); + Terminal terminal2 = nodeBreakerView.getTerminal2(switchId); + + // Check on both sides of the switch to find a connectable that is not another switch nor a bus bar section + if (isSwitchNotConnectedToOtherSwitchOrBbs(terminal1)) { + addElementToRetainedBreakersList(sw, terminal1, true); + } else if (isSwitchNotConnectedToOtherSwitchOrBbs(terminal2)) { + addElementToRetainedBreakersList(sw, terminal2, true); + } else { + // Both sides have either a switch or a bus bar section : the switch is registered by itself + addElementToRetainedBreakersList(sw, switchId, true); + } + } else if (voltageLevel.getTopologyKind() == TopologyKind.BUS_BREAKER) { + // Get the terminals on both sides of the switch + VoltageLevel.BusBreakerView busBreakerView = voltageLevel.getBusBreakerView(); + List terminalsBus1 = busBreakerView.getBus1(switchId).getConnectedTerminalStream().toList(); + List terminalsBus2 = busBreakerView.getBus2(switchId).getConnectedTerminalStream().toList(); + + // Check on both sides of the switch to check if there is one and only one connectable + if (terminalsBus1.size() == 1) { + addElementToRetainedBreakersList(sw, terminalsBus1.get(0), false); + } else if (terminalsBus2.size() == 1) { + addElementToRetainedBreakersList(sw, terminalsBus2.get(0), false); + } else { + addElementToRetainedBreakersList(sw, switchId, false); + } } + } - if (terminal1 == null || terminal1.getConnectable().getType() == IdentifiableType.BUSBAR_SECTION) { - sw.setRetained(true); - mappedSwitchMap.put(switchId, switchId); - } else { - switch (terminal1.getConnectable().getType()) { - case LINE, TWO_WINDINGS_TRANSFORMER -> { - sw.setRetained(true); - mappedSwitchMap.put(switchId, terminal1.getConnectable().getId()); - } - case LOAD, GENERATOR -> { - sw.setRetained(true); - mappedSwitchMap.put(switchId, switchId); - } - case DANGLING_LINE, HVDC_CONVERTER_STATION, SHUNT_COMPENSATOR, STATIC_VAR_COMPENSATOR, THREE_WINDINGS_TRANSFORMER -> { - if (LOGGER.isWarnEnabled()) { - LOGGER.warn(String.format("Unsupported connectable type (%s) for switch '%s'", terminal1.getConnectable().getType(), switchId)); - } + private boolean isSwitchNotConnectedToOtherSwitchOrBbs(Terminal terminal) { + return terminal != null && terminal.getConnectable().getType() != IdentifiableType.BUSBAR_SECTION; + } + + private void addElementToRetainedBreakersList(Switch sw, Terminal terminal, boolean setRetained) { + String switchId = sw.getId(); + switch (terminal.getConnectable().getType()) { + // Since switches connected to lines and TWT are "replaced" by those connectables, no need to set them retained + case LINE, TWO_WINDINGS_TRANSFORMER -> addElementToRetainedBreakersList(sw, terminal.getConnectable().getId(), false); + case LOAD, GENERATOR -> addElementToRetainedBreakersList(sw, switchId, setRetained); + case DANGLING_LINE, HVDC_CONVERTER_STATION, SHUNT_COMPENSATOR, STATIC_VAR_COMPENSATOR, + THREE_WINDINGS_TRANSFORMER -> { + if (LOGGER.isWarnEnabled()) { + LOGGER.warn("Unsupported connectable type ({}) for switch '{}'", terminal.getConnectable().getType(), switchId); } - default -> throw new PowsyblException("Unexpected connectable type : " + terminal1.getConnectable().getType()); } + default -> + throw new PowsyblException("Unexpected connectable type : " + terminal.getConnectable().getType()); + } + } + + private void addElementToRetainedBreakersList(Switch sw, String id, boolean setRetained) { + if (setRetained) { + sw.setRetained(true); } + mappedSwitchMap.put(sw.getId(), id); } private void createOpenedBranchesList(Set openedBranches) { diff --git a/metrix-integration/src/main/java/com/powsybl/metrix/integration/dataGenerator/MetrixInputData.java b/metrix-integration/src/main/java/com/powsybl/metrix/integration/dataGenerator/MetrixInputData.java index f60e58ca..33dc4d57 100755 --- a/metrix-integration/src/main/java/com/powsybl/metrix/integration/dataGenerator/MetrixInputData.java +++ b/metrix-integration/src/main/java/com/powsybl/metrix/integration/dataGenerator/MetrixInputData.java @@ -184,9 +184,11 @@ private void createMetrixInputs() { trnbgrou = metrixNetwork.getGeneratorList().size(); - cqnbquad = metrixNetwork.getLineList().size() + metrixNetwork.getTwoWindingsTransformerList().size() + 3 * metrixNetwork.getThreeWindingsTransformerList().size() + metrixNetwork.getDanglingLineList().size() + metrixNetwork.getSwitchList().size(); + // Quadripoles are lines, transformers and switches + cqnbquad = metrixNetwork.getLineList().size() + metrixNetwork.getTwoWindingsTransformerList().size() + 3 * metrixNetwork.getThreeWindingsTransformerList().size() + metrixNetwork.getSwitchList().size(); dtnbtrde = metrixNetwork.getPhaseTapChangerList().size(); + // Loads are loads and dangling lines ecnbcons = metrixNetwork.getLoadList().size() + metrixNetwork.getDanglingLineList().size(); dcnblies = metrixNetwork.getHvdcLineList().size(); @@ -394,11 +396,6 @@ private void writeBranches(boolean constantLossFactor, MetrixDie die) { throw new PowsyblException("Three Windings Transformers are not yet supported in metrix"); }); - // Dangling lines - metrixNetwork.getDanglingLineList().forEach(line -> { - throw new PowsyblException("Dangling lines are not yet supported in metrix"); - }); - // Switches metrixNetwork.getSwitchList().forEach(sw -> writeSwitch(sw, metrixInputBranch)); diff --git a/metrix-integration/src/test/java/com/powsybl/metrix/integration/MetrixNetworkTest.java b/metrix-integration/src/test/java/com/powsybl/metrix/integration/MetrixNetworkTest.java index 4320e23f..644c5e27 100644 --- a/metrix-integration/src/test/java/com/powsybl/metrix/integration/MetrixNetworkTest.java +++ b/metrix-integration/src/test/java/com/powsybl/metrix/integration/MetrixNetworkTest.java @@ -45,7 +45,9 @@ void testNetworkElementsLists() { // Set some switches as retained Set mappedSwitches = Set.of("S1VL2_GH2_BREAKER", "S3VL1_LINES3S4_BREAKER", "S1VL1_LD1_BREAKER"); - List switchList = mappedSwitches.stream() + + // Expected switch list in MetrixNetwork: switches next to branches (lines, two windings transformers) are not present + List switchList = Set.of("S1VL2_GH2_BREAKER", "S1VL1_LD1_BREAKER").stream() .map(network::getSwitch).toList(); // Contingencies diff --git a/metrix-mapping/src/main/groovy/com/powsybl/metrix/mapping/SimpleMappingData.groovy b/metrix-mapping/src/main/groovy/com/powsybl/metrix/mapping/SimpleMappingData.groovy index 9308e8ba..81c8b70c 100644 --- a/metrix-mapping/src/main/groovy/com/powsybl/metrix/mapping/SimpleMappingData.groovy +++ b/metrix-mapping/src/main/groovy/com/powsybl/metrix/mapping/SimpleMappingData.groovy @@ -42,10 +42,6 @@ class SimpleMappingData extends FilteredData { // for each filtered equipment, compute the distribution key and add it to the config if (!filteredEquipments.isEmpty()) { - if (((Switch) filteredEquipments[0]).voltageLevel.topologyKind == TopologyKind.BUS_BREAKER) { - throw new TimeSeriesMappingException("Bus breaker topology not supported for switch mapping") - } - filteredEquipments.forEach({ Identifiable identifiable -> configLoader.addEquipmentMapping(breakerType, spec.timeSeriesName, identifiable.id, NumberDistributionKey.ONE, EquipmentVariable.OPEN) }) From faa9170c9a55da83636fbf1ee992ef010f068311 Mon Sep 17 00:00:00 2001 From: Nicolas Rol Date: Wed, 25 Sep 2024 14:04:35 +0200 Subject: [PATCH 03/19] test exception on T3T Signed-off-by: Nicolas Rol --- .../powsybl/metrix/integration/MetrixInputTest.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/metrix-integration/src/test/java/com/powsybl/metrix/integration/MetrixInputTest.java b/metrix-integration/src/test/java/com/powsybl/metrix/integration/MetrixInputTest.java index 09ec99b0..9f4e833d 100755 --- a/metrix-integration/src/test/java/com/powsybl/metrix/integration/MetrixInputTest.java +++ b/metrix-integration/src/test/java/com/powsybl/metrix/integration/MetrixInputTest.java @@ -14,8 +14,10 @@ import com.google.common.collect.Range; import com.google.common.jimfs.Configuration; import com.google.common.jimfs.Jimfs; +import com.powsybl.commons.PowsyblException; import com.powsybl.contingency.*; import com.powsybl.iidm.network.*; +import com.powsybl.iidm.network.test.ThreeWindingsTransformerNetworkFactory; import com.powsybl.iidm.serde.NetworkSerDe; import com.powsybl.metrix.integration.dataGenerator.MetrixInputData; import com.powsybl.metrix.integration.metrix.MetrixChunkParam; @@ -156,6 +158,17 @@ void metrixDefaultInputTest() throws IOException { new ByteArrayInputStream(actual.getBytes(StandardCharsets.UTF_8)))); } + @Test + void metrixInputDataWithT3TTest() throws IOException { + Network n = ThreeWindingsTransformerNetworkFactory.create(); + MetrixInputData metrixInputData = new MetrixInputData(MetrixNetwork.create(n), null, new MetrixParameters()); + try (StringWriter writer = new StringWriter()) { + assertThrows(PowsyblException.class, + () -> metrixInputData.writeJson(writer), + "Three Windings Transformers are not yet supported in metrix"); + } + } + @Test void metrixInputTest() throws IOException { Network n = NetworkSerDe.read(getClass().getResourceAsStream("/simpleNetwork.xml")); From e10a1da94e9f958ee7768ac21b1028f41e0c3036 Mon Sep 17 00:00:00 2001 From: Nicolas Rol Date: Wed, 25 Sep 2024 14:45:55 +0200 Subject: [PATCH 04/19] add test on MetrixNetwork Signed-off-by: Nicolas Rol --- .../metrix/integration/MetrixNetworkTest.java | 81 ++++++++++++++++++- 1 file changed, 77 insertions(+), 4 deletions(-) diff --git a/metrix-integration/src/test/java/com/powsybl/metrix/integration/MetrixNetworkTest.java b/metrix-integration/src/test/java/com/powsybl/metrix/integration/MetrixNetworkTest.java index 644c5e27..448b7b5a 100644 --- a/metrix-integration/src/test/java/com/powsybl/metrix/integration/MetrixNetworkTest.java +++ b/metrix-integration/src/test/java/com/powsybl/metrix/integration/MetrixNetworkTest.java @@ -7,6 +7,8 @@ import com.powsybl.contingency.Contingency; import com.powsybl.iidm.network.*; import com.powsybl.iidm.network.test.FourSubstationsNodeBreakerFactory; +import com.powsybl.iidm.serde.ExportOptions; +import com.powsybl.iidm.serde.NetworkSerDe; import com.powsybl.metrix.integration.contingency.Probability; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; @@ -44,10 +46,11 @@ void testNetworkElementsLists() { Network network = createNetwork(); // Set some switches as retained - Set mappedSwitches = Set.of("S1VL2_GH2_BREAKER", "S3VL1_LINES3S4_BREAKER", "S1VL1_LD1_BREAKER"); + Set mappedSwitches = Set.of("S1VL2_GH2_BREAKER", "S3VL1_LINES3S4_BREAKER", "S1VL1_LD1_BREAKER", "S1VL3_DL_BREAKER", "S1VL2_BBS1_BBS3"); // Expected switch list in MetrixNetwork: switches next to branches (lines, two windings transformers) are not present - List switchList = Set.of("S1VL2_GH2_BREAKER", "S1VL1_LD1_BREAKER").stream() + List switchList = Set.of("S1VL2_GH2_BREAKER", "S1VL1_LD1_BREAKER", "S1VL3_DL_BREAKER", "S1VL2_BBS1_BBS3") + .stream() .map(network::getSwitch).toList(); // Contingencies @@ -81,11 +84,71 @@ void testNetworkElementsLists() { assertThat(metrixNetwork.getContingencyList()).containsExactlyInAnyOrderElementsOf(List.of(a, b)); } + @Test + void testNetworkBusBreakerElementsLists() { + // Mapped switches + Set mappedSwitches = Set.of("S1VL2_GH2_BREAKER", "S3VL1_LINES3S4_BREAKER", "S1VL1_LD1_BREAKER", + "S1VL3_DL_BREAKER", "S1VL2_BBS1_BBS3", "S1VL3_3WT_BREAKER"); + + // Network + Network network = createBusBreakerNetwork(mappedSwitches); + + // Set some switches as retained + + // Expected switch list in MetrixNetwork: switches next to branches (lines, two windings transformers) are not present + List switchList = mappedSwitches.stream().map(network::getSwitch).toList(); + + // Contingencies + Contingency a = new Contingency("a", Collections.singletonList(new BranchContingency("LINE_S2S3"))); + Contingency b = new Contingency("b", Arrays.asList( + new BranchContingency("LINE_S2S3"), + new BranchContingency("LINE_S3S4"))); + + // Create a contingency provider + ContingenciesProvider contingenciesProvider = networkLocal -> { + a.addExtension(Probability.class, new Probability(0.002d, null)); + b.addExtension(Probability.class, new Probability(null, "variable_ts1")); + return Arrays.asList(a, b); + }; + + // Initialize the MetrixNetwork + MetrixNetwork metrixNetwork = MetrixNetwork.create(network, contingenciesProvider, mappedSwitches, new MetrixParameters(), (Path) null); + + // Check the lists + assertThat(metrixNetwork.getCountryList()).containsExactlyInAnyOrderElementsOf(Collections.singletonList("Undefined")); + assertThat(metrixNetwork.getLoadList()).containsExactlyInAnyOrderElementsOf(network.getLoads()); + assertThat(metrixNetwork.getGeneratorList()).containsExactlyInAnyOrderElementsOf(network.getGenerators()); + assertThat(metrixNetwork.getGeneratorTypeList()).containsExactlyInAnyOrderElementsOf(List.of("HYDRO", "THERMAL")); + assertThat(metrixNetwork.getLineList()).containsExactlyInAnyOrderElementsOf(network.getLines()); + assertThat(metrixNetwork.getTwoWindingsTransformerList()).containsExactlyInAnyOrderElementsOf(network.getTwoWindingsTransformers()); + assertThat(metrixNetwork.getThreeWindingsTransformerList()).containsExactlyInAnyOrderElementsOf(network.getThreeWindingsTransformers()); + assertThat(metrixNetwork.getDanglingLineList()).containsExactlyInAnyOrderElementsOf(network.getDanglingLines()); + assertThat(metrixNetwork.getSwitchList()).containsExactlyInAnyOrderElementsOf(switchList); + assertThat(metrixNetwork.getHvdcLineList()).containsExactlyInAnyOrderElementsOf(network.getHvdcLines()); + assertThat(metrixNetwork.getBusList()).containsExactlyInAnyOrderElementsOf(network.getBusBreakerView().getBuses()); + assertThat(metrixNetwork.getContingencyList()).containsExactlyInAnyOrderElementsOf(List.of(a, b)); + } + + private Network createBusBreakerNetwork(Set mappedSwitches) { + // Initial network + Network network = createNetwork(); + + // Set some switches as retained + List retainedSwitches = mappedSwitches.stream().map(network::getSwitch).toList(); + network.getSwitchStream() + .forEach(sw -> sw.setRetained(retainedSwitches.contains(sw))); + + // Export the network as BusBreaker + Path exportedFile = fileSystem.getPath("./network.xiidm"); + NetworkSerDe.write(network, new ExportOptions().setTopologyLevel(TopologyLevel.BUS_BREAKER), exportedFile); + return NetworkSerDe.read(exportedFile); + } + private Network createNetwork() { // Initial network Network network = FourSubstationsNodeBreakerFactory.create(); - // We add a substation, a ThreeWindingsTransformer and a DanglingLine + // We add a voltage level, a ThreeWindingsTransformer and a DanglingLine VoltageLevel s1vl3 = network.getSubstation("S1").newVoltageLevel() .setId("S1VL3") .setNominalV(225.0) @@ -139,7 +202,7 @@ private Network createNetwork() { // Dangling line createSwitch(s1vl3, "S1VL3_BBS_DL_DISCONNECTOR", SwitchKind.DISCONNECTOR, 0, 3); - createSwitch(s1vl3, "S1VL3_DL_BREAKER", SwitchKind.BREAKER, 3, 4); + createSwitch(s1vl3, "S1VL3_DL_BREAKER", SwitchKind.BREAKER, 4, 3); s1vl3.newDanglingLine() .setId("DL") .setR(10.0) @@ -151,6 +214,16 @@ private Network createNetwork() { .setNode(4) .add(); + // We add another bus bar section and link it to the others with a breaker + network.getVoltageLevel("S1VL2").getNodeBreakerView().newBusbarSection() + .setId("S1VL2_BBS3") + .setName("S1VL2_BBS3") + .setNode(90) + .add(); + createSwitch(network.getVoltageLevel("S1VL2"), "S1VL2_BBS1_DISCONNECTOR", SwitchKind.DISCONNECTOR, 0, 91); + createSwitch(network.getVoltageLevel("S1VL2"), "S1VL2_BBS3_DISCONNECTOR", SwitchKind.DISCONNECTOR, 92, 90); + createSwitch(network.getVoltageLevel("S1VL2"), "S1VL2_BBS1_BBS3", SwitchKind.BREAKER, 91, 92); + return network; } From 332dbd34c23276ff4f6972bb5f8a59b874db4edc Mon Sep 17 00:00:00 2001 From: Nicolas Rol Date: Wed, 25 Sep 2024 14:46:44 +0200 Subject: [PATCH 05/19] switch next to dangling lines should be managed as those next to loads Signed-off-by: Nicolas Rol --- .../com/powsybl/metrix/integration/MetrixNetwork.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/metrix-integration/src/main/java/com/powsybl/metrix/integration/MetrixNetwork.java b/metrix-integration/src/main/java/com/powsybl/metrix/integration/MetrixNetwork.java index eb14adf3..1f0ccc10 100755 --- a/metrix-integration/src/main/java/com/powsybl/metrix/integration/MetrixNetwork.java +++ b/metrix-integration/src/main/java/com/powsybl/metrix/integration/MetrixNetwork.java @@ -145,7 +145,7 @@ private MetrixSubset getMetrixSubset(Identifiable identifiable) { subset = MetrixSubset.NOEUD; } else if (identifiable instanceof HvdcLine) { subset = MetrixSubset.HVDC; - } else if (identifiable instanceof Load) { + } else if (identifiable instanceof Load || identifiable instanceof DanglingLine) { subset = MetrixSubset.LOAD; } return subset; @@ -219,7 +219,7 @@ private void addThreeWindingsTransformer(ThreeWindingsTransformer twt) { private void addDanglingLine(DanglingLine dl) { if (danglingLineList.add(dl)) { - mapper.newInt(MetrixSubset.QUAD, dl.getId()); + mapper.newInt(MetrixSubset.LOAD, dl.getId()); } } @@ -656,8 +656,8 @@ private void addElementToRetainedBreakersList(Switch sw, Terminal terminal, bool switch (terminal.getConnectable().getType()) { // Since switches connected to lines and TWT are "replaced" by those connectables, no need to set them retained case LINE, TWO_WINDINGS_TRANSFORMER -> addElementToRetainedBreakersList(sw, terminal.getConnectable().getId(), false); - case LOAD, GENERATOR -> addElementToRetainedBreakersList(sw, switchId, setRetained); - case DANGLING_LINE, HVDC_CONVERTER_STATION, SHUNT_COMPENSATOR, STATIC_VAR_COMPENSATOR, + case LOAD, GENERATOR, DANGLING_LINE -> addElementToRetainedBreakersList(sw, switchId, setRetained); + case HVDC_CONVERTER_STATION, SHUNT_COMPENSATOR, STATIC_VAR_COMPENSATOR, THREE_WINDINGS_TRANSFORMER -> { if (LOGGER.isWarnEnabled()) { LOGGER.warn("Unsupported connectable type ({}) for switch '{}'", terminal.getConnectable().getType(), switchId); From 0a736851f4ba8bd072ee88411ecb30064102046d Mon Sep 17 00:00:00 2001 From: Nicolas Rol Date: Wed, 25 Sep 2024 15:11:11 +0200 Subject: [PATCH 06/19] add more test for coverage Signed-off-by: Nicolas Rol --- .../powsybl/metrix/integration/MetrixNetworkTest.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/metrix-integration/src/test/java/com/powsybl/metrix/integration/MetrixNetworkTest.java b/metrix-integration/src/test/java/com/powsybl/metrix/integration/MetrixNetworkTest.java index 448b7b5a..6a2cb763 100644 --- a/metrix-integration/src/test/java/com/powsybl/metrix/integration/MetrixNetworkTest.java +++ b/metrix-integration/src/test/java/com/powsybl/metrix/integration/MetrixNetworkTest.java @@ -23,6 +23,8 @@ import java.util.Set; import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Nicolas Rol {@literal } @@ -82,6 +84,14 @@ void testNetworkElementsLists() { assertThat(metrixNetwork.getHvdcLineList()).containsExactlyInAnyOrderElementsOf(network.getHvdcLines()); assertThat(metrixNetwork.getBusList()).containsExactlyInAnyOrderElementsOf(network.getBusBreakerView().getBuses()); assertThat(metrixNetwork.getContingencyList()).containsExactlyInAnyOrderElementsOf(List.of(a, b)); + + assertTrue(metrixNetwork.isMapped(network.getIdentifiable("S1VL2_GH2_BREAKER"))); + assertTrue(metrixNetwork.isMapped(network.getIdentifiable("DL"))); + assertTrue(metrixNetwork.isMapped(network.getIdentifiable("GH2"))); + assertTrue(metrixNetwork.isMapped(network.getIdentifiable("HVDC1"))); + assertTrue(metrixNetwork.isMapped(network.getIdentifiable("LINE_S2S3"))); + assertTrue(metrixNetwork.isMapped(network.getIdentifiable("LD5"))); + assertFalse(metrixNetwork.isMapped(network.getIdentifiable("S2VL1_BBS"))); } @Test From e219fc122d4b1eb66587b9408373c8a24e0c4a00 Mon Sep 17 00:00:00 2001 From: Nicolas Rol Date: Wed, 25 Sep 2024 15:13:38 +0200 Subject: [PATCH 07/19] remove useless comment Signed-off-by: Nicolas Rol --- .../java/com/powsybl/metrix/integration/MetrixNetworkTest.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/metrix-integration/src/test/java/com/powsybl/metrix/integration/MetrixNetworkTest.java b/metrix-integration/src/test/java/com/powsybl/metrix/integration/MetrixNetworkTest.java index 6a2cb763..5aaa9f53 100644 --- a/metrix-integration/src/test/java/com/powsybl/metrix/integration/MetrixNetworkTest.java +++ b/metrix-integration/src/test/java/com/powsybl/metrix/integration/MetrixNetworkTest.java @@ -103,8 +103,6 @@ void testNetworkBusBreakerElementsLists() { // Network Network network = createBusBreakerNetwork(mappedSwitches); - // Set some switches as retained - // Expected switch list in MetrixNetwork: switches next to branches (lines, two windings transformers) are not present List switchList = mappedSwitches.stream().map(network::getSwitch).toList(); From ccfa085c921f4beffbcfd7d83bd1996492debf9c Mon Sep 17 00:00:00 2001 From: Nicolas Rol Date: Thu, 26 Sep 2024 09:09:59 +0200 Subject: [PATCH 08/19] revert fixes on dangling line to do it in another PR Signed-off-by: Nicolas Rol --- .../com/powsybl/metrix/integration/MetrixNetwork.java | 8 ++++---- .../com/powsybl/metrix/integration/MetrixNetworkTest.java | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/metrix-integration/src/main/java/com/powsybl/metrix/integration/MetrixNetwork.java b/metrix-integration/src/main/java/com/powsybl/metrix/integration/MetrixNetwork.java index 1f0ccc10..eb14adf3 100755 --- a/metrix-integration/src/main/java/com/powsybl/metrix/integration/MetrixNetwork.java +++ b/metrix-integration/src/main/java/com/powsybl/metrix/integration/MetrixNetwork.java @@ -145,7 +145,7 @@ private MetrixSubset getMetrixSubset(Identifiable identifiable) { subset = MetrixSubset.NOEUD; } else if (identifiable instanceof HvdcLine) { subset = MetrixSubset.HVDC; - } else if (identifiable instanceof Load || identifiable instanceof DanglingLine) { + } else if (identifiable instanceof Load) { subset = MetrixSubset.LOAD; } return subset; @@ -219,7 +219,7 @@ private void addThreeWindingsTransformer(ThreeWindingsTransformer twt) { private void addDanglingLine(DanglingLine dl) { if (danglingLineList.add(dl)) { - mapper.newInt(MetrixSubset.LOAD, dl.getId()); + mapper.newInt(MetrixSubset.QUAD, dl.getId()); } } @@ -656,8 +656,8 @@ private void addElementToRetainedBreakersList(Switch sw, Terminal terminal, bool switch (terminal.getConnectable().getType()) { // Since switches connected to lines and TWT are "replaced" by those connectables, no need to set them retained case LINE, TWO_WINDINGS_TRANSFORMER -> addElementToRetainedBreakersList(sw, terminal.getConnectable().getId(), false); - case LOAD, GENERATOR, DANGLING_LINE -> addElementToRetainedBreakersList(sw, switchId, setRetained); - case HVDC_CONVERTER_STATION, SHUNT_COMPENSATOR, STATIC_VAR_COMPENSATOR, + case LOAD, GENERATOR -> addElementToRetainedBreakersList(sw, switchId, setRetained); + case DANGLING_LINE, HVDC_CONVERTER_STATION, SHUNT_COMPENSATOR, STATIC_VAR_COMPENSATOR, THREE_WINDINGS_TRANSFORMER -> { if (LOGGER.isWarnEnabled()) { LOGGER.warn("Unsupported connectable type ({}) for switch '{}'", terminal.getConnectable().getType(), switchId); diff --git a/metrix-integration/src/test/java/com/powsybl/metrix/integration/MetrixNetworkTest.java b/metrix-integration/src/test/java/com/powsybl/metrix/integration/MetrixNetworkTest.java index 5aaa9f53..07894e44 100644 --- a/metrix-integration/src/test/java/com/powsybl/metrix/integration/MetrixNetworkTest.java +++ b/metrix-integration/src/test/java/com/powsybl/metrix/integration/MetrixNetworkTest.java @@ -51,7 +51,7 @@ void testNetworkElementsLists() { Set mappedSwitches = Set.of("S1VL2_GH2_BREAKER", "S3VL1_LINES3S4_BREAKER", "S1VL1_LD1_BREAKER", "S1VL3_DL_BREAKER", "S1VL2_BBS1_BBS3"); // Expected switch list in MetrixNetwork: switches next to branches (lines, two windings transformers) are not present - List switchList = Set.of("S1VL2_GH2_BREAKER", "S1VL1_LD1_BREAKER", "S1VL3_DL_BREAKER", "S1VL2_BBS1_BBS3") + List switchList = Set.of("S1VL2_GH2_BREAKER", "S1VL1_LD1_BREAKER", "S1VL2_BBS1_BBS3") .stream() .map(network::getSwitch).toList(); From b46a26f9e49a0be851f36ed41805bf73ba2f4230 Mon Sep 17 00:00:00 2001 From: Nicolas Rol Date: Thu, 26 Sep 2024 09:56:43 +0200 Subject: [PATCH 09/19] manage dangling lines and tie lines Signed-off-by: Nicolas Rol --- .../metrix/integration/MetrixNetwork.java | 69 ++++++++++++++++--- .../dataGenerator/MetrixInputData.java | 21 +++++- .../metrix/integration/MetrixNetworkTest.java | 2 +- 3 files changed, 77 insertions(+), 15 deletions(-) diff --git a/metrix-integration/src/main/java/com/powsybl/metrix/integration/MetrixNetwork.java b/metrix-integration/src/main/java/com/powsybl/metrix/integration/MetrixNetwork.java index eb14adf3..1cbc89d3 100755 --- a/metrix-integration/src/main/java/com/powsybl/metrix/integration/MetrixNetwork.java +++ b/metrix-integration/src/main/java/com/powsybl/metrix/integration/MetrixNetwork.java @@ -45,6 +45,7 @@ public class MetrixNetwork { private final Set countryList = new HashSet<>(); private final Set loadList = new LinkedHashSet<>(); + private final Set danglingLineList = new LinkedHashSet<>(); private final Set generatorList = new LinkedHashSet<>(); private final Set generatorTypeList = new HashSet<>(); @@ -52,8 +53,8 @@ public class MetrixNetwork { private final Set lineList = new LinkedHashSet<>(); private final Set twoWindingsTransformerList = new LinkedHashSet<>(); private final Set threeWindingsTransformerList = new LinkedHashSet<>(); - private final Set danglingLineList = new LinkedHashSet<>(); private final Set switchList = new LinkedHashSet<>(); + private final Set tieLineList = new LinkedHashSet<>(); private final Set phaseTapChangerList = new LinkedHashSet<>(); @@ -112,6 +113,10 @@ public List getSwitchList() { return List.copyOf(switchList); } + public List getTieLineList() { + return List.copyOf(tieLineList); + } + public List getPhaseTapChangerList() { return List.copyOf(phaseTapChangerList); } @@ -145,7 +150,7 @@ private MetrixSubset getMetrixSubset(Identifiable identifiable) { subset = MetrixSubset.NOEUD; } else if (identifiable instanceof HvdcLine) { subset = MetrixSubset.HVDC; - } else if (identifiable instanceof Load) { + } else if (identifiable instanceof Load || identifiable instanceof DanglingLine danglingLine && !danglingLine.isPaired()) { subset = MetrixSubset.LOAD; } return subset; @@ -205,6 +210,12 @@ private void addLine(Line line) { } } + private void addTieLine(TieLine tieLine) { + if (tieLineList.add(tieLine)) { + mapper.newInt(MetrixSubset.QUAD, tieLine.getId()); + } + } + private void addTwoWindingsTransformer(TwoWindingsTransformer twt) { if (twoWindingsTransformerList.add(twt)) { mapper.newInt(MetrixSubset.QUAD, twt.getId()); @@ -219,7 +230,7 @@ private void addThreeWindingsTransformer(ThreeWindingsTransformer twt) { private void addDanglingLine(DanglingLine dl) { if (danglingLineList.add(dl)) { - mapper.newInt(MetrixSubset.QUAD, dl.getId()); + mapper.newInt(MetrixSubset.LOAD, dl.getId()); } } @@ -315,6 +326,28 @@ private void createLineList() { } } + private void createTieLineList() { + int nbNok = 0; + for (TieLine tieLine : network.getTieLines()) { + Terminal t1 = tieLine.getTerminal1(); + Bus b1 = t1.getBusBreakerView().getBus(); + Terminal t2 = tieLine.getTerminal2(); + Bus b2 = t2.getBusBreakerView().getBus(); + if (b1 != null && b2 != null) { + if (busList.contains(b1) && busList.contains(b2)) { + addTieLine(tieLine); + } else { + nbNok++; + } + } else { + nbNok++; + } + } + if (LOGGER.isDebugEnabled()) { + LOGGER.debug(String.format("TieLines total = <%5d> ok = <%5d> not = <%5d>", tieLineList.size() + nbNok, tieLineList.size(), nbNok)); + } + } + private void addTwoWindingsTransformer(TwoWindingsTransformer twt, AtomicInteger nbNok, AtomicInteger nbPtcNok) { Terminal t1 = twt.getTerminal1(); Terminal t2 = twt.getTerminal2(); @@ -386,16 +419,18 @@ private void createTransformerList() { private void createDanglingLineList() { int nbNok = 0; for (DanglingLine dl : network.getDanglingLines()) { - Terminal t = dl.getTerminal(); - Bus b = t.getBusBreakerView().getBus(); - if (b != null) { - if (busList.contains(b)) { - addDanglingLine(dl); + if (!dl.isPaired()) { + Terminal t = dl.getTerminal(); + Bus b = t.getBusBreakerView().getBus(); + if (b != null) { + if (busList.contains(b)) { + addDanglingLine(dl); + } else { + nbNok++; + } } else { nbNok++; } - } else { - nbNok++; } } if (LOGGER.isDebugEnabled()) { @@ -525,6 +560,7 @@ private void init() { createSwitchList(); createLoadList(); createHvdcLineList(); + createTieLineList(); } public static MetrixNetwork create(Network network) { @@ -657,7 +693,18 @@ private void addElementToRetainedBreakersList(Switch sw, Terminal terminal, bool // Since switches connected to lines and TWT are "replaced" by those connectables, no need to set them retained case LINE, TWO_WINDINGS_TRANSFORMER -> addElementToRetainedBreakersList(sw, terminal.getConnectable().getId(), false); case LOAD, GENERATOR -> addElementToRetainedBreakersList(sw, switchId, setRetained); - case DANGLING_LINE, HVDC_CONVERTER_STATION, SHUNT_COMPENSATOR, STATIC_VAR_COMPENSATOR, + case DANGLING_LINE -> { + // A paired dangling line is managed as a line via the tie line while a not-paired is managed as a load + DanglingLine danglingLine = (DanglingLine) terminal.getConnectable(); + if (danglingLine.isPaired()) { + addElementToRetainedBreakersList(sw, + danglingLine.getTieLine().orElseThrow(() -> new PowsyblException("No tie line on a paired dangling line - should not happen")).getId(), + false); + } else { + addElementToRetainedBreakersList(sw, switchId, setRetained); + } + } + case HVDC_CONVERTER_STATION, SHUNT_COMPENSATOR, STATIC_VAR_COMPENSATOR, THREE_WINDINGS_TRANSFORMER -> { if (LOGGER.isWarnEnabled()) { LOGGER.warn("Unsupported connectable type ({}) for switch '{}'", terminal.getConnectable().getType(), switchId); diff --git a/metrix-integration/src/main/java/com/powsybl/metrix/integration/dataGenerator/MetrixInputData.java b/metrix-integration/src/main/java/com/powsybl/metrix/integration/dataGenerator/MetrixInputData.java index 33dc4d57..ab572d03 100755 --- a/metrix-integration/src/main/java/com/powsybl/metrix/integration/dataGenerator/MetrixInputData.java +++ b/metrix-integration/src/main/java/com/powsybl/metrix/integration/dataGenerator/MetrixInputData.java @@ -185,7 +185,11 @@ private void createMetrixInputs() { trnbgrou = metrixNetwork.getGeneratorList().size(); // Quadripoles are lines, transformers and switches - cqnbquad = metrixNetwork.getLineList().size() + metrixNetwork.getTwoWindingsTransformerList().size() + 3 * metrixNetwork.getThreeWindingsTransformerList().size() + metrixNetwork.getSwitchList().size(); + cqnbquad = metrixNetwork.getLineList().size() + + metrixNetwork.getTwoWindingsTransformerList().size() + + 3 * metrixNetwork.getThreeWindingsTransformerList().size() + + metrixNetwork.getSwitchList().size() + + metrixNetwork.getTieLineList().size(); dtnbtrde = metrixNetwork.getPhaseTapChangerList().size(); // Loads are loads and dangling lines @@ -399,6 +403,9 @@ private void writeBranches(boolean constantLossFactor, MetrixDie die) { // Switches metrixNetwork.getSwitchList().forEach(sw -> writeSwitch(sw, metrixInputBranch)); + // TieLines + metrixNetwork.getTieLineList().forEach(tieLine -> writeTieLine(tieLine, metrixInputBranch, constantLossFactor)); + // Branch die.setStringArray("CQNOMQUA", cqnomqua); die.setFloatArray("CQADMITA", cqadmita); @@ -523,11 +530,19 @@ private MetrixPtcControlType getMetrixPtcControlType(TwoWindingsTransformer twt, } private void writeLine(Line line, MetrixInputBranch metrixInputBranch, boolean constantLossFactor) { + writeLineOrTieLine(line, line.getR(), line.getX(), metrixInputBranch, constantLossFactor); + } + + private void writeTieLine(TieLine tieLine, MetrixInputBranch metrixInputBranch, boolean constantLossFactor) { + writeLineOrTieLine(tieLine, tieLine.getR(), tieLine.getX(), metrixInputBranch, constantLossFactor); + } + + private void writeLineOrTieLine(Branch line, double lineR, double lineX, MetrixInputBranch metrixInputBranch, boolean constantLossFactor) { double nominalVoltage1 = line.getTerminal1().getVoltageLevel().getNominalV(); double nominalVoltage2 = line.getTerminal2().getVoltageLevel().getNominalV(); double nominalVoltage = constantLossFactor ? Math.max(nominalVoltage1, nominalVoltage2) : nominalVoltage2; - double r = (line.getR() * Math.pow(parameters.getNominalU(), 2)) / Math.pow(nominalVoltage, 2); - double admittance = toAdmittance(line.getId(), line.getX(), nominalVoltage, parameters.getNominalU()); + double r = (lineR * Math.pow(parameters.getNominalU(), 2)) / Math.pow(nominalVoltage, 2); + double admittance = toAdmittance(line.getId(), lineX, nominalVoltage, parameters.getNominalU()); int index = metrixNetwork.getIndex(line); int bus1Index = metrixNetwork.getIndex(line.getTerminal1().getBusBreakerView().getBus()); int bus2Index = metrixNetwork.getIndex(line.getTerminal2().getBusBreakerView().getBus()); diff --git a/metrix-integration/src/test/java/com/powsybl/metrix/integration/MetrixNetworkTest.java b/metrix-integration/src/test/java/com/powsybl/metrix/integration/MetrixNetworkTest.java index 07894e44..5aaa9f53 100644 --- a/metrix-integration/src/test/java/com/powsybl/metrix/integration/MetrixNetworkTest.java +++ b/metrix-integration/src/test/java/com/powsybl/metrix/integration/MetrixNetworkTest.java @@ -51,7 +51,7 @@ void testNetworkElementsLists() { Set mappedSwitches = Set.of("S1VL2_GH2_BREAKER", "S3VL1_LINES3S4_BREAKER", "S1VL1_LD1_BREAKER", "S1VL3_DL_BREAKER", "S1VL2_BBS1_BBS3"); // Expected switch list in MetrixNetwork: switches next to branches (lines, two windings transformers) are not present - List switchList = Set.of("S1VL2_GH2_BREAKER", "S1VL1_LD1_BREAKER", "S1VL2_BBS1_BBS3") + List switchList = Set.of("S1VL2_GH2_BREAKER", "S1VL1_LD1_BREAKER", "S1VL3_DL_BREAKER", "S1VL2_BBS1_BBS3") .stream() .map(network::getSwitch).toList(); From e844ad8ef11b80c278e2eca378a8c19a43c006c0 Mon Sep 17 00:00:00 2001 From: Nicolas Rol Date: Fri, 27 Sep 2024 09:13:42 +0200 Subject: [PATCH 10/19] add test for tieline coverage Signed-off-by: Nicolas Rol --- .../metrix/integration/MetrixNetworkTest.java | 63 ++++++++++++++++++- 1 file changed, 60 insertions(+), 3 deletions(-) diff --git a/metrix-integration/src/test/java/com/powsybl/metrix/integration/MetrixNetworkTest.java b/metrix-integration/src/test/java/com/powsybl/metrix/integration/MetrixNetworkTest.java index 5aaa9f53..85751e2d 100644 --- a/metrix-integration/src/test/java/com/powsybl/metrix/integration/MetrixNetworkTest.java +++ b/metrix-integration/src/test/java/com/powsybl/metrix/integration/MetrixNetworkTest.java @@ -48,13 +48,19 @@ void testNetworkElementsLists() { Network network = createNetwork(); // Set some switches as retained - Set mappedSwitches = Set.of("S1VL2_GH2_BREAKER", "S3VL1_LINES3S4_BREAKER", "S1VL1_LD1_BREAKER", "S1VL3_DL_BREAKER", "S1VL2_BBS1_BBS3"); + Set mappedSwitches = Set.of("S1VL2_GH2_BREAKER", "S3VL1_LINES3S4_BREAKER", "S1VL1_LD1_BREAKER", + "S1VL3_DL_BREAKER", "S1VL2_BBS1_BBS3", "S2VL2_DL_BREAKER"); // Expected switch list in MetrixNetwork: switches next to branches (lines, two windings transformers) are not present List switchList = Set.of("S1VL2_GH2_BREAKER", "S1VL1_LD1_BREAKER", "S1VL3_DL_BREAKER", "S1VL2_BBS1_BBS3") .stream() .map(network::getSwitch).toList(); + // Expected Dangling line list - only the unpaired dangling lines are listed + List danglingLineList = Set.of("DL") + .stream() + .map(network::getDanglingLine).toList(); + // Contingencies Contingency a = new Contingency("a", Collections.singletonList(new BranchContingency("LINE_S2S3"))); Contingency b = new Contingency("b", Arrays.asList( @@ -79,8 +85,9 @@ void testNetworkElementsLists() { assertThat(metrixNetwork.getLineList()).containsExactlyInAnyOrderElementsOf(network.getLines()); assertThat(metrixNetwork.getTwoWindingsTransformerList()).containsExactlyInAnyOrderElementsOf(network.getTwoWindingsTransformers()); assertThat(metrixNetwork.getThreeWindingsTransformerList()).containsExactlyInAnyOrderElementsOf(network.getThreeWindingsTransformers()); - assertThat(metrixNetwork.getDanglingLineList()).containsExactlyInAnyOrderElementsOf(network.getDanglingLines()); + assertThat(metrixNetwork.getDanglingLineList()).containsExactlyInAnyOrderElementsOf(danglingLineList); assertThat(metrixNetwork.getSwitchList()).containsExactlyInAnyOrderElementsOf(switchList); + assertThat(metrixNetwork.getTieLineList()).containsExactlyInAnyOrderElementsOf(network.getTieLines()); assertThat(metrixNetwork.getHvdcLineList()).containsExactlyInAnyOrderElementsOf(network.getHvdcLines()); assertThat(metrixNetwork.getBusList()).containsExactlyInAnyOrderElementsOf(network.getBusBreakerView().getBuses()); assertThat(metrixNetwork.getContingencyList()).containsExactlyInAnyOrderElementsOf(List.of(a, b)); @@ -92,6 +99,7 @@ void testNetworkElementsLists() { assertTrue(metrixNetwork.isMapped(network.getIdentifiable("LINE_S2S3"))); assertTrue(metrixNetwork.isMapped(network.getIdentifiable("LD5"))); assertFalse(metrixNetwork.isMapped(network.getIdentifiable("S2VL1_BBS"))); + assertTrue(metrixNetwork.isMapped(network.getIdentifiable("TL"))); } @Test @@ -106,6 +114,9 @@ void testNetworkBusBreakerElementsLists() { // Expected switch list in MetrixNetwork: switches next to branches (lines, two windings transformers) are not present List switchList = mappedSwitches.stream().map(network::getSwitch).toList(); + // Expected Dangling line list - only the unpaired dangling lines are listed + List danglingLineList = Set.of("DL").stream().map(network::getDanglingLine).toList(); + // Contingencies Contingency a = new Contingency("a", Collections.singletonList(new BranchContingency("LINE_S2S3"))); Contingency b = new Contingency("b", Arrays.asList( @@ -130,8 +141,9 @@ void testNetworkBusBreakerElementsLists() { assertThat(metrixNetwork.getLineList()).containsExactlyInAnyOrderElementsOf(network.getLines()); assertThat(metrixNetwork.getTwoWindingsTransformerList()).containsExactlyInAnyOrderElementsOf(network.getTwoWindingsTransformers()); assertThat(metrixNetwork.getThreeWindingsTransformerList()).containsExactlyInAnyOrderElementsOf(network.getThreeWindingsTransformers()); - assertThat(metrixNetwork.getDanglingLineList()).containsExactlyInAnyOrderElementsOf(network.getDanglingLines()); + assertThat(metrixNetwork.getDanglingLineList()).containsExactlyInAnyOrderElementsOf(danglingLineList); assertThat(metrixNetwork.getSwitchList()).containsExactlyInAnyOrderElementsOf(switchList); + assertThat(metrixNetwork.getTieLineList()).containsExactlyInAnyOrderElementsOf(network.getTieLines()); assertThat(metrixNetwork.getHvdcLineList()).containsExactlyInAnyOrderElementsOf(network.getHvdcLines()); assertThat(metrixNetwork.getBusList()).containsExactlyInAnyOrderElementsOf(network.getBusBreakerView().getBuses()); assertThat(metrixNetwork.getContingencyList()).containsExactlyInAnyOrderElementsOf(List.of(a, b)); @@ -232,6 +244,51 @@ private Network createNetwork() { createSwitch(network.getVoltageLevel("S1VL2"), "S1VL2_BBS3_DISCONNECTOR", SwitchKind.DISCONNECTOR, 92, 90); createSwitch(network.getVoltageLevel("S1VL2"), "S1VL2_BBS1_BBS3", SwitchKind.BREAKER, 91, 92); + // We now add two dangling lines and a Tie line + VoltageLevel vlS2VL2 = network.getSubstation("S2").newVoltageLevel() + .setId("S2VL2") + .setNominalV(225.0) + .setLowVoltageLimit(220.0) + .setHighVoltageLimit(240.0) + .setTopologyKind(TopologyKind.NODE_BREAKER) + .add(); + vlS2VL2.getNodeBreakerView().newBusbarSection() + .setId("S2VL2_BBS") + .setName("S2VL2_BBS") + .setNode(10) + .add(); + createSwitch(vlS2VL2, "S2VL2_BBS_DL_DISCONNECTOR", SwitchKind.DISCONNECTOR, 10, 11); + createSwitch(vlS2VL2, "S2VL2_DL_BREAKER", SwitchKind.BREAKER, 12, 11); + DanglingLine dl1 = vlS2VL2.newDanglingLine() + .setId("DL_S2VL2") + .setP0(0.0) + .setQ0(0.0) + .setR(1.5) + .setX(20.0) + .setG(1E-6) + .setB(386E-6 / 2) + .setPairingKey("XNODE1") + .setNode(12) + .add(); + createSwitch(network.getVoltageLevel("S1VL2"), "S1VL2_BBS_DL_DISCONNECTOR", SwitchKind.DISCONNECTOR, 0, 93); + createSwitch(network.getVoltageLevel("S1VL2"), "S1VL2_DL_BREAKER", SwitchKind.BREAKER, 93, 94); + DanglingLine dl2 = network.getVoltageLevel("S1VL2").newDanglingLine() + .setId("DL_S1VL2") + .setP0(0.0) + .setQ0(0.0) + .setR(1.5) + .setX(13.0) + .setG(2E-6) + .setB(386E-6 / 2) + .setNode(94) + .setPairingKey("XNODE1") + .add(); + network.newTieLine() + .setId("TL") + .setDanglingLine1(dl1.getId()) + .setDanglingLine2(dl2.getId()) + .add(); + return network; } From e9236028c4c169450641406d8b02527b8fd184b5 Mon Sep 17 00:00:00 2001 From: Damien Jeandemange Date: Fri, 8 Nov 2024 17:01:32 +0100 Subject: [PATCH 11/19] Handle unpaired dangling line as quad + node + load Signed-off-by: Damien Jeandemange --- .../metrix/integration/MetrixNetwork.java | 50 ++++++++++++------- .../dataGenerator/MetrixInputData.java | 41 ++++++++++++--- .../MetrixInputDataGeneratorTest.java | 2 +- .../metrix/integration/MetrixNetworkTest.java | 6 +-- 4 files changed, 72 insertions(+), 27 deletions(-) diff --git a/metrix-integration/src/main/java/com/powsybl/metrix/integration/MetrixNetwork.java b/metrix-integration/src/main/java/com/powsybl/metrix/integration/MetrixNetwork.java index 9d101ccd..65dd48fb 100755 --- a/metrix-integration/src/main/java/com/powsybl/metrix/integration/MetrixNetwork.java +++ b/metrix-integration/src/main/java/com/powsybl/metrix/integration/MetrixNetwork.java @@ -37,6 +37,8 @@ public class MetrixNetwork { private static final Logger LOGGER = LoggerFactory.getLogger(MetrixNetwork.class); private static final String PAYS_CVG_PROPERTY = "paysCvg"; private static final String PAYS_CVG_UNDEFINED = "Undefined"; + private static final String METRIX_DANGLING_LINE_BUS_SUFFIX = "_metrixDanglingLineBus"; + private static final String METRIX_DANGLING_LINE_LOAD_SUFFIX = "_metrixDanglingLineLoad"; private final Network network; @@ -45,7 +47,6 @@ public class MetrixNetwork { private final Set countryList = new HashSet<>(); private final Set loadList = new LinkedHashSet<>(); - private final Set danglingLineList = new LinkedHashSet<>(); private final Set generatorList = new LinkedHashSet<>(); private final Set generatorTypeList = new HashSet<>(); @@ -54,6 +55,7 @@ public class MetrixNetwork { private final Set twoWindingsTransformerList = new LinkedHashSet<>(); private final Set threeWindingsTransformerList = new LinkedHashSet<>(); private final Set switchList = new LinkedHashSet<>(); + private final Set unpairedDanglingLineList = new LinkedHashSet<>(); private final Set tieLineList = new LinkedHashSet<>(); private final Set phaseTapChangerList = new LinkedHashSet<>(); @@ -105,8 +107,8 @@ public List getThreeWindingsTransformerList() { return List.copyOf(threeWindingsTransformerList); } - public List getDanglingLineList() { - return List.copyOf(danglingLineList); + public List getUnpairedDanglingLineList() { + return List.copyOf(unpairedDanglingLineList); } public List getSwitchList() { @@ -142,6 +144,19 @@ public int getIndex(Identifiable identifiable) { return mapper.getInt(subset, identifiable.getId()); } + public int getUnpairedDanglingLineBusIndex(DanglingLine danglingLine) { + Objects.requireNonNull(danglingLine); + if (danglingLine.isPaired()) { + throw new IllegalStateException("DanglingLine is paired " + danglingLine.getId()); + } + return mapper.getInt(MetrixSubset.NOEUD, danglingLine.getId() + METRIX_DANGLING_LINE_BUS_SUFFIX); + } + + public static String getUnpairedDanglingLineLoadId(DanglingLine danglingLine) { + Objects.requireNonNull(danglingLine); + return danglingLine.getId() + METRIX_DANGLING_LINE_LOAD_SUFFIX; + } + private MetrixSubset getMetrixSubset(Identifiable identifiable) { MetrixSubset subset = MetrixSubset.QUAD; if (identifiable instanceof Generator) { @@ -150,7 +165,7 @@ private MetrixSubset getMetrixSubset(Identifiable identifiable) { subset = MetrixSubset.NOEUD; } else if (identifiable instanceof HvdcLine) { subset = MetrixSubset.HVDC; - } else if (identifiable instanceof Load || identifiable instanceof DanglingLine danglingLine && !danglingLine.isPaired()) { + } else if (identifiable instanceof Load) { subset = MetrixSubset.LOAD; } return subset; @@ -228,9 +243,11 @@ private void addThreeWindingsTransformer(ThreeWindingsTransformer twt) { } } - private void addDanglingLine(DanglingLine dl) { - if (danglingLineList.add(dl)) { - mapper.newInt(MetrixSubset.LOAD, dl.getId()); + private void addUnpairedDanglingLine(DanglingLine dl) { + if (unpairedDanglingLineList.add(dl)) { + mapper.newInt(MetrixSubset.QUAD, dl.getId()); + mapper.newInt(MetrixSubset.NOEUD, dl.getId() + METRIX_DANGLING_LINE_BUS_SUFFIX); + mapper.newInt(MetrixSubset.LOAD, dl.getId() + METRIX_DANGLING_LINE_LOAD_SUFFIX); } } @@ -424,7 +441,7 @@ private void createDanglingLineList() { Bus b = t.getBusBreakerView().getBus(); if (b != null) { if (busList.contains(b)) { - addDanglingLine(dl); + addUnpairedDanglingLine(dl); } else { nbNok++; } @@ -434,7 +451,7 @@ private void createDanglingLineList() { } } if (LOGGER.isDebugEnabled()) { - LOGGER.debug(String.format("Dangling total = <%5d> ok = <%5d> not = <%5d>", danglingLineList.size() + nbNok, danglingLineList.size(), nbNok)); + LOGGER.debug(String.format("Dangling total = <%5d> ok = <%5d> not = <%5d>", unpairedDanglingLineList.size() + nbNok, unpairedDanglingLineList.size(), nbNok)); } } @@ -456,7 +473,7 @@ private void createSwitchList() { } } if (LOGGER.isDebugEnabled()) { - LOGGER.debug(String.format("Switches total = <%5d> ok = <%5d> not = <%5d>", switchList.size() + nbNok, switchList.size(), nbNok)); + LOGGER.debug(String.format("Switches total = <%5d> ok = <%5d> not = <%5d>", switchList.size() + nbNok, switchList.size(), nbNok)); } } @@ -574,8 +591,7 @@ public static MetrixNetwork create(Network network, ContingenciesProvider contin try { reader = Files.newBufferedReader(remedialActionFile, StandardCharsets.UTF_8); } catch (IOException e) { - LOGGER.error("Failed to read remedialActionFile {}", remedialActionFile, e); - throw new UncheckedIOException(e); + throw new UncheckedIOException("Failed to read remedialActionFile " + remedialActionFile, e); } } return create( @@ -694,14 +710,14 @@ private void addElementToRetainedBreakersList(Switch sw, Terminal terminal, bool case LINE, TWO_WINDINGS_TRANSFORMER -> addElementToRetainedBreakersList(sw, terminal.getConnectable().getId(), false); case LOAD, GENERATOR -> addElementToRetainedBreakersList(sw, switchId, setRetained); case DANGLING_LINE -> { - // A paired dangling line is managed as a line via the tie line while a not-paired is managed as a load DanglingLine danglingLine = (DanglingLine) terminal.getConnectable(); if (danglingLine.isPaired()) { - addElementToRetainedBreakersList(sw, - danglingLine.getTieLine().orElseThrow(() -> new PowsyblException("No tie line on a paired dangling line - should not happen")).getId(), - false); + // Paired dangling line is managed as a line via the tie line + TieLine tieLine = danglingLine.getTieLine().orElseThrow(() -> new PowsyblException("No tie line on a paired dangling line - should not happen")); + addElementToRetainedBreakersList(sw, tieLine.getId(), false); } else { - addElementToRetainedBreakersList(sw, switchId, setRetained); + // Unpaired dangling line is managed as a line (ending to a load) + addElementToRetainedBreakersList(sw, terminal.getConnectable().getId(), false); } } case HVDC_CONVERTER_STATION, SHUNT_COMPENSATOR, STATIC_VAR_COMPENSATOR, diff --git a/metrix-integration/src/main/java/com/powsybl/metrix/integration/dataGenerator/MetrixInputData.java b/metrix-integration/src/main/java/com/powsybl/metrix/integration/dataGenerator/MetrixInputData.java index ab572d03..f4944493 100755 --- a/metrix-integration/src/main/java/com/powsybl/metrix/integration/dataGenerator/MetrixInputData.java +++ b/metrix-integration/src/main/java/com/powsybl/metrix/integration/dataGenerator/MetrixInputData.java @@ -189,15 +189,16 @@ private void createMetrixInputs() { + metrixNetwork.getTwoWindingsTransformerList().size() + 3 * metrixNetwork.getThreeWindingsTransformerList().size() + metrixNetwork.getSwitchList().size() + + metrixNetwork.getUnpairedDanglingLineList().size() + metrixNetwork.getTieLineList().size(); dtnbtrde = metrixNetwork.getPhaseTapChangerList().size(); - // Loads are loads and dangling lines - ecnbcons = metrixNetwork.getLoadList().size() + metrixNetwork.getDanglingLineList().size(); + // Loads are loads and unpaired dangling lines + ecnbcons = metrixNetwork.getLoadList().size() + metrixNetwork.getUnpairedDanglingLineList().size(); dcnblies = metrixNetwork.getHvdcLineList().size(); - tnnbntot = metrixNetwork.getBusList().size(); + tnnbntot = metrixNetwork.getBusList().size() + metrixNetwork.getUnpairedDanglingLineList().size(); if (dslData != null) { sectnbse = dslData.getSectionList().size(); @@ -406,6 +407,9 @@ private void writeBranches(boolean constantLossFactor, MetrixDie die) { // TieLines metrixNetwork.getTieLineList().forEach(tieLine -> writeTieLine(tieLine, metrixInputBranch, constantLossFactor)); + // Unpaired Dangling Lines + metrixNetwork.getUnpairedDanglingLineList().forEach(udl -> writeUnpairedDanglingLine(udl, metrixInputBranch)); + // Branch die.setStringArray("CQNOMQUA", cqnomqua); die.setFloatArray("CQADMITA", cqadmita); @@ -537,6 +541,21 @@ private void writeTieLine(TieLine tieLine, MetrixInputBranch metrixInputBranch, writeLineOrTieLine(tieLine, tieLine.getR(), tieLine.getX(), metrixInputBranch, constantLossFactor); } + private void writeUnpairedDanglingLine(DanglingLine danglingLine, MetrixInputBranch metrixInputBranch) { + double nominalVoltage = danglingLine.getTerminal().getVoltageLevel().getNominalV(); + double r = (danglingLine.getR() * Math.pow(parameters.getNominalU(), 2)) / Math.pow(nominalVoltage, 2); + double admittance = toAdmittance(danglingLine.getId(), danglingLine.getX(), nominalVoltage, parameters.getNominalU()); + int index = metrixNetwork.getIndex(danglingLine); + // side 1 is network side + int bus1Index = metrixNetwork.getIndex(danglingLine.getTerminal().getBusBreakerView().getBus()); + // side 2 is boundary side + int bus2Index = metrixNetwork.getUnpairedDanglingLineBusIndex(danglingLine); + + writeBranch(metrixInputBranch, + index, + new BranchValues(danglingLine.getId(), admittance, r, getMonitoringTypeBasecase(danglingLine.getId()), getMonitoringTypeOnContingency(danglingLine.getId()), bus1Index, bus2Index)); + } + private void writeLineOrTieLine(Branch line, double lineR, double lineX, MetrixInputBranch metrixInputBranch, boolean constantLossFactor) { double nominalVoltage1 = line.getTerminal1().getVoltageLevel().getNominalV(); double nominalVoltage2 = line.getTerminal2().getVoltageLevel().getNominalV(); @@ -566,6 +585,10 @@ private void writeTopology(MetrixDie die) { int index = metrixNetwork.getIndex(bus); cpposreg[index - 1] = metrixNetwork.getCountryIndex(metrixNetwork.getCountryCode(bus.getVoltageLevel())); } + for (DanglingLine udl : metrixNetwork.getUnpairedDanglingLineList()) { + int index = metrixNetwork.getUnpairedDanglingLineBusIndex(udl); + cpposreg[index - 1] = metrixNetwork.getCountryIndex(metrixNetwork.getCountryCode(udl.getTerminal().getBusBreakerView().getBus().getVoltageLevel())); + } die.setIntArray("CPPOSREG", cpposreg); } @@ -607,9 +630,15 @@ private void writeLoads(MetrixDie die) { index++; } - for (DanglingLine dl : metrixNetwork.getDanglingLineList()) { - int busIndex = metrixNetwork.getIndex(dl.getTerminal().getBusBreakerView().getBus()); - writeLoad(tnneucel, esafiact, tnnomnoe, index, busIndex, (float) dl.getP0(), dl.getId()); + for (DanglingLine udl : metrixNetwork.getUnpairedDanglingLineList()) { + int busIndex = metrixNetwork.getUnpairedDanglingLineBusIndex(udl); + float p0 = (float) udl.getP0(); + if (udl.getGeneration() != null) { + // We do not greate a generator, because we do not want the DL generation to be used when balancing Gen/Load. + // Therefore, we just remove the generation part from the load. + p0 -= (float) udl.getGeneration().getTargetP(); + } + writeLoad(tnneucel, esafiact, tnnomnoe, index, busIndex, p0, udl.getId() + MetrixNetwork.getUnpairedDanglingLineLoadId(udl)); index++; } diff --git a/metrix-integration/src/test/java/com/powsybl/metrix/integration/MetrixInputDataGeneratorTest.java b/metrix-integration/src/test/java/com/powsybl/metrix/integration/MetrixInputDataGeneratorTest.java index 2ca13bb1..d41209b0 100644 --- a/metrix-integration/src/test/java/com/powsybl/metrix/integration/MetrixInputDataGeneratorTest.java +++ b/metrix-integration/src/test/java/com/powsybl/metrix/integration/MetrixInputDataGeneratorTest.java @@ -88,7 +88,7 @@ void generateInputFileZipDoNotWriteFile() throws IOException { } @Test - void generateInputFileZipDoNotCopyAdditionnalFiles() throws IOException { + void generateInputFileZipDoNotCopyAdditionalFiles() throws IOException { //GIVEN Path remedialActionFile = Paths.get("remedialActionFile"); MetrixVariantProvider variantProvider = null; diff --git a/metrix-integration/src/test/java/com/powsybl/metrix/integration/MetrixNetworkTest.java b/metrix-integration/src/test/java/com/powsybl/metrix/integration/MetrixNetworkTest.java index 37d0f7f9..e7776a70 100644 --- a/metrix-integration/src/test/java/com/powsybl/metrix/integration/MetrixNetworkTest.java +++ b/metrix-integration/src/test/java/com/powsybl/metrix/integration/MetrixNetworkTest.java @@ -52,7 +52,7 @@ void testNetworkElementsLists() { "S1VL3_DL_BREAKER", "S1VL2_BBS1_BBS3", "S2VL2_DL_BREAKER"); // Expected switch list in MetrixNetwork: switches next to branches (lines, two windings transformers) are not present - List switchList = Set.of("S1VL2_GH2_BREAKER", "S1VL1_LD1_BREAKER", "S1VL3_DL_BREAKER", "S1VL2_BBS1_BBS3") + List switchList = Set.of("S1VL2_GH2_BREAKER", "S1VL1_LD1_BREAKER", "S1VL2_BBS1_BBS3") .stream() .map(network::getSwitch).toList(); @@ -85,7 +85,7 @@ void testNetworkElementsLists() { assertThat(metrixNetwork.getLineList()).containsExactlyInAnyOrderElementsOf(network.getLines()); assertThat(metrixNetwork.getTwoWindingsTransformerList()).containsExactlyInAnyOrderElementsOf(network.getTwoWindingsTransformers()); assertThat(metrixNetwork.getThreeWindingsTransformerList()).containsExactlyInAnyOrderElementsOf(network.getThreeWindingsTransformers()); - assertThat(metrixNetwork.getDanglingLineList()).containsExactlyInAnyOrderElementsOf(danglingLineList); + assertThat(metrixNetwork.getUnpairedDanglingLineList()).containsExactlyInAnyOrderElementsOf(danglingLineList); assertThat(metrixNetwork.getSwitchList()).containsExactlyInAnyOrderElementsOf(switchList); assertThat(metrixNetwork.getTieLineList()).containsExactlyInAnyOrderElementsOf(network.getTieLines()); assertThat(metrixNetwork.getHvdcLineList()).containsExactlyInAnyOrderElementsOf(network.getHvdcLines()); @@ -141,7 +141,7 @@ void testNetworkBusBreakerElementsLists() { assertThat(metrixNetwork.getLineList()).containsExactlyInAnyOrderElementsOf(network.getLines()); assertThat(metrixNetwork.getTwoWindingsTransformerList()).containsExactlyInAnyOrderElementsOf(network.getTwoWindingsTransformers()); assertThat(metrixNetwork.getThreeWindingsTransformerList()).containsExactlyInAnyOrderElementsOf(network.getThreeWindingsTransformers()); - assertThat(metrixNetwork.getDanglingLineList()).containsExactlyInAnyOrderElementsOf(danglingLineList); + assertThat(metrixNetwork.getUnpairedDanglingLineList()).containsExactlyInAnyOrderElementsOf(danglingLineList); assertThat(metrixNetwork.getSwitchList()).containsExactlyInAnyOrderElementsOf(switchList); assertThat(metrixNetwork.getTieLineList()).containsExactlyInAnyOrderElementsOf(network.getTieLines()); assertThat(metrixNetwork.getHvdcLineList()).containsExactlyInAnyOrderElementsOf(network.getHvdcLines()); From c0d333f1a474f51451edc383a77dbb6fe9fa218c Mon Sep 17 00:00:00 2001 From: Damien Jeandemange Date: Fri, 8 Nov 2024 17:25:06 +0100 Subject: [PATCH 12/19] test Signed-off-by: Damien Jeandemange --- .../metrix/integration/MetrixInputTest.java | 30 ++ .../src/test/resources/tieLinesNetwork.json | 495 ++++++++++++++++++ .../unpairedDanglingLineNetwork.json | 495 ++++++++++++++++++ 3 files changed, 1020 insertions(+) create mode 100644 metrix-integration/src/test/resources/tieLinesNetwork.json create mode 100644 metrix-integration/src/test/resources/unpairedDanglingLineNetwork.json diff --git a/metrix-integration/src/test/java/com/powsybl/metrix/integration/MetrixInputTest.java b/metrix-integration/src/test/java/com/powsybl/metrix/integration/MetrixInputTest.java index 9f4e833d..e3200c2f 100755 --- a/metrix-integration/src/test/java/com/powsybl/metrix/integration/MetrixInputTest.java +++ b/metrix-integration/src/test/java/com/powsybl/metrix/integration/MetrixInputTest.java @@ -17,6 +17,8 @@ import com.powsybl.commons.PowsyblException; import com.powsybl.contingency.*; import com.powsybl.iidm.network.*; +import com.powsybl.iidm.network.test.DanglingLineNetworkFactory; +import com.powsybl.iidm.network.test.EurostagTutorialExample1Factory; import com.powsybl.iidm.network.test.ThreeWindingsTransformerNetworkFactory; import com.powsybl.iidm.serde.NetworkSerDe; import com.powsybl.metrix.integration.dataGenerator.MetrixInputData; @@ -169,6 +171,34 @@ void metrixInputDataWithT3TTest() throws IOException { } } + @Test + void metrixInputDataWithTieLinesTests() throws IOException { + Network n = EurostagTutorialExample1Factory.createWithTieLine(); + // Conversion iidm to die + StringWriter writer = new StringWriter(); + new MetrixInputData(MetrixNetwork.create(n), null, new MetrixParameters()).writeJson(writer); + writer.close(); + + // Results comparison + String actual = writer.toString(); + assertNotNull(compareStreamTxt(getClass().getResourceAsStream("/tieLinesNetwork.json"), + new ByteArrayInputStream(actual.getBytes(StandardCharsets.UTF_8)))); + } + + @Test + void metrixInputDataWithUnpairedDanglingLineTests() throws IOException { + Network n = DanglingLineNetworkFactory.createWithGeneration(); + // Conversion iidm to die + StringWriter writer = new StringWriter(); + new MetrixInputData(MetrixNetwork.create(n), null, new MetrixParameters()).writeJson(writer); + writer.close(); + + // Results comparison + String actual = writer.toString(); + assertNotNull(compareStreamTxt(getClass().getResourceAsStream("/unpairedDanglingLineNetwork.json"), + new ByteArrayInputStream(actual.getBytes(StandardCharsets.UTF_8)))); + } + @Test void metrixInputTest() throws IOException { Network n = NetworkSerDe.read(getClass().getResourceAsStream("/simpleNetwork.xml")); diff --git a/metrix-integration/src/test/resources/tieLinesNetwork.json b/metrix-integration/src/test/resources/tieLinesNetwork.json new file mode 100644 index 00000000..6d0a25be --- /dev/null +++ b/metrix-integration/src/test/resources/tieLinesNetwork.json @@ -0,0 +1,495 @@ +{ + "files" : [ { + "name" : "IntegerFile", + "attributes" : [ { + "name" : "CGNBREGI", + "type" : "INTEGER", + "valueCount" : 1, + "firstIndexMaxValue" : 1, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 1, + "values" : [ 1 ] + }, { + "name" : "TNNBNTOT", + "type" : "INTEGER", + "valueCount" : 1, + "firstIndexMaxValue" : 1, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 1, + "values" : [ 4 ] + }, { + "name" : "CQNBQUAD", + "type" : "INTEGER", + "valueCount" : 1, + "firstIndexMaxValue" : 1, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 1, + "values" : [ 4 ] + }, { + "name" : "ECNBCONS", + "type" : "INTEGER", + "valueCount" : 1, + "firstIndexMaxValue" : 1, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 1, + "values" : [ 1 ] + }, { + "name" : "TRNBGROU", + "type" : "INTEGER", + "valueCount" : 1, + "firstIndexMaxValue" : 1, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 1, + "values" : [ 1 ] + }, { + "name" : "DTNBTRDE", + "type" : "INTEGER", + "valueCount" : 1, + "firstIndexMaxValue" : 1, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 1, + "values" : [ 0 ] + }, { + "name" : "DCNBLIES", + "type" : "INTEGER", + "valueCount" : 1, + "firstIndexMaxValue" : 1, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 1, + "values" : [ 0 ] + }, { + "name" : "SECTNBSE", + "type" : "INTEGER", + "valueCount" : 1, + "firstIndexMaxValue" : 1, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 1, + "values" : [ 0 ] + }, { + "name" : "MODECALC", + "type" : "INTEGER", + "valueCount" : 1, + "firstIndexMaxValue" : 1, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 1, + "values" : [ 1 ] + }, { + "name" : "UNOMINAL", + "type" : "INTEGER", + "valueCount" : 1, + "firstIndexMaxValue" : 1, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 1, + "values" : [ 100 ] + }, { + "name" : "CPPOSREG", + "type" : "INTEGER", + "valueCount" : 4, + "firstIndexMaxValue" : 4, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 4, + "values" : [ 1, 1, 1, 1 ] + }, { + "name" : "QASURVDI", + "type" : "INTEGER", + "valueCount" : 4, + "firstIndexMaxValue" : 4, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 4, + "values" : [ 0, 0, 0, 0 ] + }, { + "name" : "QASURNMK", + "type" : "INTEGER", + "valueCount" : 4, + "firstIndexMaxValue" : 4, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 4, + "values" : [ 0, 0, 0, 0 ] + }, { + "name" : "TNNORQUA", + "type" : "INTEGER", + "valueCount" : 4, + "firstIndexMaxValue" : 4, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 4, + "values" : [ 1, 3, 2, 2 ] + }, { + "name" : "TNNEXQUA", + "type" : "INTEGER", + "valueCount" : 4, + "firstIndexMaxValue" : 4, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 4, + "values" : [ 2, 4, 3, 3 ] + }, { + "name" : "DTTRDEQU", + "type" : "INTEGER", + "valueCount" : 0, + "firstIndexMaxValue" : 0, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 0, + "values" : [ ] + }, { + "name" : "DTMODREG", + "type" : "INTEGER", + "valueCount" : 0, + "firstIndexMaxValue" : 0, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 0, + "values" : [ ] + }, { + "name" : "DTLOWTAP", + "type" : "INTEGER", + "valueCount" : 0, + "firstIndexMaxValue" : 0, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 0, + "values" : [ ] + }, { + "name" : "DTNBTAPS", + "type" : "INTEGER", + "valueCount" : 0, + "firstIndexMaxValue" : 0, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 0, + "values" : [ ] + }, { + "name" : "TNNEUCEL", + "type" : "INTEGER", + "valueCount" : 1, + "firstIndexMaxValue" : 1, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 1, + "values" : [ 4 ] + }, { + "name" : "TRNBTYPE", + "type" : "INTEGER", + "valueCount" : 1, + "firstIndexMaxValue" : 1, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 1, + "values" : [ 1 ] + }, { + "name" : "TNNEURGT", + "type" : "INTEGER", + "valueCount" : 1, + "firstIndexMaxValue" : 1, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 1, + "values" : [ 1 ] + }, { + "name" : "TRTYPGRP", + "type" : "INTEGER", + "valueCount" : 1, + "firstIndexMaxValue" : 1, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 1, + "values" : [ 0 ] + }, { + "name" : "SPIMPMOD", + "type" : "INTEGER", + "valueCount" : 1, + "firstIndexMaxValue" : 1, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 1, + "values" : [ 1 ] + }, { + "name" : "DCNDROOP", + "type" : "INTEGER", + "valueCount" : 1, + "firstIndexMaxValue" : 1, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 1, + "values" : [ 0 ] + }, { + "name" : "DCNORQUA", + "type" : "INTEGER", + "valueCount" : 0, + "firstIndexMaxValue" : 0, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 0, + "values" : [ ] + }, { + "name" : "DCNEXQUA", + "type" : "INTEGER", + "valueCount" : 0, + "firstIndexMaxValue" : 0, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 0, + "values" : [ ] + }, { + "name" : "DCREGPUI", + "type" : "INTEGER", + "valueCount" : 0, + "firstIndexMaxValue" : 0, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 0, + "values" : [ ] + }, { + "name" : "DMNBDEFK", + "type" : "INTEGER", + "valueCount" : 1, + "firstIndexMaxValue" : 1, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 1, + "values" : [ 0 ] + } ] + }, { + "name" : "FloatFile", + "attributes" : [ { + "name" : "CGCPERTE", + "type" : "FLOAT", + "valueCount" : 1, + "firstIndexMaxValue" : 1, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 1, + "values" : [ 0.0 ] + }, { + "name" : "CQADMITA", + "type" : "FLOAT", + "valueCount" : 4, + "firstIndexMaxValue" : 4, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 4, + "values" : [ 1.3003745, 0.5555934, 0.43757576, 0.43757576 ] + }, { + "name" : "CQRESIST", + "type" : "FLOAT", + "valueCount" : 4, + "firstIndexMaxValue" : 4, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 4, + "values" : [ 0.018461538, 0.021, 0.20775624, 0.20775624 ] + }, { + "name" : "DTVALSUP", + "type" : "FLOAT", + "valueCount" : 0, + "firstIndexMaxValue" : 0, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 0, + "values" : [ ] + }, { + "name" : "DTVALINF", + "type" : "FLOAT", + "valueCount" : 0, + "firstIndexMaxValue" : 0, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 0, + "values" : [ ] + }, { + "name" : "DTVALDEP", + "type" : "FLOAT", + "valueCount" : 0, + "firstIndexMaxValue" : 0, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 0, + "values" : [ ] + }, { + "name" : "DTTAPDEP", + "type" : "FLOAT", + "valueCount" : 0, + "firstIndexMaxValue" : 0, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 0, + "values" : [ ] + }, { + "name" : "ESAFIACT", + "type" : "FLOAT", + "valueCount" : 1, + "firstIndexMaxValue" : 1, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 1, + "values" : [ 600.0 ] + }, { + "name" : "SPPACTGT", + "type" : "FLOAT", + "valueCount" : 1, + "firstIndexMaxValue" : 1, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 1, + "values" : [ 607.0 ] + }, { + "name" : "TRVALPMD", + "type" : "FLOAT", + "valueCount" : 1, + "firstIndexMaxValue" : 1, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 1, + "values" : [ 9999.99 ] + }, { + "name" : "TRPUIMIN", + "type" : "FLOAT", + "valueCount" : 1, + "firstIndexMaxValue" : 1, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 1, + "values" : [ -9999.99 ] + }, { + "name" : "DCMINPUI", + "type" : "FLOAT", + "valueCount" : 0, + "firstIndexMaxValue" : 0, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 0, + "values" : [ ] + }, { + "name" : "DCMAXPUI", + "type" : "FLOAT", + "valueCount" : 0, + "firstIndexMaxValue" : 0, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 0, + "values" : [ ] + }, { + "name" : "DCIMPPUI", + "type" : "FLOAT", + "valueCount" : 0, + "firstIndexMaxValue" : 0, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 0, + "values" : [ ] + }, { + "name" : "DCTENSDC", + "type" : "FLOAT", + "valueCount" : 0, + "firstIndexMaxValue" : 0, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 0, + "values" : [ ] + }, { + "name" : "DCRESIST", + "type" : "FLOAT", + "valueCount" : 0, + "firstIndexMaxValue" : 0, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 0, + "values" : [ ] + }, { + "name" : "DCPERST1", + "type" : "FLOAT", + "valueCount" : 0, + "firstIndexMaxValue" : 0, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 0, + "values" : [ ] + }, { + "name" : "DCPERST2", + "type" : "FLOAT", + "valueCount" : 0, + "firstIndexMaxValue" : 0, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 0, + "values" : [ ] + } ] + }, { + "name" : "DoubleFile", + "attributes" : [ ] + }, { + "name" : "StringFile", + "attributes" : [ { + "name" : "CGNOMREG", + "type" : "STRING", + "valueCount" : 2, + "firstIndexMaxValue" : 2, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 2, + "values" : [ "FR" ] + }, { + "name" : "CQNOMQUA", + "type" : "STRING", + "valueCount" : 44, + "firstIndexMaxValue" : 11, + "secondIndexMaxValue" : 4, + "firstValueIndex" : 1, + "lastValueIndex" : 44, + "values" : [ "NGEN_NHV1", "NHV2_NLOAD", "NHV1_NHV2_1", "NHV1_NHV2_2" ] + }, { + "name" : "TNNOMNOE", + "type" : "STRING", + "valueCount" : 4, + "firstIndexMaxValue" : 4, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 4, + "values" : [ "LOAD" ] + }, { + "name" : "TRNOMGTH", + "type" : "STRING", + "valueCount" : 3, + "firstIndexMaxValue" : 3, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 3, + "values" : [ "GEN" ] + }, { + "name" : "TRNOMTYP", + "type" : "STRING", + "valueCount" : 5, + "firstIndexMaxValue" : 5, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 5, + "values" : [ "OTHER" ] + }, { + "name" : "DCNOMQUA", + "type" : "STRING", + "valueCount" : 0, + "firstIndexMaxValue" : 0, + "secondIndexMaxValue" : 0, + "firstValueIndex" : 1, + "lastValueIndex" : 0, + "values" : [ ] + } ] + }, { + "name" : "BooleanFile", + "attributes" : [ ] + } ] +} \ No newline at end of file diff --git a/metrix-integration/src/test/resources/unpairedDanglingLineNetwork.json b/metrix-integration/src/test/resources/unpairedDanglingLineNetwork.json new file mode 100644 index 00000000..9e252461 --- /dev/null +++ b/metrix-integration/src/test/resources/unpairedDanglingLineNetwork.json @@ -0,0 +1,495 @@ +{ + "files" : [ { + "name" : "IntegerFile", + "attributes" : [ { + "name" : "CGNBREGI", + "type" : "INTEGER", + "valueCount" : 1, + "firstIndexMaxValue" : 1, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 1, + "values" : [ 1 ] + }, { + "name" : "TNNBNTOT", + "type" : "INTEGER", + "valueCount" : 1, + "firstIndexMaxValue" : 1, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 1, + "values" : [ 2 ] + }, { + "name" : "CQNBQUAD", + "type" : "INTEGER", + "valueCount" : 1, + "firstIndexMaxValue" : 1, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 1, + "values" : [ 1 ] + }, { + "name" : "ECNBCONS", + "type" : "INTEGER", + "valueCount" : 1, + "firstIndexMaxValue" : 1, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 1, + "values" : [ 1 ] + }, { + "name" : "TRNBGROU", + "type" : "INTEGER", + "valueCount" : 1, + "firstIndexMaxValue" : 1, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 1, + "values" : [ 1 ] + }, { + "name" : "DTNBTRDE", + "type" : "INTEGER", + "valueCount" : 1, + "firstIndexMaxValue" : 1, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 1, + "values" : [ 0 ] + }, { + "name" : "DCNBLIES", + "type" : "INTEGER", + "valueCount" : 1, + "firstIndexMaxValue" : 1, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 1, + "values" : [ 0 ] + }, { + "name" : "SECTNBSE", + "type" : "INTEGER", + "valueCount" : 1, + "firstIndexMaxValue" : 1, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 1, + "values" : [ 0 ] + }, { + "name" : "MODECALC", + "type" : "INTEGER", + "valueCount" : 1, + "firstIndexMaxValue" : 1, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 1, + "values" : [ 1 ] + }, { + "name" : "UNOMINAL", + "type" : "INTEGER", + "valueCount" : 1, + "firstIndexMaxValue" : 1, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 1, + "values" : [ 100 ] + }, { + "name" : "CPPOSREG", + "type" : "INTEGER", + "valueCount" : 2, + "firstIndexMaxValue" : 2, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 2, + "values" : [ 1, 1 ] + }, { + "name" : "QASURVDI", + "type" : "INTEGER", + "valueCount" : 1, + "firstIndexMaxValue" : 1, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 1, + "values" : [ 0 ] + }, { + "name" : "QASURNMK", + "type" : "INTEGER", + "valueCount" : 1, + "firstIndexMaxValue" : 1, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 1, + "values" : [ 0 ] + }, { + "name" : "TNNORQUA", + "type" : "INTEGER", + "valueCount" : 1, + "firstIndexMaxValue" : 1, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 1, + "values" : [ 1 ] + }, { + "name" : "TNNEXQUA", + "type" : "INTEGER", + "valueCount" : 1, + "firstIndexMaxValue" : 1, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 1, + "values" : [ 2 ] + }, { + "name" : "DTTRDEQU", + "type" : "INTEGER", + "valueCount" : 0, + "firstIndexMaxValue" : 0, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 0, + "values" : [ ] + }, { + "name" : "DTMODREG", + "type" : "INTEGER", + "valueCount" : 0, + "firstIndexMaxValue" : 0, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 0, + "values" : [ ] + }, { + "name" : "DTLOWTAP", + "type" : "INTEGER", + "valueCount" : 0, + "firstIndexMaxValue" : 0, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 0, + "values" : [ ] + }, { + "name" : "DTNBTAPS", + "type" : "INTEGER", + "valueCount" : 0, + "firstIndexMaxValue" : 0, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 0, + "values" : [ ] + }, { + "name" : "TNNEUCEL", + "type" : "INTEGER", + "valueCount" : 1, + "firstIndexMaxValue" : 1, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 1, + "values" : [ 2 ] + }, { + "name" : "TRNBTYPE", + "type" : "INTEGER", + "valueCount" : 1, + "firstIndexMaxValue" : 1, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 1, + "values" : [ 1 ] + }, { + "name" : "TNNEURGT", + "type" : "INTEGER", + "valueCount" : 1, + "firstIndexMaxValue" : 1, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 1, + "values" : [ 1 ] + }, { + "name" : "TRTYPGRP", + "type" : "INTEGER", + "valueCount" : 1, + "firstIndexMaxValue" : 1, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 1, + "values" : [ 0 ] + }, { + "name" : "SPIMPMOD", + "type" : "INTEGER", + "valueCount" : 1, + "firstIndexMaxValue" : 1, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 1, + "values" : [ 1 ] + }, { + "name" : "DCNDROOP", + "type" : "INTEGER", + "valueCount" : 1, + "firstIndexMaxValue" : 1, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 1, + "values" : [ 0 ] + }, { + "name" : "DCNORQUA", + "type" : "INTEGER", + "valueCount" : 0, + "firstIndexMaxValue" : 0, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 0, + "values" : [ ] + }, { + "name" : "DCNEXQUA", + "type" : "INTEGER", + "valueCount" : 0, + "firstIndexMaxValue" : 0, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 0, + "values" : [ ] + }, { + "name" : "DCREGPUI", + "type" : "INTEGER", + "valueCount" : 0, + "firstIndexMaxValue" : 0, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 0, + "values" : [ ] + }, { + "name" : "DMNBDEFK", + "type" : "INTEGER", + "valueCount" : 1, + "firstIndexMaxValue" : 1, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 1, + "values" : [ 0 ] + } ] + }, { + "name" : "FloatFile", + "attributes" : [ { + "name" : "CGCPERTE", + "type" : "FLOAT", + "valueCount" : 1, + "firstIndexMaxValue" : 1, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 1, + "values" : [ 0.0 ] + }, { + "name" : "CQADMITA", + "type" : "FLOAT", + "valueCount" : 1, + "firstIndexMaxValue" : 1, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 1, + "values" : [ 1.0 ] + }, { + "name" : "CQRESIST", + "type" : "FLOAT", + "valueCount" : 1, + "firstIndexMaxValue" : 1, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 1, + "values" : [ 10.0 ] + }, { + "name" : "DTVALSUP", + "type" : "FLOAT", + "valueCount" : 0, + "firstIndexMaxValue" : 0, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 0, + "values" : [ ] + }, { + "name" : "DTVALINF", + "type" : "FLOAT", + "valueCount" : 0, + "firstIndexMaxValue" : 0, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 0, + "values" : [ ] + }, { + "name" : "DTVALDEP", + "type" : "FLOAT", + "valueCount" : 0, + "firstIndexMaxValue" : 0, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 0, + "values" : [ ] + }, { + "name" : "DTTAPDEP", + "type" : "FLOAT", + "valueCount" : 0, + "firstIndexMaxValue" : 0, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 0, + "values" : [ ] + }, { + "name" : "ESAFIACT", + "type" : "FLOAT", + "valueCount" : 1, + "firstIndexMaxValue" : 1, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 1, + "values" : [ -390.0 ] + }, { + "name" : "SPPACTGT", + "type" : "FLOAT", + "valueCount" : 1, + "firstIndexMaxValue" : 1, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 1, + "values" : [ 50.0 ] + }, { + "name" : "TRVALPMD", + "type" : "FLOAT", + "valueCount" : 1, + "firstIndexMaxValue" : 1, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 1, + "values" : [ 100.0 ] + }, { + "name" : "TRPUIMIN", + "type" : "FLOAT", + "valueCount" : 1, + "firstIndexMaxValue" : 1, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 1, + "values" : [ 0.0 ] + }, { + "name" : "DCMINPUI", + "type" : "FLOAT", + "valueCount" : 0, + "firstIndexMaxValue" : 0, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 0, + "values" : [ ] + }, { + "name" : "DCMAXPUI", + "type" : "FLOAT", + "valueCount" : 0, + "firstIndexMaxValue" : 0, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 0, + "values" : [ ] + }, { + "name" : "DCIMPPUI", + "type" : "FLOAT", + "valueCount" : 0, + "firstIndexMaxValue" : 0, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 0, + "values" : [ ] + }, { + "name" : "DCTENSDC", + "type" : "FLOAT", + "valueCount" : 0, + "firstIndexMaxValue" : 0, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 0, + "values" : [ ] + }, { + "name" : "DCRESIST", + "type" : "FLOAT", + "valueCount" : 0, + "firstIndexMaxValue" : 0, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 0, + "values" : [ ] + }, { + "name" : "DCPERST1", + "type" : "FLOAT", + "valueCount" : 0, + "firstIndexMaxValue" : 0, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 0, + "values" : [ ] + }, { + "name" : "DCPERST2", + "type" : "FLOAT", + "valueCount" : 0, + "firstIndexMaxValue" : 0, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 0, + "values" : [ ] + } ] + }, { + "name" : "DoubleFile", + "attributes" : [ ] + }, { + "name" : "StringFile", + "attributes" : [ { + "name" : "CGNOMREG", + "type" : "STRING", + "valueCount" : 2, + "firstIndexMaxValue" : 2, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 2, + "values" : [ "FR" ] + }, { + "name" : "CQNOMQUA", + "type" : "STRING", + "valueCount" : 2, + "firstIndexMaxValue" : 2, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 2, + "values" : [ "DL" ] + }, { + "name" : "TNNOMNOE", + "type" : "STRING", + "valueCount" : 27, + "firstIndexMaxValue" : 27, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 27, + "values" : [ "DLDL_metrixDanglingLineLoad" ] + }, { + "name" : "TRNOMGTH", + "type" : "STRING", + "valueCount" : 1, + "firstIndexMaxValue" : 1, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 1, + "values" : [ "G" ] + }, { + "name" : "TRNOMTYP", + "type" : "STRING", + "valueCount" : 5, + "firstIndexMaxValue" : 5, + "secondIndexMaxValue" : 1, + "firstValueIndex" : 1, + "lastValueIndex" : 5, + "values" : [ "OTHER" ] + }, { + "name" : "DCNOMQUA", + "type" : "STRING", + "valueCount" : 0, + "firstIndexMaxValue" : 0, + "secondIndexMaxValue" : 0, + "firstValueIndex" : 1, + "lastValueIndex" : 0, + "values" : [ ] + } ] + }, { + "name" : "BooleanFile", + "attributes" : [ ] + } ] +} \ No newline at end of file From 4afc31d75053fd62b77dbc82fb74040d1353d9f6 Mon Sep 17 00:00:00 2001 From: Damien Jeandemange Date: Thu, 14 Nov 2024 09:59:01 +0100 Subject: [PATCH 13/19] DanglingLine BranchMonitoring Signed-off-by: Damien Jeandemange --- .../metrix/integration/BranchMonitoringData.groovy | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/metrix-integration/src/main/groovy/com/powsybl/metrix/integration/BranchMonitoringData.groovy b/metrix-integration/src/main/groovy/com/powsybl/metrix/integration/BranchMonitoringData.groovy index 704136ff..4b8a2763 100644 --- a/metrix-integration/src/main/groovy/com/powsybl/metrix/integration/BranchMonitoringData.groovy +++ b/metrix-integration/src/main/groovy/com/powsybl/metrix/integration/BranchMonitoringData.groovy @@ -7,6 +7,8 @@ */ package com.powsybl.metrix.integration +import com.powsybl.iidm.network.Branch +import com.powsybl.iidm.network.DanglingLine import com.powsybl.iidm.network.Identifiable import com.powsybl.iidm.network.Network import com.powsybl.metrix.mapping.LogDslLoader @@ -126,11 +128,15 @@ class BranchMonitoringData { } protected static branchData(Closure closure, String id, Network network, TimeSeriesMappingConfigLoader configLoader, MetrixDslData data, LogDslLoader logDslLoader) { - Identifiable identifiable = network.getBranch(id) + Identifiable identifiable = network.getIdentifiable(id) if (identifiable == null) { logDslLoader.logWarn("Branch %s not found in the network", id) return } + if (!(identifiable instanceof Branch || identifiable instanceof DanglingLine)) { + logDslLoader.logWarn("Branch %s is not a Branch or Dangling Line", id) + return + } def branchSpec = branchMonitoringData(closure) From 7de56fd60b867ba6f43d775638fc4922ebc62c46 Mon Sep 17 00:00:00 2001 From: Damien Jeandemange Date: Thu, 14 Nov 2024 10:23:28 +0100 Subject: [PATCH 14/19] DanglingLine and TieLine Contingency Signed-off-by: Damien Jeandemange --- .../integration/dataGenerator/MetrixInputData.java | 2 +- .../metrix/integration/metrix/MetrixInputAnalysis.java | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/metrix-integration/src/main/java/com/powsybl/metrix/integration/dataGenerator/MetrixInputData.java b/metrix-integration/src/main/java/com/powsybl/metrix/integration/dataGenerator/MetrixInputData.java index f4944493..b220dedb 100755 --- a/metrix-integration/src/main/java/com/powsybl/metrix/integration/dataGenerator/MetrixInputData.java +++ b/metrix-integration/src/main/java/com/powsybl/metrix/integration/dataGenerator/MetrixInputData.java @@ -814,7 +814,7 @@ private double listElementsToTrip(Contingency contingency, try { int type; switch (element.getType()) { - case BRANCH, LINE, TWO_WINDINGS_TRANSFORMER -> type = ElementType.BRANCH.getType(); + case BRANCH, LINE, TWO_WINDINGS_TRANSFORMER, TIE_LINE, DANGLING_LINE -> type = ElementType.BRANCH.getType(); case GENERATOR -> { type = ElementType.GENERATOR.getType(); generatorPowerLost += metrixNetwork.getNetwork().getGenerator(element.getId()).getMaxP(); diff --git a/metrix-integration/src/main/java/com/powsybl/metrix/integration/metrix/MetrixInputAnalysis.java b/metrix-integration/src/main/java/com/powsybl/metrix/integration/metrix/MetrixInputAnalysis.java index 1799021d..02ee7a2e 100644 --- a/metrix-integration/src/main/java/com/powsybl/metrix/integration/metrix/MetrixInputAnalysis.java +++ b/metrix-integration/src/main/java/com/powsybl/metrix/integration/metrix/MetrixInputAnalysis.java @@ -148,6 +148,8 @@ private static boolean isValidContingencyType(ContingencyElementType elementType elementType == ContingencyElementType.TWO_WINDINGS_TRANSFORMER || elementType == ContingencyElementType.BRANCH || elementType == ContingencyElementType.GENERATOR || + elementType == ContingencyElementType.DANGLING_LINE || + elementType == ContingencyElementType.TIE_LINE || elementType == ContingencyElementType.HVDC_LINE; } @@ -158,13 +160,16 @@ private static boolean isValidContingencyTypeForIdentifiable(IdentifiableType id if (elementType == ContingencyElementType.TWO_WINDINGS_TRANSFORMER && identifiableType == IdentifiableType.TWO_WINDINGS_TRANSFORMER) { return true; } - if (elementType == ContingencyElementType.BRANCH && (identifiableType == IdentifiableType.LINE || identifiableType == IdentifiableType.TWO_WINDINGS_TRANSFORMER)) { + if (elementType == ContingencyElementType.BRANCH && (identifiableType == IdentifiableType.LINE || identifiableType == IdentifiableType.TWO_WINDINGS_TRANSFORMER || identifiableType == IdentifiableType.TIE_LINE)) { return true; } if (elementType == ContingencyElementType.GENERATOR && identifiableType == IdentifiableType.GENERATOR) { return true; } - return elementType == ContingencyElementType.HVDC_LINE && identifiableType == IdentifiableType.HVDC_LINE; + if (elementType == ContingencyElementType.HVDC_LINE && identifiableType == IdentifiableType.HVDC_LINE) { + return true; + } + return elementType == ContingencyElementType.DANGLING_LINE && identifiableType == IdentifiableType.DANGLING_LINE; } public static boolean isValidContingencyElement(IdentifiableType identifiableType, ContingencyElementType elementType) { From b00946087dddd6ef81134ddbf2dafe70e9474c50 Mon Sep 17 00:00:00 2001 From: Damien Jeandemange Date: Thu, 14 Nov 2024 18:25:26 +0100 Subject: [PATCH 15/19] DanglingLine and TieLine Section Monitoring Signed-off-by: Damien Jeandemange --- .../metrix/integration/BranchMonitoringData.groovy | 4 ++++ .../metrix/integration/SectionMonitoringData.groovy | 10 +++++++++- .../integration/dataGenerator/MetrixInputData.java | 5 ++++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/metrix-integration/src/main/groovy/com/powsybl/metrix/integration/BranchMonitoringData.groovy b/metrix-integration/src/main/groovy/com/powsybl/metrix/integration/BranchMonitoringData.groovy index 4b8a2763..7396c80a 100644 --- a/metrix-integration/src/main/groovy/com/powsybl/metrix/integration/BranchMonitoringData.groovy +++ b/metrix-integration/src/main/groovy/com/powsybl/metrix/integration/BranchMonitoringData.groovy @@ -137,6 +137,10 @@ class BranchMonitoringData { logDslLoader.logWarn("Branch %s is not a Branch or Dangling Line", id) return } + if (identifiable instanceof DanglingLine && identifiable.isPaired()) { + logDslLoader.logWarn("Branch %s is a paired Dangling Line, the TieLine should be used instead", id) + return + } def branchSpec = branchMonitoringData(closure) diff --git a/metrix-integration/src/main/groovy/com/powsybl/metrix/integration/SectionMonitoringData.groovy b/metrix-integration/src/main/groovy/com/powsybl/metrix/integration/SectionMonitoringData.groovy index 094f6e2a..fb24ce01 100644 --- a/metrix-integration/src/main/groovy/com/powsybl/metrix/integration/SectionMonitoringData.groovy +++ b/metrix-integration/src/main/groovy/com/powsybl/metrix/integration/SectionMonitoringData.groovy @@ -48,10 +48,18 @@ class SectionMonitoringData { logDslLoader.logWarn("sectionMonitoring '" + id + "' branch id '"+branch.getKey()+"' not found in the network") return } - if (!(identifiable instanceof Line || identifiable instanceof TwoWindingsTransformer || identifiable instanceof HvdcLine)) { + if (!(identifiable instanceof Line || + identifiable instanceof TwoWindingsTransformer || + identifiable instanceof TieLine || + identifiable instanceof DanglingLine || + identifiable instanceof HvdcLine)) { logDslLoader.logWarn("sectionMonitoring '" + id + "' type " + identifiable.getClass().name + " not supported") return } + if (identifiable instanceof DanglingLine && identifiable.isPaired()) { + logDslLoader.logWarn("Branch %s is a paired Dangling Line, the TieLine should be used instead", id) + return + } } section.setCoefFlowList(spec.branchList) data.addSection(section) diff --git a/metrix-integration/src/main/java/com/powsybl/metrix/integration/dataGenerator/MetrixInputData.java b/metrix-integration/src/main/java/com/powsybl/metrix/integration/dataGenerator/MetrixInputData.java index b220dedb..5eccfc8c 100755 --- a/metrix-integration/src/main/java/com/powsybl/metrix/integration/dataGenerator/MetrixInputData.java +++ b/metrix-integration/src/main/java/com/powsybl/metrix/integration/dataGenerator/MetrixInputData.java @@ -1180,7 +1180,10 @@ private void getBranchForSection(MetrixSection section, List secttype, List sectnumq, List sectcoef) { Identifiable identifiable = metrixNetwork.getNetwork().getIdentifiable(branch.getKey()); if (identifiable != null) { - if (identifiable instanceof Line || identifiable instanceof TwoWindingsTransformer) { + if (identifiable instanceof Line || + identifiable instanceof TwoWindingsTransformer || + identifiable instanceof DanglingLine || + identifiable instanceof TieLine) { secttype.add(ElementType.BRANCH.getType()); } else if (identifiable instanceof HvdcLine) { secttype.add(ElementType.HVDC.getType()); From 1ab38678b368019f69f2d79a5f6c35a1c3224e37 Mon Sep 17 00:00:00 2001 From: Damien Jeandemange Date: Fri, 15 Nov 2024 09:00:36 +0100 Subject: [PATCH 16/19] clean Signed-off-by: Damien Jeandemange --- .../metrix/integration/MetrixNetwork.java | 6 +- .../metrix/integration/MetrixNetworkTest.java | 130 +++++++++--------- 2 files changed, 68 insertions(+), 68 deletions(-) diff --git a/metrix-integration/src/main/java/com/powsybl/metrix/integration/MetrixNetwork.java b/metrix-integration/src/main/java/com/powsybl/metrix/integration/MetrixNetwork.java index 65dd48fb..aa95bf27 100755 --- a/metrix-integration/src/main/java/com/powsybl/metrix/integration/MetrixNetwork.java +++ b/metrix-integration/src/main/java/com/powsybl/metrix/integration/MetrixNetwork.java @@ -433,7 +433,7 @@ private void createTransformerList() { createThreeWindingsTransformersList(); } - private void createDanglingLineList() { + private void createUnpairedDanglingLineList() { int nbNok = 0; for (DanglingLine dl : network.getDanglingLines()) { if (!dl.isPaired()) { @@ -573,7 +573,7 @@ private void init() { createGeneratorList(); createLineList(); createTransformerList(); - createDanglingLineList(); + createUnpairedDanglingLineList(); createSwitchList(); createLoadList(); createHvdcLineList(); @@ -727,7 +727,7 @@ private void addElementToRetainedBreakersList(Switch sw, Terminal terminal, bool } } default -> - throw new PowsyblException("Unexpected connectable type : " + terminal.getConnectable().getType()); + throw new PowsyblException("Unexpected connectable type : " + terminal.getConnectable().getType()); } } diff --git a/metrix-integration/src/test/java/com/powsybl/metrix/integration/MetrixNetworkTest.java b/metrix-integration/src/test/java/com/powsybl/metrix/integration/MetrixNetworkTest.java index e7776a70..8525b4e4 100644 --- a/metrix-integration/src/test/java/com/powsybl/metrix/integration/MetrixNetworkTest.java +++ b/metrix-integration/src/test/java/com/powsybl/metrix/integration/MetrixNetworkTest.java @@ -106,7 +106,7 @@ void testNetworkElementsLists() { void testNetworkBusBreakerElementsLists() { // Mapped switches Set mappedSwitches = Set.of("S1VL2_GH2_BREAKER", "S3VL1_LINES3S4_BREAKER", "S1VL1_LD1_BREAKER", - "S1VL3_DL_BREAKER", "S1VL2_BBS1_BBS3", "S1VL3_3WT_BREAKER"); + "S1VL3_DL_BREAKER", "S1VL2_BBS1_BBS3", "S1VL3_3WT_BREAKER"); // Network Network network = createBusBreakerNetwork(mappedSwitches); @@ -120,8 +120,8 @@ void testNetworkBusBreakerElementsLists() { // Contingencies Contingency a = new Contingency("a", Collections.singletonList(new BranchContingency("LINE_S2S3"))); Contingency b = new Contingency("b", Arrays.asList( - new BranchContingency("LINE_S2S3"), - new BranchContingency("LINE_S3S4"))); + new BranchContingency("LINE_S2S3"), + new BranchContingency("LINE_S3S4"))); // Create a contingency provider ContingenciesProvider contingenciesProvider = networkLocal -> { @@ -170,17 +170,17 @@ private Network createNetwork() { // We add a voltage level, a ThreeWindingsTransformer and a DanglingLine VoltageLevel s1vl3 = network.getSubstation("S1").newVoltageLevel() - .setId("S1VL3") - .setNominalV(225.0) - .setLowVoltageLimit(220.0) - .setHighVoltageLimit(240.0) - .setTopologyKind(TopologyKind.NODE_BREAKER) - .add(); + .setId("S1VL3") + .setNominalV(225.0) + .setLowVoltageLimit(220.0) + .setHighVoltageLimit(240.0) + .setTopologyKind(TopologyKind.NODE_BREAKER) + .add(); s1vl3.getNodeBreakerView().newBusbarSection() - .setId("S1VL3_BBS") - .setName("S1VL3_BBS") - .setNode(0) - .add(); + .setId("S1VL3_BBS") + .setName("S1VL3_BBS") + .setNode(0) + .add(); createSwitch(s1vl3, "S1VL3_BBS_3WT_DISCONNECTOR", SwitchKind.DISCONNECTOR, 0, 1); createSwitch(s1vl3, "S1VL3_3WT_BREAKER", SwitchKind.BREAKER, 1, 2); @@ -189,57 +189,57 @@ private Network createNetwork() { createSwitch(network.getVoltageLevel("S1VL2"), "S1VL2_BBS_3WT_DISCONNECTOR", SwitchKind.DISCONNECTOR, 0, 40); createSwitch(network.getVoltageLevel("S1VL2"), "S1VL2_3WT_BREAKER", SwitchKind.BREAKER, 40, 41); network.getSubstation("S1").newThreeWindingsTransformer() - .setId("3WT") - .setRatedU0(132.0) - .newLeg1() - .setR(17.424) - .setX(1.7424) - .setG(0.00573921028466483) - .setB(0.000573921028466483) - .setRatedU(132.0) - .setVoltageLevel(s1vl3.getId()) - .setNode(2) - .add() - .newLeg2() - .setR(1.089) - .setX(0.1089) - .setG(0.0) - .setB(0.0) - .setRatedU(33.0) - .setVoltageLevel("S1VL1") - .setNode(11) - .add() - .newLeg3() - .setR(0.121) - .setX(0.0121) - .setG(0.0) - .setB(0.0) - .setRatedU(11.0) - .setVoltageLevel("S1VL2") - .setNode(41) - .add() - .add(); + .setId("3WT") + .setRatedU0(132.0) + .newLeg1() + .setR(17.424) + .setX(1.7424) + .setG(0.00573921028466483) + .setB(0.000573921028466483) + .setRatedU(132.0) + .setVoltageLevel(s1vl3.getId()) + .setNode(2) + .add() + .newLeg2() + .setR(1.089) + .setX(0.1089) + .setG(0.0) + .setB(0.0) + .setRatedU(33.0) + .setVoltageLevel("S1VL1") + .setNode(11) + .add() + .newLeg3() + .setR(0.121) + .setX(0.0121) + .setG(0.0) + .setB(0.0) + .setRatedU(11.0) + .setVoltageLevel("S1VL2") + .setNode(41) + .add() + .add(); // Dangling line createSwitch(s1vl3, "S1VL3_BBS_DL_DISCONNECTOR", SwitchKind.DISCONNECTOR, 0, 3); createSwitch(s1vl3, "S1VL3_DL_BREAKER", SwitchKind.BREAKER, 4, 3); s1vl3.newDanglingLine() - .setId("DL") - .setR(10.0) - .setX(1.0) - .setB(10e-6) - .setG(10e-5) - .setP0(50.0) - .setQ0(30.0) - .setNode(4) - .add(); + .setId("DL") + .setR(10.0) + .setX(1.0) + .setB(10e-6) + .setG(10e-5) + .setP0(50.0) + .setQ0(30.0) + .setNode(4) + .add(); // We add another bus bar section and link it to the others with a breaker network.getVoltageLevel("S1VL2").getNodeBreakerView().newBusbarSection() - .setId("S1VL2_BBS3") - .setName("S1VL2_BBS3") - .setNode(90) - .add(); + .setId("S1VL2_BBS3") + .setName("S1VL2_BBS3") + .setNode(90) + .add(); createSwitch(network.getVoltageLevel("S1VL2"), "S1VL2_BBS1_DISCONNECTOR", SwitchKind.DISCONNECTOR, 0, 91); createSwitch(network.getVoltageLevel("S1VL2"), "S1VL2_BBS3_DISCONNECTOR", SwitchKind.DISCONNECTOR, 92, 90); createSwitch(network.getVoltageLevel("S1VL2"), "S1VL2_BBS1_BBS3", SwitchKind.BREAKER, 91, 92); @@ -294,14 +294,14 @@ private Network createNetwork() { private static void createSwitch(VoltageLevel vl, String id, SwitchKind kind, int node1, int node2) { vl.getNodeBreakerView().newSwitch() - .setId(id) - .setName(id) - .setKind(kind) - .setRetained(kind.equals(SwitchKind.BREAKER)) - .setOpen(false) - .setFictitious(false) - .setNode1(node1) - .setNode2(node2) - .add(); + .setId(id) + .setName(id) + .setKind(kind) + .setRetained(kind.equals(SwitchKind.BREAKER)) + .setOpen(false) + .setFictitious(false) + .setNode1(node1) + .setNode2(node2) + .add(); } } From 7ce32a1df79c8f6035bbc8eb5ebd42ffcdcee9f8 Mon Sep 17 00:00:00 2001 From: Damien Jeandemange Date: Fri, 15 Nov 2024 09:04:54 +0100 Subject: [PATCH 17/19] clean Signed-off-by: Damien Jeandemange --- .../com/powsybl/metrix/integration/MetrixNetworkTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/metrix-integration/src/test/java/com/powsybl/metrix/integration/MetrixNetworkTest.java b/metrix-integration/src/test/java/com/powsybl/metrix/integration/MetrixNetworkTest.java index 8525b4e4..fd9d29c3 100644 --- a/metrix-integration/src/test/java/com/powsybl/metrix/integration/MetrixNetworkTest.java +++ b/metrix-integration/src/test/java/com/powsybl/metrix/integration/MetrixNetworkTest.java @@ -64,8 +64,8 @@ void testNetworkElementsLists() { // Contingencies Contingency a = new Contingency("a", Collections.singletonList(new BranchContingency("LINE_S2S3"))); Contingency b = new Contingency("b", Arrays.asList( - new BranchContingency("LINE_S2S3"), - new BranchContingency("LINE_S3S4"))); + new BranchContingency("LINE_S2S3"), + new BranchContingency("LINE_S3S4"))); // Create a contingency provider ContingenciesProvider contingenciesProvider = networkLocal -> { From 6c4e5aad0282350e844d43c071a06072fb3c2f35 Mon Sep 17 00:00:00 2001 From: Damien Jeandemange Date: Fri, 15 Nov 2024 10:40:41 +0100 Subject: [PATCH 18/19] test Signed-off-by: Damien Jeandemange --- .../metrix/MetrixInputAnalysis.java | 3 ++ .../MetrixContingencyAnalysisTest.java | 14 +++++----- .../metrix/integration/MetrixNetworkTest.java | 28 ++++++++++++------- 3 files changed, 28 insertions(+), 17 deletions(-) diff --git a/metrix-integration/src/main/java/com/powsybl/metrix/integration/metrix/MetrixInputAnalysis.java b/metrix-integration/src/main/java/com/powsybl/metrix/integration/metrix/MetrixInputAnalysis.java index 02ee7a2e..f0d5a82e 100644 --- a/metrix-integration/src/main/java/com/powsybl/metrix/integration/metrix/MetrixInputAnalysis.java +++ b/metrix-integration/src/main/java/com/powsybl/metrix/integration/metrix/MetrixInputAnalysis.java @@ -160,6 +160,9 @@ private static boolean isValidContingencyTypeForIdentifiable(IdentifiableType id if (elementType == ContingencyElementType.TWO_WINDINGS_TRANSFORMER && identifiableType == IdentifiableType.TWO_WINDINGS_TRANSFORMER) { return true; } + if (elementType == ContingencyElementType.TIE_LINE && identifiableType == IdentifiableType.TIE_LINE) { + return true; + } if (elementType == ContingencyElementType.BRANCH && (identifiableType == IdentifiableType.LINE || identifiableType == IdentifiableType.TWO_WINDINGS_TRANSFORMER || identifiableType == IdentifiableType.TIE_LINE)) { return true; } diff --git a/metrix-integration/src/test/java/com/powsybl/metrix/integration/MetrixContingencyAnalysisTest.java b/metrix-integration/src/test/java/com/powsybl/metrix/integration/MetrixContingencyAnalysisTest.java index 3c4fbeee..dbdb93c9 100644 --- a/metrix-integration/src/test/java/com/powsybl/metrix/integration/MetrixContingencyAnalysisTest.java +++ b/metrix-integration/src/test/java/com/powsybl/metrix/integration/MetrixContingencyAnalysisTest.java @@ -7,7 +7,6 @@ */ package com.powsybl.metrix.integration; -import com.google.common.collect.ImmutableList; import com.powsybl.contingency.*; import com.powsybl.iidm.network.Network; import com.powsybl.iidm.serde.NetworkSerDe; @@ -20,6 +19,7 @@ import java.io.StringReader; import java.io.StringWriter; import java.util.Collections; +import java.util.List; import java.util.ResourceBundle; import static com.powsybl.metrix.mapping.LogDslLoader.LogType.WARNING; @@ -28,7 +28,7 @@ /** * @author Marianne Funfrock {@literal } */ -public class MetrixContingencyAnalysisTest { +class MetrixContingencyAnalysisTest { private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle("lang.MetrixAnalysis"); @@ -74,7 +74,7 @@ private void metrixDslDataContingencyAnalysisTest(MetrixDslData metrixDslData, S } private void loadContingencyTest(Contingency contingency, String expected) throws IOException { - ContingenciesProvider provider = network -> ImmutableList.of(contingency); + ContingenciesProvider provider = net -> List.of(contingency); StringWriter writer = new StringWriter(); try (BufferedWriter bufferedWriter = new BufferedWriter(writer)) { @@ -129,7 +129,7 @@ void loadContingencyWithWrongTypeForIdentifiableTest() throws IOException { @Test void metrixDslDataLoadContingencyAnalysisTest() throws IOException { MetrixDslData metrixDslData = new MetrixDslData(); - metrixDslData.addCurativeLoad("loadId", 10, ImmutableList.of("ctyForLoadId")); + metrixDslData.addCurativeLoad("loadId", 10, List.of("ctyForLoadId")); String expected = getWarningInvalidMetrixDslDataContingency(" - loadId", "load", "ctyForLoadId"); metrixDslDataContingencyAnalysisTest(metrixDslData, expected); } @@ -137,7 +137,7 @@ void metrixDslDataLoadContingencyAnalysisTest() throws IOException { @Test void metrixDslDataPhaseTapChangerContingencyAnalysisTest() throws IOException { MetrixDslData metrixDslData = new MetrixDslData(); - metrixDslData.addPtc("phaseTapChangerId", MetrixPtcControlType.OPTIMIZED_ANGLE_CONTROL, ImmutableList.of("ctyForPhaseTapChangerId")); + metrixDslData.addPtc("phaseTapChangerId", MetrixPtcControlType.OPTIMIZED_ANGLE_CONTROL, List.of("ctyForPhaseTapChangerId")); String expected = getWarningInvalidMetrixDslDataContingency(" - phaseTapChangerId", "phaseTapChanger", "ctyForPhaseTapChangerId"); metrixDslDataContingencyAnalysisTest(metrixDslData, expected); } @@ -145,7 +145,7 @@ void metrixDslDataPhaseTapChangerContingencyAnalysisTest() throws IOException { @Test void metrixDslDataGeneratorContingencyAnalysisTest() throws IOException { MetrixDslData metrixDslData = new MetrixDslData(); - metrixDslData.addGeneratorForRedispatching("generatorId", ImmutableList.of("ctyForGeneratorId")); + metrixDslData.addGeneratorForRedispatching("generatorId", List.of("ctyForGeneratorId")); String expected = getWarningInvalidMetrixDslDataContingency(" - generatorId", "generator", "ctyForGeneratorId"); metrixDslDataContingencyAnalysisTest(metrixDslData, expected); } @@ -153,7 +153,7 @@ void metrixDslDataGeneratorContingencyAnalysisTest() throws IOException { @Test void metrixDslDataHvdcLineContingencyAnalysisTest() throws IOException { MetrixDslData metrixDslData = new MetrixDslData(); - metrixDslData.addHvdc("hvdcLineId", MetrixHvdcControlType.OPTIMIZED, ImmutableList.of("ctyForHvdcLineId")); + metrixDslData.addHvdc("hvdcLineId", MetrixHvdcControlType.OPTIMIZED, List.of("ctyForHvdcLineId")); String expected = getWarningInvalidMetrixDslDataContingency(" - hvdcLineId", "hvdcLine", "ctyForHvdcLineId"); metrixDslDataContingencyAnalysisTest(metrixDslData, expected); } diff --git a/metrix-integration/src/test/java/com/powsybl/metrix/integration/MetrixNetworkTest.java b/metrix-integration/src/test/java/com/powsybl/metrix/integration/MetrixNetworkTest.java index fd9d29c3..5423d5b1 100644 --- a/metrix-integration/src/test/java/com/powsybl/metrix/integration/MetrixNetworkTest.java +++ b/metrix-integration/src/test/java/com/powsybl/metrix/integration/MetrixNetworkTest.java @@ -1,10 +1,15 @@ +/* + * Copyright (c) 2024, RTE (http://www.rte-france.com) + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * SPDX-License-Identifier: MPL-2.0 + */ package com.powsybl.metrix.integration; import com.google.common.jimfs.Configuration; import com.google.common.jimfs.Jimfs; -import com.powsybl.contingency.BranchContingency; -import com.powsybl.contingency.ContingenciesProvider; -import com.powsybl.contingency.Contingency; +import com.powsybl.contingency.*; import com.powsybl.iidm.network.*; import com.powsybl.iidm.network.test.FourSubstationsNodeBreakerFactory; import com.powsybl.iidm.serde.ExportOptions; @@ -17,7 +22,6 @@ import java.io.IOException; import java.nio.file.FileSystem; import java.nio.file.Path; -import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Set; @@ -63,7 +67,7 @@ void testNetworkElementsLists() { // Contingencies Contingency a = new Contingency("a", Collections.singletonList(new BranchContingency("LINE_S2S3"))); - Contingency b = new Contingency("b", Arrays.asList( + Contingency b = new Contingency("b", List.of( new BranchContingency("LINE_S2S3"), new BranchContingency("LINE_S3S4"))); @@ -71,7 +75,7 @@ void testNetworkElementsLists() { ContingenciesProvider contingenciesProvider = networkLocal -> { a.addExtension(Probability.class, new Probability(0.002d, null)); b.addExtension(Probability.class, new Probability(null, "variable_ts1")); - return Arrays.asList(a, b); + return List.of(a, b); }; // Initialize the MetrixNetwork @@ -119,15 +123,19 @@ void testNetworkBusBreakerElementsLists() { // Contingencies Contingency a = new Contingency("a", Collections.singletonList(new BranchContingency("LINE_S2S3"))); - Contingency b = new Contingency("b", Arrays.asList( + Contingency b = new Contingency("b", List.of( new BranchContingency("LINE_S2S3"), new BranchContingency("LINE_S3S4"))); + Contingency c = new Contingency("c", Collections.singletonList(new DanglingLineContingency("DL"))); + Contingency d = new Contingency("d", Collections.singletonList(new TieLineContingency("TL"))); // Create a contingency provider ContingenciesProvider contingenciesProvider = networkLocal -> { a.addExtension(Probability.class, new Probability(0.002d, null)); - b.addExtension(Probability.class, new Probability(null, "variable_ts1")); - return Arrays.asList(a, b); + b.addExtension(Probability.class, new Probability(0.002d, null)); + c.addExtension(Probability.class, new Probability(0.002d, null)); + d.addExtension(Probability.class, new Probability(0.002d, null)); + return List.of(a, b, c, d); }; // Initialize the MetrixNetwork @@ -146,7 +154,7 @@ void testNetworkBusBreakerElementsLists() { assertThat(metrixNetwork.getTieLineList()).containsExactlyInAnyOrderElementsOf(network.getTieLines()); assertThat(metrixNetwork.getHvdcLineList()).containsExactlyInAnyOrderElementsOf(network.getHvdcLines()); assertThat(metrixNetwork.getBusList()).containsExactlyInAnyOrderElementsOf(network.getBusBreakerView().getBuses()); - assertThat(metrixNetwork.getContingencyList()).containsExactlyInAnyOrderElementsOf(List.of(a, b)); + assertThat(metrixNetwork.getContingencyList()).containsExactlyInAnyOrderElementsOf(List.of(a, b, c, d)); } private Network createBusBreakerNetwork(Set mappedSwitches) { From d72e43ad14500564184e49df0e37a8c6d05c3eec Mon Sep 17 00:00:00 2001 From: Nicolas Rol Date: Mon, 16 Dec 2024 11:41:37 +0100 Subject: [PATCH 19/19] extract method to reduce complexity Signed-off-by: Nicolas Rol --- .../dataGenerator/MetrixInputData.java | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/metrix-integration/src/main/java/com/powsybl/metrix/integration/dataGenerator/MetrixInputData.java b/metrix-integration/src/main/java/com/powsybl/metrix/integration/dataGenerator/MetrixInputData.java index 5eccfc8c..783ec777 100755 --- a/metrix-integration/src/main/java/com/powsybl/metrix/integration/dataGenerator/MetrixInputData.java +++ b/metrix-integration/src/main/java/com/powsybl/metrix/integration/dataGenerator/MetrixInputData.java @@ -615,6 +615,21 @@ private void writeLoads(MetrixDie die) { preventiveLoadsList = new HashSet<>(); } + writeLoadsAndUnpairedDanglingLines(tnneucel, esafiact, tnnomnoe, tnvapal1, tnvacou1, preventiveLoadsList); + + die.setStringArray("TNNOMNOE", tnnomnoe); + die.setIntArray("TNNEUCEL", tnneucel); + die.setFloatArray("ESAFIACT", esafiact); + + if (!preventiveLoadsList.isEmpty()) { + die.setIntArray("TNVAPAL1", tnvapal1); + die.setFloatArray("TNVACOU1", tnvacou1); + } + } + + private void writeLoadsAndUnpairedDanglingLines(int[] tnneucel, float[] esafiact, String[] tnnomnoe, + int[] tnvapal1, float[] tnvacou1, + Set preventiveLoadsList) { int index = 0; for (Load load : metrixNetwork.getLoadList()) { int busIndex = metrixNetwork.getIndex(load.getTerminal().getBusBreakerView().getBus()); @@ -634,22 +649,13 @@ private void writeLoads(MetrixDie die) { int busIndex = metrixNetwork.getUnpairedDanglingLineBusIndex(udl); float p0 = (float) udl.getP0(); if (udl.getGeneration() != null) { - // We do not greate a generator, because we do not want the DL generation to be used when balancing Gen/Load. + // We do not create a generator, because we do not want the DL generation to be used when balancing Gen/Load. // Therefore, we just remove the generation part from the load. p0 -= (float) udl.getGeneration().getTargetP(); } writeLoad(tnneucel, esafiact, tnnomnoe, index, busIndex, p0, udl.getId() + MetrixNetwork.getUnpairedDanglingLineLoadId(udl)); index++; } - - die.setStringArray("TNNOMNOE", tnnomnoe); - die.setIntArray("TNNEUCEL", tnneucel); - die.setFloatArray("ESAFIACT", esafiact); - - if (!preventiveLoadsList.isEmpty()) { - die.setIntArray("TNVAPAL1", tnvapal1); - die.setFloatArray("TNVACOU1", tnvacou1); - } } private void writeGenerators(MetrixDie die) {