Sveino / Inst4CIM-KG

Instance of CIM Knowledge Graph
Apache License 2.0
5 stars 1 forks source link

Datatypes and Units of Measure #38

Closed VladimirAlexiev closed 2 months ago

VladimirAlexiev commented 2 months ago

CGMES datatype properties are defined like this:

cim:ACDCConverter.baseS a owl:FunctionalProperty , owl:DatatypeProperty ;
  rdfs:domain cim:ACDCConverter ;
  rdfs:range  cim:ApparentPower.

cim:ApparentPower a owl:Class ;
  rdfs:label "ApparentPower"@en ;
  eq:Package "Package_CoreEquipmentProfile" ;
  eq:isCIMDatatype "True" ;
  skos:definition "\nProduct of the RMS value of the voltage and the RMS value of the current.\n\n\t"@en .

cim:ApparentPower.multiplier
  a owl:FunctionalProperty , owl:DatatypeProperty ;
  rdf:value "M" ;
  rdfs:domain cim:ApparentPower ;
  rdfs:label "multiplier"@en ;
  rdfs:range cim:UnitMultiplier ;
  eq:isFixed "True " .

cim:ApparentPower.unit
  a owl:FunctionalProperty , owl:DatatypeProperty ;
  rdf:value "VA" ;
  rdfs:domain cim:ApparentPower ;
  rdfs:label "unit"@en ;
  rdfs:range cim:UnitSymbol ;
  eq:isFixed "True " .

cim:ApparentPower.value
 a owl:FunctionalProperty , owl:DatatypeProperty ;
 rdfs:domain cim:ApparentPower ;
 rdfs:label "value"@en ;
 rdfs:range xsd:float .

There are numerous problems:

CIM defines a large set of units of measure, eg:

cim:UnitSymbol a owl:Class ;
  rdfs:label "UnitSymbol"@en ;
  eq:Package "Package_CoreEquipmentProfile" ;
  owl:oneOf (... cim:UnitSymbol.VA ...).
cim:UnitSymbol.VA a owl:NamedIndividual, owl:Thing ;
  rdfs:label "VA "@en ;
  eq:isenum "True" ;
  rdfs:domain cim:UnitSymbol ;
  skos:definition "Apparent power in volt amperes. See also real power and reactive power."@en .

cim:UnitMultiplier a owl:Class ;
  rdfs:label "UnitMultiplier"@en ;
  owl:oneOf (... cim:UnitMultiplier.M ...).
cim:UnitMultiplier.M a owl:NamedIndividual, owl:Thing ;
  rdfs:label "M "@en ;
  eq:isenum "True" ;
  rdfs:domain cim:UnitMultiplier ;
  skos:definition "Mega 10**6."@en .

See sec ## Datatypes and Units of Measure for more analysis and a fixing plan . But I only plan to fix datatype props: so we need to discuss whether to:

VladimirAlexiev commented 2 months ago

Fixed Units Representation

