Skip to content

Commit

Permalink
CGMES Import: allow voltage levels without names (#3252)
Browse files Browse the repository at this point in the history
* Import voltage levels without names
* Code review
* Code review: move cim14 test
* Use smaller and simpler cim files

Signed-off-by: Olivier Perrin <[email protected]>
Co-authored-by: Romain Courtier <[email protected]>
  • Loading branch information
olperr1 and rcourtier authored Dec 12, 2024
1 parent 77a758d commit fe577f8
Show file tree
Hide file tree
Showing 6 changed files with 132 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,16 @@ void voltageLevelsConnectedByOpenSwitchTest() {
assertEquals(1, network.getVoltageLevelCount());
assertNotNull(network.getVoltageLevel("VL_1"));
}

@Test
void voltageLevelWithoutName() {
// CGMES network:
// Voltage level of ID "VoltageLevel1" has no name
// IIDM network:
// The voltage level imported without name, and can be retrieved via its id
Network network = readCgmesResources(DIR, "vl_without_name.xml");
assertNotNull(network);
assertEquals(2, network.getVoltageLevelCount());
assertNotNull(network.getVoltageLevel("VoltageLevel"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
import java.util.Properties;
import java.util.stream.Collectors;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertNotNull;

/**
* @author Luma Zamarreño {@literal <zamarrenolm at aia.es>}
Expand Down Expand Up @@ -113,5 +113,20 @@ void condenser() {
assertTrue(c.isCondenser());
}

@Test
void voltageLevelWithoutName() {
// CGMES network:
// Voltage level of ID "VoltageLevel1" has no name
// IIDM network:
// The voltage level imported without name, and can be retrieved via its id

ReadOnlyDataSource ds = new ResourceDataSource("vl_without_name",
new ResourceSet("/cim14/", "vl_without_name.xml"));
Network network = new CgmesImport().importData(ds, new NetworkFactoryImpl(), new Properties());

assertNotNull(network);
assertNotNull(network.getVoltageLevel("VoltageLevel"));
}

private static ConversionTester tester;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:cim="http://iec.ch/TC57/2009/CIM-schema-cim14#">
<cim:GeographicalRegion rdf:ID="_GeographicalRegion">
<cim:IdentifiedObject.name>GeographicalRegion</cim:IdentifiedObject.name>
</cim:GeographicalRegion>
<cim:SubGeographicalRegion rdf:ID="_SubGeographicalRegion">
<cim:IdentifiedObject.name>SubGeographicalRegion</cim:IdentifiedObject.name>
<cim:SubGeographicalRegion.Region rdf:resource="#_GeographicalRegion"/>
</cim:SubGeographicalRegion>
<cim:Substation rdf:ID="_Substation">
<cim:IdentifiedObject.name>Substation</cim:IdentifiedObject.name>
<cim:Substation.Region rdf:resource="#_SubGeographicalRegion"/>
</cim:Substation>
<cim:VoltageLevel rdf:ID="_VoltageLevel">
<!-- _VoltageLevel has no name -->
<cim:VoltageLevel.BaseVoltage rdf:resource="#_BaseVoltage"/>
<cim:VoltageLevel.MemberOf_Substation rdf:resource="#_Substation"/>
</cim:VoltageLevel>
<cim:BaseVoltage rdf:ID="_BaseVoltage">
<cim:IdentifiedObject.name>11 kV</cim:IdentifiedObject.name>
<cim:BaseVoltage.nominalVoltage>11.0</cim:BaseVoltage.nominalVoltage>
</cim:BaseVoltage>
<cim:IEC61970CIMVersion rdf:ID="version">
<cim:IEC61970CIMVersion.version>IEC61970CIM14v02</cim:IEC61970CIMVersion.version>
<cim:IEC61970CIMVersion.date>2009-05-10</cim:IEC61970CIMVersion.date>
</cim:IEC61970CIMVersion>
</rdf:RDF>
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<rdf:RDF xmlns:cim="http://iec.ch/TC57/2013/CIM-schema-cim16#" xmlns:entsoe="http://entsoe.eu/CIM/SchemaExtension/3/1#" xmlns:md="http://iec.ch/TC57/61970-552/ModelDescription/1#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<md:FullModel rdf:about="urn:uuid:d400c631-75a0-4c30-8aed-832b0d282e73">
<md:Model.created>2024-03-28T11:00:00Z</md:Model.created>
<md:Model.scenarioTime>2024-03-28T11:00:00Z</md:Model.scenarioTime>
<md:Model.version>1</md:Model.version>
<md:Model.description>Line containers and fictitious voltage levels</md:Model.description>
<md:Model.modelingAuthoritySet>https://www.powsybl.org/</md:Model.modelingAuthoritySet>
<md:Model.profile>http://entsoe.eu/CIM/EquipmentCore/3/1</md:Model.profile>
<md:Model.profile>http://entsoe.eu/CIM/EquipmentOperation/3/1</md:Model.profile>
</md:FullModel>
<cim:GeographicalRegion rdf:ID="_GeographicalRegion">
<cim:IdentifiedObject.name>GeographicalRegion</cim:IdentifiedObject.name>
</cim:GeographicalRegion>
<cim:SubGeographicalRegion rdf:ID="_SubGeographicalRegion">
<cim:IdentifiedObject.name>SubGeographicalRegion</cim:IdentifiedObject.name>
<cim:SubGeographicalRegion.Region rdf:resource="#_GeographicalRegion" />
</cim:SubGeographicalRegion>
<cim:Substation rdf:ID="_Substation">
<cim:IdentifiedObject.name>Substation</cim:IdentifiedObject.name>
<cim:Substation.Region rdf:resource="#_SubGeographicalRegion" />
</cim:Substation>
<cim:VoltageLevel rdf:ID="_VoltageLevel">
<!-- _VoltageLevel has no name -->
<cim:VoltageLevel.BaseVoltage rdf:resource="#_BaseVoltage"/>
<cim:VoltageLevel.Substation rdf:resource="#_Substation"/>
</cim:VoltageLevel>
<cim:Bay rdf:ID="_Bay">
<cim:IdentifiedObject.name>Bay</cim:IdentifiedObject.name>
<cim:Bay.VoltageLevel rdf:resource="#_VoltageLevel"/>
</cim:Bay>
<cim:ConnectivityNode rdf:ID="_Node1">
<cim:IdentifiedObject.name>Node inside bay</cim:IdentifiedObject.name>
<cim:ConnectivityNode.ConnectivityNodeContainer rdf:resource="#_Bay"/>
</cim:ConnectivityNode>
<cim:Line rdf:ID="_LineContainer">
<cim:IdentifiedObject.name>Line Container</cim:IdentifiedObject.name>
</cim:Line>
<cim:ConnectivityNode rdf:ID="_Node2">
<cim:IdentifiedObject.name>Node inside line container</cim:IdentifiedObject.name>
<cim:ConnectivityNode.ConnectivityNodeContainer rdf:resource="#_LineContainer"/>
</cim:ConnectivityNode>
<cim:ACLineSegment rdf:ID="_ACLineSegment">
<cim:ACLineSegment.b0ch>0</cim:ACLineSegment.b0ch>
<cim:ACLineSegment.bch>0</cim:ACLineSegment.bch>
<cim:ACLineSegment.g0ch>0</cim:ACLineSegment.g0ch>
<cim:ACLineSegment.gch>0</cim:ACLineSegment.gch>
<cim:IdentifiedObject.name>Line segment</cim:IdentifiedObject.name>
<cim:ACLineSegment.r>0.1</cim:ACLineSegment.r>
<cim:ACLineSegment.r0>0.1</cim:ACLineSegment.r0>
<cim:ACLineSegment.shortCircuitEndTemperature>75</cim:ACLineSegment.shortCircuitEndTemperature>
<cim:ACLineSegment.x>1</cim:ACLineSegment.x>
<cim:ACLineSegment.x0>1</cim:ACLineSegment.x0>
<cim:ConductingEquipment.BaseVoltage rdf:resource="#_BaseVoltage"/>
<cim:Equipment.EquipmentContainer rdf:resource="#_LineContainer"/>
</cim:ACLineSegment>
<cim:Terminal rdf:ID="_ACLineSegment-T1">
<cim:IdentifiedObject.name>Line segment Terminal 1</cim:IdentifiedObject.name>
<cim:Terminal.ConductingEquipment rdf:resource="#_ACLineSegment"/>
<cim:ACDCTerminal.sequenceNumber>1</cim:ACDCTerminal.sequenceNumber>
<cim:Terminal.ConnectivityNode rdf:resource="#_Node1"/>
</cim:Terminal>
<cim:Terminal rdf:ID="_ACLineSegment-T2">
<cim:IdentifiedObject.name>Line segment Terminal 2</cim:IdentifiedObject.name>
<cim:Terminal.ConductingEquipment rdf:resource="#_ACLineSegment"/>
<cim:ACDCTerminal.sequenceNumber>2</cim:ACDCTerminal.sequenceNumber>
<cim:Terminal.ConnectivityNode rdf:resource="#_Node2"/>
</cim:Terminal>
<cim:BaseVoltage rdf:ID="_BaseVoltage">
<cim:IdentifiedObject.name>11 kV</cim:IdentifiedObject.name>
<cim:BaseVoltage.nominalVoltage>11.0</cim:BaseVoltage.nominalVoltage>
</cim:BaseVoltage>
</rdf:RDF>
2 changes: 1 addition & 1 deletion cgmes/cgmes-model/src/main/resources/CIM14.sparql
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ GRAPH ?graph {
?VoltageLevel
a cim:VoltageLevel ;
cim:VoltageLevel.MemberOf_Substation ?Substation ;
cim:IdentifiedObject.name ?name ;
cim:VoltageLevel.BaseVoltage ?BaseVoltage .
OPTIONAL { ?VoltageLevel cim:IdentifiedObject.name ?name }
}
# BaseVoltage may be defined in a different EQ graph
GRAPH ?graph2 {
Expand Down
6 changes: 3 additions & 3 deletions cgmes/cgmes-model/src/main/resources/CIM16.sparql
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,8 @@ WHERE {
?VoltageLevel
a cim:VoltageLevel ;
cim:VoltageLevel.Substation ?Substation ;
cim:IdentifiedObject.name ?name ;
cim:VoltageLevel.BaseVoltage ?BaseVoltage .
OPTIONAL { ?VoltageLevel cim:IdentifiedObject.name ?name }
OPTIONAL { ?VoltageLevel cim:VoltageLevel.lowVoltageLimit ?lowVoltageLimit }
OPTIONAL { ?VoltageLevel cim:VoltageLevel.highVoltageLimit ?highVoltageLimit }
}}
Expand Down Expand Up @@ -342,9 +342,9 @@ WHERE {
# A Bay may be in a different instance file of its containing Voltage Level,
# and a Voltage Level in a different instance file of its containing Substation.
# This is why we do not use a "restrictive" GRAPH clause here.
?ConnectivityNodeContainer a ?connectivityNodeContainerType ;
?ConnectivityNodeContainer a ?connectivityNodeContainerType .
OPTIONAL { ?ConnectivityNodeContainer cim:IdentifiedObject.name ?name }
VALUES ?connectivityNodeContainerType { cim:VoltageLevel cim:Bay cim:Line cim:Substation} .
?ConnectivityNodeContainer cim:IdentifiedObject.name ?name .
OPTIONAL {
?ConnectivityNodeContainer
a cim:VoltageLevel ;
Expand Down

0 comments on commit fe577f8

Please sign in to comment.