#physics-simulation #quantities #units #simulation #physics

unitforge

A library for unit and quantity consistent computations in Rust

21 releases

new 0.2.16 May 8, 2025
0.2.15 May 6, 2025
0.2.8 Apr 25, 2025
0.2.3 Mar 28, 2025
0.1.4 Feb 20, 2025

#89 in Science

Download history 335/week @ 2025-02-14 158/week @ 2025-02-21 15/week @ 2025-02-28 5/week @ 2025-03-07 215/week @ 2025-03-14 72/week @ 2025-03-21 261/week @ 2025-03-28 330/week @ 2025-04-04 124/week @ 2025-04-11 129/week @ 2025-04-18 186/week @ 2025-04-25 791/week @ 2025-05-02

1,300 downloads per month

MIT license

160KB
4.5K SLoC

Unitforge

Overview

Unitforge is a Rust crate designed for safe handling of physical quantities of units. New quantities and relations can be set up via small macros.

Features

  • Quantity inference: Resulting quantities of arithmetic operations are inferred at compile time.
  • Unit conversion: Quantities can be set or read in arbitrary units.
  • Computing Precision Values are stored in exponential format (f64*10^i32) to prevent floating point precision issues.
  • Formating Quantities are displayed with 4 significant digits and configured display unit.
  • ndarray support: Quantities may be used as inner types for ndarray.
  • 3D Vector and matrix operations: Structs for 3D vectors and matrices are included to allow fast and unit-safe work with them.
  • Serialization: Optional support for sere using the serde feature.
  • python interface Optional Python interface when building with flag pyo3; also available on pypi

Contribute

All contributions are welcome! Feel free to implement new quantities or define relations using impl_macros.rs. 🚀

Dependencies

~1.3–2.9MB
~55K SLoC