#chemistry #atomic #atom #periodic-table #no-alloc #isotope

no-std mendeleev

List of chemical elements, their isotopes, and their properties

9 releases (breaking)

new 0.8.1 Jun 5, 2024
0.8.0 Apr 21, 2023
0.7.0 Feb 6, 2023
0.6.0 Dec 18, 2022
0.5.0 Nov 27, 2022

#14 in Science

Download history 12/week @ 2024-02-21 23/week @ 2024-02-28 10/week @ 2024-03-06 16/week @ 2024-03-13 7/week @ 2024-03-20 13/week @ 2024-03-27 26/week @ 2024-04-03 3/week @ 2024-04-10 8/week @ 2024-04-17 9/week @ 2024-04-24 6/week @ 2024-05-08 90/week @ 2024-05-15 216/week @ 2024-05-22 768/week @ 2024-05-29

1,080 downloads per month
Used in 8 crates (3 directly)

MIT/Apache

730KB
25K SLoC

Information on chemical elements and their isotopes

Latest version pipeline status Documentation unsafe forbidden License

Mendeleev

Mendeleev is a crate containing all known chemical elements as an enum and as a list, as well as methods that return some properties for each of them.

Example

Get data on a specific element

use mendeleev::Element;

let element = Element::Si;
assert_eq!(element.atomic_number(), 14);
assert_eq!(element.name(), "Silicon");
assert_eq!(format!("{}", element.electronic_configuration()), "[Ne] 3s² 3p²");

Example

Search the list of elements

use mendeleev::{Element, Kelvin};

// Find the element with the highest value for a given property
let highest_melting_point = Element::iter().reduce(|acc, e| {
    core::cmp::max_by(acc, e, |e1, e2| {
        e1.melting_point()
            .unwrap_or(Kelvin(0.0))
            .total_cmp(&e2.melting_point().unwrap_or(Kelvin(0.0)))
    })
});
assert_eq!(highest_melting_point, Some(Element::C));

// Iterate through the elements with no known year of discovery
let mut ancient_elements = Element::iter()
    .filter(|e| matches!(e.year_discovered(), mendeleev::YearDiscovered::Ancient));
assert_eq!(ancient_elements.next(), Some(Element::C));
assert_eq!(ancient_elements.next(), Some(Element::Al));

// Find an element by name
let iron = Element::iter().find(|e| e.name().eq_ignore_ascii_case("iron"));
assert_eq!(iron, Some(Element::Fe));

It also contains most of the known isotopes for each element (naturally occurring, synthetic, or theoretical), accessible via a similar API as the elements themselves.

Available data

Elements

  • Symbol
  • Name (in American English)
  • Atomic number
  • Atomic radius
  • Atomic weight
  • RGB color in the CPK and Jmol conventions
  • Position in the periodic table (period and group)
  • Melting and boiling point
  • Heat of fusion and evaporation
  • Electronic configuration
  • Discovery data (year, location, discoverers)

Isotopes

  • Corresponding element
  • Relative natural abundance on Earth
  • Mass number
  • Neutron number

Features

  • No unsafe code
  • No required dependencies
  • Optional support for serde
  • All properties are const or 'static
  • Compatible with no-std
  • Most types implement Display
  • No build.rs file. All the data is directly in the code
  • Each of the available properties has its own file that can be excluded from the build with a feature flag, to reduce binary size and compilation time when not all properties are needed
  • Numeric properties are accompanied by constants providing the range of values they can take
  • Documentation, tests, and examples

Data sources

The data from this crate comes from the following sources:

Note that this crate is not maintained by the same authors as the PyPI package.

Contributing

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as below, without any additional terms or conditions.

License

Licensed under either of

at your option.

Dependencies