# 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 (L^{3}T^{-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/m^{3}, 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/s^{2} | `acceleration` | ~m/s^{2} |

Angle | rad | `angle` | rad |

`angle:deg` | ° | ||

Angular acceleration | rad/s^{2} | `angular_acceleration` | rad/s^{2} |

Angular jerk | rad/s^{3} | `angular_jerk` | rad/s^{3} |

Angular velocity | rad/s | `angular_velocity` | rad/s |

Area | m^{2} | `area` | ~m^{2} |

Data rate | – | `data_rate` | ~B/s |

Density | kg/m^{3} | `density` | ~kg/m^{3} |

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 | m^{3}/s | `flowrate` | m^{3}/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/s^{3} | `jerk` | ~m/s^{3} |

Kinematic viscosity | m^{2}/s | `kinematic_viscosity` | ~Pa·s |

Length | m | `length` | ~m, ly |

`length:atomic` | Å | ||

Level | dB | `level` | dB |

Luminance | cd/m^{2} | `luminance` | cd/m^{2} |

Luminous efficacy | lm/W | `luminous_efficacy` | lm/W |

Luminous energy density | lm·s/m^{3} | `luminous_energy_density` | lm·s/m^{3} |

Luminous energy | lm·s | `luminous_energy` | lm·s |

Luminous exitance | lm/m^{2} | `luminous_exitance` | lm/m^{2} |

Luminous exposure | lx·s | `luminous_exposure` | lx·s |

Luminous flux | lm | `luminous_flux` | lm |

Luminous intensity | cd | `luminous_intensity` | cd |

Mass concentration | kg/m^{3} | `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/m^{3} | `molar_concentration` | M |

`molar_concentration:explicit` | ~mol/l | ||

Moment of inertia | kg·m^{2} | `moment_of_inertia` | kg·m^{2} |

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/m^{2} | `radiance` | W/sr/m^{2} |

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 | m^{3} | `volume` | ~m^{3} |

`volume:l` | l |