Automancer docs

Defining quantities

General

Quantities are ubiquitous in Automancer and are managed by Quantops.

Quantops is flexible on how units are referenced: they can be in a abbreviated (e.g. s) or longer form (e.g. sec or second), singular or plural (e.g. seconds). Prefixes from the SI system can also be used, such as MHz for megahertz.

QuantityExample units
time (T)s, sec, second, seconds; min, minute, minutes; etc.
frequency (T-1)Hz, hertz, 1 / second, s**-1
temperature (Θ)degC; degF; K, kelvin
flowrate (L3T-1)m**3 / second, µl/s, ul/s

Defining quantities in expressions

When working with expressions, units can be obtained using the global unit variable, such as unit.sec or unit.second for seconds. The unit can then be multiplied by a number to obtain a quantity, e.g. 5 * unit.sec corresponds to 5 seconds. Multiplying two units or quantities together will produce a new unit or quantity with that new unit, as expected: 5 * unit.meter / unit.sec corresponds to 5 m/s. The same result is obtained when manipulating units first and then creating a quantity, such as 5 * (unit.meter / unit.sec). The number multiplied by a unit can involve complex operations, such as abs(math.cos(2 ** index)) * unit.sec.

Any attribute expecting a quantity can have a value as both a quantity literal (e.g. 5 sec) or an expression (e.g. {{ 5 * unit.sec }}).

Using inverse units

In specific situations, a quantity with the inverse expected unit can be accepted by an attribute. For example, a time quantity can often be accepted instead of a frequency. These two would produce the same result:

frequency: 20 Hz
frequency: 50 ms

Providing unit contexts

Certain configuration schemas or APIs require a unit context. A unit context describes how to display a quantity with a given dimensionality as rendering quantities with SI units is not always the most convenient option. For example, it is common to display DNA concentration in µg/ml rather than kg/m3, and certain pressure in psi rather than pascals. The prefixes used are also specified by the unit context, for instance to display MB/s or MiB/s for a data rate depending on the context. Lastly, a context can define different rules depending on the locale, for example by using °C or °F when dealing with temperatures.

The following contexts are available out of the box. The ~ symbol indicates that prefixes may be prepended to the adjacent unit. Prefixes that are technically correct but not used in practice (such as megagrams) are never used.

DimensionSI unitContext nameUnits
Nonedimensionless
percent%
Absementm·sabsement~m·s
Accelerationm/s2acceleration~m/s2
Angleradanglerad
angle:deg°
Angular accelerationrad/s2angular_accelerationrad/s2
Angular jerkrad/s3angular_jerkrad/s3
Angular velocityrad/sangular_velocityrad/s
Aream2area~m2
Data ratedata_rate~B/s
Densitykg/m3density~kg/m3
Electric chargeCelectric_charge~C
Electric currentAelectric_current~A
EnergyJenergy~J
energy:cal~cal
energy:kcalkcal
energy:ev~eV
energy:watt~W*h
Flowratem3/sflowratem3/s
flowrate:l_min~l/min
ForceNnewton~N
newton:daNdaN
FrequencyHzfrequency~Hz
Bqactivity~Bq
Illuminancelxilluminancelx
Jerkm/s3jerk~m/s3
Kinematic viscositym2/skinematic_viscosity~Pa·s
Lengthmlength~m, ly
length:atomicÅ
LeveldBleveldB
Luminancecd/m2luminancecd/m2
Luminous efficacylm/Wluminous_efficacylm/W
Luminous energy densitylm·s/m3luminous_energy_densitylm·s/m3
Luminous energylm·sluminous_energylm·s
Luminous exitancelm/m2luminous_exitancelm/m2
Luminous exposurelx·sluminous_exposurelx·s
Luminous fluxlmluminous_fluxlm
Luminous intensitycdluminous_intensitycd
Mass concentrationkg/m3dna_concentrationng/µl
mass_concentration~g/l
Mass flow ratekg/smass_flow_ratekg/s
Masskgmass~g, ton
Memorymemory~B
Molar concentrationmol/m3molar_concentrationM
molar_concentration:explicit~mol/l
Moment of inertiakg·m2moment_of_inertiakg·m2
Momentumkg·m/smomentumkg·m/s
PowerWpower~W
power:hphp
PressurePapressure~Pa
pressure:psi~psi
RadianceW/sr/m2radianceW/sr/m2
Solid anglesrsolid_anglesr
TemperatureKtemperature°C
temperature:K~K
Timestimes, min, hr, day, year
Velocityvelocity:carkm/hr
velocity~m/s
Volumem3volume~m3
volume:ll