Modelica® Language Specification version 3.5

Chapter 19 Unit Expressions

(February 18, 2021)

Unless otherwise stated, the syntax and semantics of unit expressions in Modelica conform with the international standards International System of Units (SI) by BIPM superseding parts of ISO 31/0-1992 General principles concerning quantities, units and symbols and ISO 1000-1992 SI units and recommendations for the use of their multiples and of certain other units. Unfortunately, these standards do not define a formal syntax for unit expressions. There are recommendations and Modelica exploits them.

Note that this document uses the American spelling meter, whereas the SI specification from BIPM uses the British spelling metre.

Examples for the syntax of unit expressions used in Modelica: "N.m", "kg.m/s2", "kg.m.s-2" "1/rad", "mm/s".

19.1 The Syntax of Unit Expressions

unit_expression:
   unit_numerator [ "/" unit_denominator ]
unit_numerator:
   "1" | unit_factors | "(" unit_expression ")"
unit_denominator:
   unit_factor | "(" unit_expression ")"

The unit of measure of a dimension free quantity is denoted by "1". The SI standard does not define any precedence between multiplications and divisions. The SI standard does not allow multiple units to the right of the division-symbol (/) since the result is ambiguous; either the divisor shall be enclosed in parentheses, or negative exponents used instead of division, for example, "J/(kg.K)" may be written as "J.kg-1.K-1".

unit_factors:
   unit_factor [ unit_mulop unit_factors ]
unit_mulop:
   "."

The SI standard specifies that a multiplication operator symbol is written as space or as a dot. The SI standard requires that this dot is a bit above the base line: ‘·’, which is not part of ASCII. The ISO standard also prefers ‘·’, but Modelica supports the ISO alternative ‘.’, which is an ordinary dot on the base line.

For example, Modelica does not support "Nm" for newton-meter, but requires it to be written as "N.m".

unit_factor:
  unit_operand [ unit_exponent ]
unit_exponent:
   [ "+" | "-" ] integer

The SI standard uses super-script for the exponentation, and does thus not define any operator symbol for exponentiation. A unit_factor consists of a unit_operand possibly suffixed by a possibly signed integer number, which is interpreted as an exponent. There must be no spacing between the unit_operand and a possible unit_exponent.

unit_operand:
   unit_symbol | unit_prefix unit_symbol
unit_prefix:
   Y | Z | E | P | T | G | M | k | h | da | d | c | m | u | n | p | f | a | z | y

A unit_symbol is a string of letters. A basic support of units in Modelica should know the basic and derived units of the SI system. It is possible to support user defined unit symbols. In the base version Greek letters is not supported, but full names must then be written, for example "Ohm".

A unit_operand should first be interpreted as a unit_symbol and only if not successful the second alternative assuming a prefixed operand should be exploited. There must be no spacing between the unit_symbol and a possible unit_prefix. The values of the prefixes are according to the ISO standard. The letter u is used as a symbol for the prefix micro.

[A tool may present Ohm as Ω and the prefix u as μ, and similarly m2 as m2.]

19.2 Examples

The unit expression "m" means meter and not milli (10-3), since prefixes cannot be used in isolation. For millimeter use "mm" and for square meter, m2, write "m2".

The expression "mm2" means (10-3m)2 = 10-6m2. Note that exponentiation includes the prefix.

The unit expression "T" means tesla, but note that the letter T is also the symbol for the prefix tera which has a multiplier value of 1012.