We want to fix the representation as follows, and also connect to QUDT (see https://github.com/qudt/qudt-public-repo/issues/969) . To be clear, this below is just a blueprint, which parts of it will be implemented and where is still for discussion.

First we correct the property: give a numeric range, but also specify hasQuantityKind and hasUnit using qudt props. We link to a global QUDT unit, but also give the multiplier and unitSymbol separately, using cims props:

@prefix qudt: <http://qudt.org/schema/qudt/> .
@prefix unit: <http://qudt.org/vocab/unit/> .

cim:ACDCConverter.baseS a owl:FunctionalProperty , owl:DatatypeProperty ;
  rdfs:domain cim:ACDCConverter ;
  rdfs:range  xsd:float ;
  qudt:hasQuantityKind cim:ApparentPower;
  qudt:hasUnit    unit:MegaV-A;
  cims:multiplier cim:UnitMultiplier.M;
  cims:unitSymbol cim:UnitSymbol.VA.

Then we correct the QuantityKind and relate it to QUDT.

cim:ApparentPower a qudt:QuantityKind ; rdfs:label "ApparentPower"@en ; eq:Package "Package_CoreEquipmentProfile" ; eq:isCIMDatatype "True" ; qudt:applicableUnit cim:cim:UnitSymbol.VA; skos:broader quantitykind:ComplexPower; skos:definition "\nProduct of the RMS value of the voltage and the RMS value of the current.\n\n\t"@en .


We delete `cim:ApparentPower.multiplier, cim:ApparentPower.unit` 
because they are replaced by universal props `cims:multiplier, cims:unitSymbol` respectively.

We delete `cim:ApparentPower.value` because the actual DatatypeProperty `cim:ACDCConverter.baseS`
now carries a number (`xsd:float`).

We correct CIM unit symbols and relate them to QUDT:
```ttl
cim:UnitSymbol a owl:Class ;
  rdfs:label "UnitSymbol"@en ;
  owl:oneOf (... cim:UnitSymbol.VA ...);
  skos:exactMatch qudt:Unit.

cim:UnitSymbol.VA a cim:UnitSymbol ;
  rdfs:label "VA" ;
  cims:isenum "True" ;
  skos:definition "Apparent power in volt amperes. See also real power and reactive power."@en;
  qudt:hasQuantityKind cim:ApparentPower;
  skos:exactMatch unit:V-A.

We correct CIM multipliers and relate them to QUDT (where they are called "prefixes"):

@prefix prefix: <http://qudt.org/vocab/prefix/> .

cim:UnitMultiplier a owl:Class ;
  rdfs:label "UnitMultiplier"@en ;
  owl:oneOf (... cim:UnitMultiplier.M ...);
  skos:exactMatch qudt:DecimalPrefix.

cim:UnitMultiplier.M a cim:UnitMultiplier;
  rdfs:label "M" ;
  cims:isenum "True" ;
  skos:definition "Mega 10**6."@en ;
  skos:exactMatch prefix:Mega.
VladimirAlexiev commented 2 months ago
griddigit-ci commented 2 months ago

Yes, the direction would be to be more explicit with QUDT. we need to see if we need cim: properties in RDFS - maybe not as this will be result of transformation from UML to the RDFS

VladimirAlexiev commented 2 months ago

@griddigit-ci

we need to see if we need cim: properties in RDFS

This statement is rich since QUDT has all sort of info about MegaV-A:

cim:ACDCConverter.baseS qudt:hasUnit    unit:MegaV-A

including info what is its base unit, and what is its multiplier.

But @Sveino also suggested we keep props multiplier and unitSymbol for an easier transition

cim:ACDCConverter.baseS 
  cims:multiplier cim:UnitMultiplier.M;
  cims:unitSymbol cim:UnitSymbol.VA.

(I eliminated the parasitic intermediate props cim:ApparentPower.multiplier, cim:ApparentPower.unit and converted from strings to things.)

It looks like we have an agreement now to exchange in basic units i.e. no M but in form 1e6

We should keep an object to represent "Mega", not just the multiplication factor.

When we link multipliers to QUDT:

cim:UnitMultiplier.M a cim:UnitMultiplier;
  skos:exactMatch prefix:Mega.

people can get rich info:

prefix:Mega
  a qudt:DecimalPrefix ;
  a qudt:Prefix ;
  dcterms:description "'mega' is a decimal prefix for expressing a value with a scaling of \\(10^{6}\\)."^^qudt:LatexString ;
  qudt:dbpediaMatch "http://dbpedia.org/resource/Mega"^^xsd:anyURI ;
  qudt:informativeReference "http://en.wikipedia.org/wiki/Mega?oldid=494040441"^^xsd:anyURI ;
  qudt:prefixMultiplier 1.0E6 ;
  qudt:siExactMatch si-prefix:mega ;
  qudt:symbol "M" ;
  qudt:ucumCode "M" ;
  rdfs:isDefinedBy <http://qudt.org/2.1/vocab/prefix> ;
  rdfs:label "Mega"@en ;
.

Of course, we can copy selected info from QUDT, eg prefixMultiplier 1.0E6. There is a lot richer info about units and quantity kinds. But I was content to just link to QUDT.

VladimirAlexiev commented 2 months ago

This was a big one, the fix queries are: fix05-units-76,77.ru fix06-quantityKind-38.ru fix07-dataProps-38.ru fix08-remove-qkProps-38.ru fix09-map-qkUnitsMultipliers-38.ru