2. Defining units
The string that defines a unit can say much more than a symbol. Each part is optional but the first one, and each adds information that FURY uses:
symbol_only = uom64('m')
with_dimensions = uom64('m [length]')
with_aliases = uom64('m = metre = meter [length]')
with_name = uom64('m = metre = meter [length] {metre}')
compound = uom64('kg [mass].m [length].s-2 [time-2]')
with_main_alias = uom64('kg [mass].m [length].s-2 [time-2] (N[force]) {newton}')| Part | Example | Meaning |
|---|---|---|
| symbol | m | the main symbol, the only required part |
= alias | = metre = meter | other symbols of the same unit (synonyms), or conversion formulas (chapter 5) |
[dimensions] | [length] | the dimensions of the symbol, with the same exponent |
. | kg.m.s-2 | a product of reference units, each with its exponent and dimensions |
(alias[dimensions]) | (N[force]) | the main alias of a compound unit: the symbol it is known by |
{name} | {newton} | the name of the unit, used to query a units system |
stringify prints the parts it is asked for:
print '(A)', symbol_only%stringify(with_dimensions=.true.)
print '(A)', with_dimensions%stringify(with_dimensions=.true.)
print '(A)', with_aliases%stringify(with_dimensions=.true., with_aliases=.true.)
print '(A)', with_name%stringify(with_dimensions=.true., with_aliases=.true., with_name=.true.)
print '(A)', compound%stringify(with_dimensions=.true.)
print '(A)', with_main_alias%stringify(with_dimensions=.true., with_aliases=.true., with_name=.true.)$ tutorial_2
m
m [length]
m = metre = meter [length]
m = metre = meter [length] {metre}
kg.m.s-2 [mass.length.time-2]
kg.m.s-2 [mass.length.time-2] (N [force]) {newton}Compound units
A compound unit is a product of reference units separated by ., each with an integer exponent: kg.m.s-2 is the kilogram times the metre times the second to the power -2, the notation of The Unified Code for Units of Measure. Each reference has its own dimensions, kg [mass].m [length].s-2 [time-2], and FURY combines them: mass.length.time-2.
The main alias in parentheses is the short symbol of a compound unit, N for kg.m.s-2, with its own dimensions. It is how the unit is printed with with_aliases=.true., and FURY uses it to convert the unit (chapter 5).
What you learned
The parts of a unit definition: symbol, aliases, dimensions, compound units, main alias, name. Reference: Unit grammar.
Next: 3. The algebra of units.