Crate simple_si_units

source ·
Expand description

Simple SI Units

This Rust library provides compiler-checked types for the standard set of SI units, as specified by the US National Institute of Standards and Technology (this project is not officially endorsed by NIST).

What’s included?

  • Official standard SI Units
  • Common secondary units, such as velocity
  • Implements operators to automatically convert between units with basic arithmatic (eg distance / time = velocity)
  • Units are templated so that you can choose whether to use f32 or f64 or other number-like type as your concrete number type.
  • Optional, limited integration with uom

Since these structs use generic type templates for the internal data type, you can use any number-like data type with these structs, including num_complex::Complex and num_bigfloat::BigFloat (see caveat section below regarding primitive types other than f64).

Units

This crate provides types for the following units. Other kinds of quantities not listed below (eg jolt) are beyond the scope of this crate.

Base SI units (and standard unit of measure):
  • Distance, aka Length (meters)
  • Mass (kilogram)
  • Time (seconds)
  • Temperature (kelvin)
  • Amount, aka Quantity (moles)
  • Current (amperes)
  • Luminosity (candela)
Derived units:
  • Angle (rad)
  • Solid Angle (sr)
  • Frequency (1/s, aka Hz)
  • Area (m^2)
  • Volume (m^3)
  • Velocity (m/s)
  • Acceleration (m/s^2)
  • Force (kg.m/s^2, aka N)
  • Pressure (N/m^2, aka Pa)
  • Energy (kg.m^2/s^2, aka J)
  • Coulomb (A.s, aka C)
  • Power, aka Watt (J/s, aka W)
  • Voltage (W/A, aka V)
  • Resistance (V/A, aka Ohm)
  • Conductance (1/ohm, aka S)
  • Capacitance (C/V)
  • Inductance (Wb/A, aka H)
  • Magnetic Flux (V.s, aka Wb)
  • Magnetic Flux Density (Wb/m^2, aka T)
  • Catalytic Activity (mol/s)
  • Concentration (mol/m^3)
  • Luminous Flux (cd.sr, aka lm)
  • Illuminance (lm/m^2, aka lux)
  • Radioactivity (1/s, aka Bq)
  • Absorbed Dose (J/kg, aka Gy)
  • Dose Equivalent (J/kg, aka Sv)

What’s NOT included?

  • Not supporting dimensional analysis
  • Not providing an exhaustive list of all possible unit types (but you can use this library to implement them yourself)
  • Not supporting unusual number types (eg integers)
  • Not aiming for full integration with uom

Modules

  • This module provides base SI units, such as distance (aka length) and amount.
  • This module provides chemical SI units, such as catalytic activity and chemical concentration.
  • This module provides electromagnetic SI units, such as electric charge (aka coulombs) and magnetic flux.
  • This module provides geometry SI units, such as angle and volume.
  • This module provides mechanical SI units, such as angular velocity and velocity.
  • This module provides nuclear SI units, such as radioactivity and radiation dose equivalent.

Traits

Derive Macros