cim-kit
A Rust implementation of the IEC Common Information Model for power systems.
cim-kit reads, navigates, validates and writes CIM grid models in CGMES 3.0
(IEC TS 61970-600-1/-2:2021) and CGMES 2.4.15. It exports typed RDF that ENTSO-E's
SHACL shapes accept, and computes difference models between two model states.
It reads both ENTSO-E conformity corpora โ 31 CGMES 3.0 model sets and 52 CGMES 2.4.15 archives, 523,842 objects โ without an error, and writes each back file for file and value for value.
๐ Documentation ยท ๐ฆ API reference
use *;
use ;
// A CGMES model is a set of profile files describing the same objects.
let grid = load_dir?;
for line in grid.
let report = grid.validate;
println!;
# Ok::
๐ฆ Install
The package is cim-kit; the library is cim_kit.
| Feature | Effect |
|---|---|
cgmes3 (default) |
CGMES 3.0 schema, typed views and named constants |
cgmes2 |
CGMES 2.4.15 schema, typed views and named constants |
zip |
Read and write model sets packaged as zip archives |
cli |
The cim command line (implies zip) |
Both vintages can be enabled at once; identifiers are per-vintage, so they cannot be mixed.
โจ๏ธ From a shell
Inputs may be files, zip archives or directories. A document result is the whole of stdout; reports go to stderr. See the command-line reference.
โ What makes it correct
Each point is enforced by a test against the published conformity models.
- A model is a set of files. Objects merge by mRID across profiles; contradictions are
reported (
CIM0018), not resolved silently. - An identifier is a UUID, not its spelling. Hyphenless and absolute-IRI forms resolve to the same object.
- Provenance decides the export. Each value and object records the file it came from, so a re-export reproduces the original file set.
- Element classes and
rdf:ID/rdf:aboutcome from the profile RDFS, not from guesses. - A number's spelling is kept.
2.62637E-05is written back as read; equality still compares numbers. - Compounds are values. Nested
StreetAddressand similar are read as structures. - The vintage is detected from the namespace. A mismatch is reported (
CIM0021). - A read succeeds only for a whole, well-formed document. Truncated or broken XML is an error under either strictness, and a failed read changes nothing.
- Lenient reading reports what it tolerated, in a bounded report. A property given twice
in one element is reported (
CIM0018), with both positions. - Input is bounded. 8 GiB per load by default, archives counted decompressed;
--max-inputraises it. Entities are never expanded or fetched. - Unrepresentable values are refused. Characters XML 1.0 cannot hold and non-
NCNamerdf:IDs are reported (CIM0019,CIM0020) and never written. - Output is checked by other parsers. XML and N-Triples grammars, PowSyBl (same network from a re-export as from the original) and rdflib, in CI.
Details: conformance.
๐ Typed RDF
CIM/XML is not RDF/XML and carries no datatypes. cim-kit exports N-Triples or Turtle per
profile, with every value typed from the profile, ready for a triple store or a SHACL engine.
use *;
use SCHEMA;
use ;
# let grid = load?;
let eq = SCHEMA.profile_by_keyword.unwrap;
let turtle = to_string?;
# Ok::
<urn:uuid:17086487-56ba-4979-b8de-064025a6b4da>
a cim:ACLineSegment ;
cim:ACLineSegment.r "2.2"^^xsd:float ;
cim:ConductingEquipment.BaseVoltage <urn:uuid:a7f1d8de-d658-428a-821b-3a5ae5965fd1> ;
cim:Equipment.aggregate "false"^^xsd:boolean ;
cim:IdentifiedObject.name "BE-Line_1" ;
eu:IdentifiedObject.shortName "BE-L_1" .
Every profile with data in every CGMES 3.0 conformity model passes ENTSO-E's SHACL shapes
under pyshacl in CI. The library does not run SHACL itself. More
๐ Difference models
Read, apply, write and compute IEC 61970-552 difference models.
use *;
use SCHEMA;
use DiffOptions;
#
Applying a computed change set to its base reproduces the target exactly. A change set
applies only to its own base: an unmet md:Model.Supersedes or dm:preconditions is
refused before anything changes. More
๐๏ธ Design
The schema tables, typed views and named constants are generated from the official RDFS, one module per vintage; the dataset, reader/writer, RDF, header, diff and validation layers are hand-written and schema-agnostic. Objects are stored sparsely. More
| Vintage | Feature | Namespace | Classes | Attributes | Enums | Profiles |
|---|---|---|---|---|---|---|
| CGMES 3.0 | cgmes3 (default) |
CIM100 + eu |
443 | 3,624 | 51 | 11 |
| CGMES 2.4.15 | cgmes2 |
cim16 + entsoe |
401 | 3,539 | 48 | 12 |
Benchmarks: performance; reproduce with cargo bench -p cim-kit.
๐ Conformance
| Standard | Role |
|---|---|
| IEC 61970-301:2020+AMD1:2022 | CIM base semantics (CIM17) |
| IEC 61970-501:2006 | RDFS profile representation โ the codegen input |
| IEC 61970-552:2016 | CIM/XML format: identity, headers, difference models |
| IEC TS 61970-600-1/-2:2021 | CGMES 3.0 profile set |
Profiles: EQ, OP, SC, EQBD, SSH, TP, SV, DL, GL, DY and the header vocabulary in both
vintages, plus TPBD in CGMES 2.4.15. Tested against both conformity corpora and
ENTSO-E's 100 QoCDC quality-check sets; builds for wasm32-unknown-unknown.
The full record
๐ ๏ธ Development
Corpus-backed tests skip cleanly on a fresh clone. See CONTRIBUTING.md and CHANGELOG.md.
โ๏ธ Licensing and attribution
Licensed MIT OR Apache-2.0.
The RDFS vocabularies the generated code derives from are published by ENTSO-E and the UCA International Users Group under the Apache License 2.0; generated files carry that attribution. IEC standard documents are not redistributed and the build does not depend on them. The ENTSO-E conformity models (CC BY-SA 4.0) are a local test corpus only and are never redistributed.