Skip to main content

Module units

Module units 

Source
Expand description

Units, physical constants & dimensional analysis (Gap analysis §3.6).

A unit-correct quantity is a value plus its physical dimension, and arithmetic on quantities is dimensionally checked: you cannot add a length to a time, and multiplying a force by a distance yields an energy. This serves the NL→3D / engineering work directly (unit-correct geometry and materials) and is a small, self-contained foundation the rest of the engine can lean on.

Mission fit: dimensional consistency is a correctness guard — a calculation that is dimensionally wrong is wrong, full stop, and the type system catches it before a fabricated number can propagate. Fail-closed throughout (UnitsError).

Layers (one concern per file, §11):

  • dimension — the 7-vector of SI base-dimension exponents + named dimensions.
  • quantity — a value with a dimension, and checked arithmetic.
  • conversion — units (linear factor + affine offset for temperature) and convert.
  • constants — CODATA physical constants as dimensioned quantities.

Kernel-class ElementwiseMap (trivial CPU).

Re-exports§

pub use conversion::convert;
pub use conversion::Unit;
pub use dimension::Dimension;
pub use quantity::Quantity;

Modules§

constants
Physical constants as dimensioned Quantitys (CODATA / SI-2019 defined values where exact). Each carries its dimension so it composes correctly in unit-checked arithmetic — e.g. ½·m·v² divided by k_B·T is dimensionless by construction.
conversion
Units and conversion. A Unit maps its own scale to coherent SI by an affine transform si = value·factor + offset (the offset is only non-zero for the temperature scales — Celsius, Fahrenheit). Conversion between two units requires matching dimensions and fails closed otherwise.
dimension
Physical dimension as the 7-vector of SI base-dimension exponents.
quantity
A dimensioned quantity: a value with a physical Dimension, and arithmetic that is dimensionally checked. Adding incompatible dimensions fails closed; products and quotients compose dimensions automatically.

Enums§

UnitsError
Fail-closed errors for unit handling.