diff --git a/cgmes/cgmes-conversion/src/test/java/com/powsybl/cgmes/conversion/test/OperationalLimitConversionTest.java b/cgmes/cgmes-conversion/src/test/java/com/powsybl/cgmes/conversion/test/OperationalLimitConversionTest.java index 8a2a372029b..6b0c3284825 100644 --- a/cgmes/cgmes-conversion/src/test/java/com/powsybl/cgmes/conversion/test/OperationalLimitConversionTest.java +++ b/cgmes/cgmes-conversion/src/test/java/com/powsybl/cgmes/conversion/test/OperationalLimitConversionTest.java @@ -253,4 +253,22 @@ void missingLimitsTest() { assertNull(limits2.getTemporaryLimit(1200)); } + @Test + void limitsCim100Test() { + // CGMES network: + // An ACLineSegment ACL with CurrentLimit and ApparentPowerLimit (each time patl and tatl) on side 1. + // IIDM network: + // Limits are imported smoothly. + Network network = readCgmesResources(DIR, "limits_cim100.xml"); + + // Loading limits have been imported smoothly. + Line line = network.getLine("ACL"); + assertTrue(line.getCurrentLimits1().isPresent()); + assertEquals(100.0, line.getCurrentLimits1().get().getPermanentLimit()); + assertEquals(200.0, line.getCurrentLimits1().get().getTemporaryLimit(600).getValue()); + assertTrue(line.getApparentPowerLimits1().isPresent()); + assertEquals(102.0, line.getApparentPowerLimits1().get().getPermanentLimit()); + assertEquals(202.0, line.getApparentPowerLimits1().get().getTemporaryLimit(600).getValue()); + } + } diff --git a/cgmes/cgmes-conversion/src/test/java/com/powsybl/cgmes/conversion/test/conformity/Cgmes3ConversionTest.java b/cgmes/cgmes-conversion/src/test/java/com/powsybl/cgmes/conversion/test/conformity/Cgmes3ConversionTest.java index c559cf54255..a51b2128c11 100644 --- a/cgmes/cgmes-conversion/src/test/java/com/powsybl/cgmes/conversion/test/conformity/Cgmes3ConversionTest.java +++ b/cgmes/cgmes-conversion/src/test/java/com/powsybl/cgmes/conversion/test/conformity/Cgmes3ConversionTest.java @@ -19,7 +19,6 @@ import com.powsybl.commons.datasource.ReadOnlyDataSource; import com.powsybl.commons.datasource.ReadOnlyMemDataSource; import com.powsybl.iidm.network.*; -import com.powsybl.iidm.network.LoadingLimits.TemporaryLimit; import com.powsybl.triplestore.api.TripleStoreFactory; import org.junit.jupiter.api.Test; @@ -71,39 +70,6 @@ void microGridConvertBoundary() throws IOException { t.testConversion(expected, Cgmes3Catalog.microGrid()); } - @Test - void microGridOperationalLimits() { - Network n = networkModel(Cgmes3Catalog.microGrid(), new Conversion.Config()); - - Line ln = n.getLine("ffbabc27-1ccd-4fdc-b037-e341706c8d29"); - assertEquals(1312.0, ln.getCurrentLimits1().map(LoadingLimits::getPermanentLimit).orElse(0.0), 0.0); - assertEquals(1312.0, ln.getCurrentLimits2().map(LoadingLimits::getPermanentLimit).orElse(0.0), 0.0); - - assertEquals(1, (int) ln.getCurrentLimits1().map(lim -> lim.getTemporaryLimits().size()).orElse(-1)); - TemporaryLimit lntl1 = ln.getCurrentLimits1().flatMap(lim -> lim.getTemporaryLimits().stream().findFirst()).orElseThrow(IllegalStateException::new); - assertEquals(500.0, lntl1.getValue(), 0.0); - assertEquals(10, lntl1.getAcceptableDuration()); - - assertEquals(1, (int) ln.getCurrentLimits2().map(lim -> lim.getTemporaryLimits().size()).orElse(-1)); - TemporaryLimit lntl2 = ln.getCurrentLimits2().flatMap(lim -> lim.getTemporaryLimits().stream().findFirst()).orElseThrow(IllegalStateException::new); - assertEquals(500.0, lntl2.getValue(), 0.0); - assertEquals(10, lntl2.getAcceptableDuration()); - - TieLine tln = n.getTieLine("dad02278-bd25-476f-8f58-dbe44be72586 + ed0c5d75-4a54-43c8-b782-b20d7431630b"); - assertEquals(1371.0, tln.getDanglingLine1().getCurrentLimits().map(LoadingLimits::getPermanentLimit).orElse(0.0), 0.0); - assertEquals(1226.0, tln.getDanglingLine2().getCurrentLimits().map(LoadingLimits::getPermanentLimit).orElse(0.0), 0.0); - - assertEquals(1, (int) tln.getDanglingLine1().getCurrentLimits().map(lim -> lim.getTemporaryLimits().size()).orElse(-1)); - TemporaryLimit tlntl1 = tln.getDanglingLine1().getCurrentLimits().flatMap(lim -> lim.getTemporaryLimits().stream().findFirst()).orElseThrow(IllegalStateException::new); - assertEquals(500.0, tlntl1.getValue(), 0.0); - assertEquals(10, tlntl1.getAcceptableDuration()); - - assertEquals(1, (int) tln.getDanglingLine2().getCurrentLimits().map(lim -> lim.getTemporaryLimits().size()).orElse(-1)); - TemporaryLimit tlntl2 = ln.getCurrentLimits2().flatMap(lim -> lim.getTemporaryLimits().stream().findFirst()).orElseThrow(IllegalStateException::new); - assertEquals(500.0, tlntl2.getValue(), 0.0); - assertEquals(10, tlntl2.getAcceptableDuration()); - } - @Test void microGridWithAndWithoutTpSv() { Properties importParams = new Properties(); @@ -148,27 +114,6 @@ void miniGridConvertBoundary() throws IOException { t.testConversion(expected, Cgmes3Catalog.miniGrid()); } - @Test - void miniGridOperationalLimits() { - Network n = networkModel(Cgmes3Catalog.miniGrid(), new Conversion.Config()); - - TwoWindingsTransformer tw2t = n.getTwoWindingsTransformer("813365c3-5be7-4ef0-a0a7-abd1ae6dc174"); - assertEquals(753.0659, tw2t.getCurrentLimits1().map(LoadingLimits::getPermanentLimit).orElse(0.0), 0.0); - assertEquals(4123.933, tw2t.getCurrentLimits2().map(LoadingLimits::getPermanentLimit).orElse(0.0), 0.0); - - assertEquals(0, (int) tw2t.getCurrentLimits1().map(l -> l.getTemporaryLimits().size()).orElse(-1)); - assertEquals(0, (int) tw2t.getCurrentLimits2().map(l -> l.getTemporaryLimits().size()).orElse(-1)); - - ThreeWindingsTransformer tw3t = n.getThreeWindingsTransformer("411b5401-0a43-404a-acb4-05c3d7d0c95c"); - assertEquals(505.1817, tw3t.getLeg1().getCurrentLimits().map(LoadingLimits::getPermanentLimit).orElse(0.0), 0.0); - assertEquals(1683.939, tw3t.getLeg2().getCurrentLimits().map(LoadingLimits::getPermanentLimit).orElse(0.0), 0.0); - assertEquals(962.2509, tw3t.getLeg3().getCurrentLimits().map(LoadingLimits::getPermanentLimit).orElse(0.0), 0.0); - - assertEquals(0, (int) tw3t.getLeg1().getCurrentLimits().map(l -> l.getTemporaryLimits().size()).orElse(-1)); - assertEquals(0, (int) tw3t.getLeg2().getCurrentLimits().map(l -> l.getTemporaryLimits().size()).orElse(-1)); - assertEquals(0, (int) tw3t.getLeg3().getCurrentLimits().map(l -> l.getTemporaryLimits().size()).orElse(-1)); - } - @Test void miniGridRatedS() { Network n = networkModel(Cgmes3Catalog.miniGrid(), new Conversion.Config()); @@ -232,25 +177,6 @@ void smallGridConvertBoundary() throws IOException { t.testConversion(expected, Cgmes3Catalog.smallGrid()); } - @Test - void smallGridOperationalLimits() { - Network n = networkModel(Cgmes3Catalog.smallGrid(), new Conversion.Config()); - - Line ln = n.getLine("04658820-c766-11e1-8775-005056c00008"); - assertEquals(1000.0, ln.getCurrentLimits1().map(LoadingLimits::getPermanentLimit).orElse(0.0), 0.0); - assertEquals(1000.0, ln.getCurrentLimits2().map(LoadingLimits::getPermanentLimit).orElse(0.0), 0.0); - - assertEquals(1, (int) ln.getCurrentLimits1().map(l -> l.getTemporaryLimits().size()).orElse(-1)); - TemporaryLimit lntl1 = ln.getCurrentLimits1().flatMap(l -> l.getTemporaryLimits().stream().findFirst()).orElseThrow(IllegalStateException::new); - assertEquals(500.0, lntl1.getValue(), 0.0); - assertEquals(900, lntl1.getAcceptableDuration()); - - assertEquals(1, (int) ln.getCurrentLimits2().map(l -> l.getTemporaryLimits().size()).orElse(-1)); - TemporaryLimit lntl2 = ln.getCurrentLimits2().flatMap(l -> l.getTemporaryLimits().stream().findFirst()).orElseThrow(IllegalStateException::new); - assertEquals(500.0, lntl2.getValue(), 0.0); - assertEquals(900, lntl2.getAcceptableDuration()); - } - @Test void smallGridWithAndWithoutTpSv() { Properties importParams = new Properties(); @@ -314,25 +240,6 @@ void svedalaConvertBoundary() throws IOException { t.testConversion(expected, Cgmes3Catalog.svedala()); } - @Test - void svedalaOperationalLimits() { - Network n = networkModel(Cgmes3Catalog.svedala(), new Conversion.Config()); - - Line ln = n.getLine("c6278b38-b777-4ad9-b395-50c4009afdff"); - assertEquals(2970.0, ln.getCurrentLimits1().map(LoadingLimits::getPermanentLimit).orElse(0.0), 0.0); - assertEquals(2970.0, ln.getCurrentLimits2().map(LoadingLimits::getPermanentLimit).orElse(0.0), 0.0); - - assertEquals(1, (int) ln.getCurrentLimits1().map(l -> l.getTemporaryLimits().size()).orElse(-1)); - TemporaryLimit lntl1 = ln.getCurrentLimits1().flatMap(l -> l.getTemporaryLimits().stream().findFirst()).orElseThrow(IllegalStateException::new); - assertEquals(500.0, lntl1.getValue(), 0.0); - assertEquals(600, lntl1.getAcceptableDuration()); - - assertEquals(1, (int) ln.getCurrentLimits2().map(l -> l.getTemporaryLimits().size()).orElse(-1)); - TemporaryLimit lntl2 = ln.getCurrentLimits2().flatMap(l -> l.getTemporaryLimits().stream().findFirst()).orElseThrow(IllegalStateException::new); - assertEquals(500.0, lntl2.getValue(), 0.0); - assertEquals(600, lntl2.getAcceptableDuration()); - } - @Test void svedalaWithAndWithoutTpSv() { Properties importParams = new Properties(); diff --git a/cgmes/cgmes-conversion/src/test/resources/issues/operational-limits/limits_cim100.xml b/cgmes/cgmes-conversion/src/test/resources/issues/operational-limits/limits_cim100.xml new file mode 100644 index 00000000000..360258dcb0e --- /dev/null +++ b/cgmes/cgmes-conversion/src/test/resources/issues/operational-limits/limits_cim100.xml @@ -0,0 +1,124 @@ + + + 2021-03-01T23:00:00Z + 2021-03-02T10:22:58Z + Limits + 001 + http://iec.ch/TC57/ns/CIM/CoreEquipment-EU/3.0 + http://iec.ch/TC57/ns/CIM/Operation-EU/3.0 + powsybl.org + + + Geographical region + + + Subgeographical region + + + + Substation 1 + + + + Voltage level 1 + + + + + Node 1 + + + + Substation 2 + + + + Voltage level 2 + + + + + Node 2 + + + + AC line segment + 0 + 0 + 0 + 0 + 0.1 + 0.1 + 1 + 0.1 + + + + + Terminal ACL 1 + 1 + + + + + Terminal ACL 2 + 2 + + + + + Limit set + + + + Current limit + 100 + + + + + Current limit + 200 + + + + + Active power limit + 101 + + + + + Active power limit + 201 + + + + + Apparent power limit + 102 + + + + + Apparent power limit + 202 + + + + + + + PATL + + + + + Tatl 600 + 600 + + + 100 kV + 100 + + diff --git a/cgmes/cgmes-model/src/main/resources/CIM100.sparql b/cgmes/cgmes-model/src/main/resources/CIM100.sparql index ba668498e7a..362132e60b1 100644 --- a/cgmes/cgmes-model/src/main/resources/CIM100.sparql +++ b/cgmes/cgmes-model/src/main/resources/CIM100.sparql @@ -114,13 +114,11 @@ SELECT * WHERE { { GRAPH ?graph { ?OperationalLimit - cim:OperationalLimit.OperationalLimitType ?OperationalLimitType ; - cim:OperationalLimit.OperationalLimitSet ?OperationalLimitSet ; + a ?OperationalLimitSubclass ; cim:IdentifiedObject.name ?name ; - a ?OperationalLimitSubclass . - ?OperationalLimitType - a cim:OperationalLimitType ; - cim:IdentifiedObject.name ?operationalLimitTypeName . + cim:OperationalLimit.OperationalLimitSet ?OperationalLimitSet ; + cim:OperationalLimit.OperationalLimitType ?OperationalLimitType . + OPTIONAL { ?OperationalLimit eu:IdentifiedObject.shortName ?shortName } OPTIONAL { ?OperationalLimit cim:CurrentLimit.normalValue ?normalValue } OPTIONAL { ?OperationalLimit cim:ApparentPowerLimit.normalValue ?normalValue } OPTIONAL { ?OperationalLimit cim:VoltageLimit.normalValue ?normalValue } @@ -131,14 +129,17 @@ WHERE { ?OperationalLimitSet cim:OperationalLimitSet.Equipment ?Equipment . ?Equipment cim:Equipment.EquipmentContainer ?EquipmentContainer }} + ?OperationalLimitType + a cim:OperationalLimitType ; + cim:IdentifiedObject.name ?operationalLimitTypeName . OPTIONAL { ?OperationalLimitType cim:OperationalLimitType.direction ?direction } OPTIONAL { ?OperationalLimitType eu:OperationalLimitType.kind ?limitType } OPTIONAL { ?OperationalLimitType cim:OperationalLimitType.acceptableDuration ?acceptableDuration } }} -{ GRAPH ?graphSSH { - OPTIONAL {?OperationalLimit cim:CurrentLimit.value ?value } - OPTIONAL {?OperationalLimit cim:ApparentPowerLimit.value ?value } - OPTIONAL {?OperationalLimit cim:VoltageLimit.value ?value } +OPTIONAL { GRAPH ?graphSSH { + { ?OperationalLimit cim:CurrentLimit.value ?value } + { ?OperationalLimit cim:ApparentPowerLimit.value ?value } + { ?OperationalLimit cim:VoltageLimit.value ?value } }} }