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.
Quantity | Example 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.
Dimension | SI unit | Context name | Units |
---|---|---|---|
None | dimensionless | ||
percent | % | ||
Absement | m·s | absement | ~m·s |
Acceleration | m/s2 | acceleration | ~m/s2 |
Angle | rad | angle | rad |
angle:deg | ° | ||
Angular acceleration | rad/s2 | angular_acceleration | rad/s2 |
Angular jerk | rad/s3 | angular_jerk | rad/s3 |
Angular velocity | rad/s | angular_velocity | rad/s |
Area | m2 | area | ~m2 |
Data rate | – | data_rate | ~B/s |
Density | kg/m3 | density | ~kg/m3 |
Electric charge | C | electric_charge | ~C |
Electric current | A | electric_current | ~A |
Energy | J | energy | ~J |
energy:cal | ~cal | ||
energy:kcal | kcal | ||
energy:ev | ~eV | ||
energy:watt | ~W*h | ||
Flowrate | m3/s | flowrate | m3/s |
flowrate:l_min | ~l/min | ||
Force | N | newton | ~N |
newton:daN | daN | ||
Frequency | Hz | frequency | ~Hz |
Bq | activity | ~Bq | |
Illuminance | lx | illuminance | lx |
Jerk | m/s3 | jerk | ~m/s3 |
Kinematic viscosity | m2/s | kinematic_viscosity | ~Pa·s |
Length | m | length | ~m, ly |
length:atomic | Å | ||
Level | dB | level | dB |
Luminance | cd/m2 | luminance | cd/m2 |
Luminous efficacy | lm/W | luminous_efficacy | lm/W |
Luminous energy density | lm·s/m3 | luminous_energy_density | lm·s/m3 |
Luminous energy | lm·s | luminous_energy | lm·s |
Luminous exitance | lm/m2 | luminous_exitance | lm/m2 |
Luminous exposure | lx·s | luminous_exposure | lx·s |
Luminous flux | lm | luminous_flux | lm |
Luminous intensity | cd | luminous_intensity | cd |
Mass concentration | kg/m3 | dna_concentration | ng/µl |
mass_concentration | ~g/l | ||
Mass flow rate | kg/s | mass_flow_rate | kg/s |
Mass | kg | mass | ~g, ton |
Memory | – | memory | ~B |
Molar concentration | mol/m3 | molar_concentration | M |
molar_concentration:explicit | ~mol/l | ||
Moment of inertia | kg·m2 | moment_of_inertia | kg·m2 |
Momentum | kg·m/s | momentum | kg·m/s |
Power | W | power | ~W |
power:hp | hp | ||
Pressure | Pa | pressure | ~Pa |
pressure:psi | ~psi | ||
Radiance | W/sr/m2 | radiance | W/sr/m2 |
Solid angle | sr | solid_angle | sr |
Temperature | K | temperature | °C |
temperature:K | ~K | ||
Time | s | time | s, min, hr, day, year |
Velocity | velocity:car | km/hr | |
velocity | ~m/s | ||
Volume | m3 | volume | ~m3 |
volume:l | l |