utomid-rs 0.1.0

Compact encoding for chemical elements, compounds, and basic chemistry utilities.
Documentation
  • Coverage
  • 26.67%
    4 out of 15 items documented1 out of 3 items with examples
  • Size
  • Source code size: 39.9 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.96 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 17s Average build duration of successful builds.
  • all releases: 17s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • JDPlumbing/utomid-rs
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • JDPlumbing

utomid-rs

utomid-rs is a compact Rust library for representing chemical elements and compounds. It’s designed for simulation and material modeling, with a focus on compact encoding and fast operations rather than full-blown chemistry accuracy.


✨ Features

  • Lookup of all 118 chemical elements (Element struct)
  • Encode atomic numbers into a compact u8 representation
  • Decode element IDs back into names, symbols, valence, and atomic mass
  • Build compounds either as expanded lists ([1, 1, 8] for Hβ‚‚O) or compact pairs ([(1,2), (8,1)])
  • Calculate compound molecular mass
  • Render compounds into human-readable formulas (e.g. "H2O", "C6H12O6")
  • Benchmark-ready for performance tuning

πŸ“¦ Installation

Add this crate to your project:

cargo add utomid-rs

Or manually in Cargo.toml:

[dependencies]
utomid-rs = "0.1"

πŸš€ Usage

use utomid_rs::{CompactCompound, compound_formula, compound_mass};

// Expanded representation (array of atomic numbers)
let water = vec![1,1,8]; // H2O
println!("Formula: {}", compound_formula(&water));
println!("Mass: {}", compound_mass(&water));

// Compact representation
let water_compact = CompactCompound::new(vec![(1,2), (8,1)]);
println!("Formula: {}", water_compact.formula());
println!("Mass: {}", water_compact.mass());

Output:

Formula: H2O
Mass: 18.015

πŸ§ͺ Benchmarks

Run with:

cargo bench

Sample results (on a mid-tier CPU):

mass H2O (compact)      time:   ~18 ns
formula H2O (compact)   time:   ~92 ns
mass glucose (compact)  time:   ~27 ns
formula glucose (compact) ~165 ns

πŸ“– Roadmap

  • Add bond/interaction utilities
  • Expand into materials-level abstractions (air, water, steel, etc.)
  • Optional probabilistic reaction rules

πŸ“œ License

Licensed under MIT.
See LICENSE for details.