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 byk_B·Tis dimensionless by construction. - conversion
- Units and conversion. A
Unitmaps its own scale to coherent SI by an affine transformsi = 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§
- Units
Error - Fail-closed errors for unit handling.