# Chapter 19 Unit Expressions

Unless otherwise stated, the syntax and semantics of unit expressions in Modelica are conform with the international standards 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, neither these two standards nor other existing or emerging ISO standards define a formal syntax for unit expressions. There are recommendations and Modelica exploits them.

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 ISO standard does not define any precedence between multiplications and divisions. The ISO recommendation is to have at most one division, where the expression to the right of ”/” either contains no multiplications or is enclosed within parentheses. It is also possible to use negative exponents, 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 ISO standard allows that a multiplication operator symbol is left out. However, Modelica enforces the ISO recommendation that each multiplication operator is explicitly written out in formal specifications. For example, Modelica does not support ”Nm” for newtonmeter, but requires it to written as ”N.m”.

The preferred ISO symbol for the multiplication operator is a ”dot” a bit above the base line: ”·”. Modelica supports the ISO alternative ”.”, which is an ordinary ”dot” on the base line.

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

The ISO standard does 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.

## 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 squaremeter, m2, write ”m2”.

The expression ”mm2” means mm2 = (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.