Skip to main content

qualia_core_db/specialized_libs/chemistry_modeling/
structure.rs

1/// IUPAC standard atomic weight (amu) for common elements. Conventional values
2/// (IUPAC 2021). Returns `None` for elements outside the table so callers can
3/// fall back to a declared per-atom mass rather than receive a fabricated one.
4pub fn standard_atomic_weight(element: &str) -> Option<f64> {
5    let w = match element {
6        "H" => 1.008,
7        "He" => 4.002602,
8        "Li" => 6.94,
9        "Be" => 9.0121831,
10        "B" => 10.81,
11        "C" => 12.011,
12        "N" => 14.007,
13        "O" => 15.999,
14        "F" => 18.998403163,
15        "Ne" => 20.1797,
16        "Na" => 22.98976928,
17        "Mg" => 24.305,
18        "Al" => 26.9815385,
19        "Si" => 28.085,
20        "P" => 30.973761998,
21        "S" => 32.06,
22        "Cl" => 35.45,
23        "Ar" => 39.948,
24        "K" => 39.0983,
25        "Ca" => 40.078,
26        "Fe" => 55.845,
27        "Cu" => 63.546,
28        "Zn" => 65.38,
29        "Br" => 79.904,
30        "I" => 126.90447,
31        _ => return None,
32    };
33    Some(w)
34}
35
36/// Exact structural / mass properties of a molecule (see the methods on
37/// [`ChemistryModelingLibrary`]). Every field is computed from a closed-form
38/// definition over atomic data and geometry, not an approximation or fit.
39#[derive(Debug, Clone)]
40pub struct StructuralProperties {
41    /// Total molecular mass (amu), from standard atomic weights.
42    pub molecular_mass: f64,
43    /// Molecular formula in Hill notation.
44    pub formula: String,
45    /// Number of atoms.
46    pub atom_count: usize,
47    /// Nuclear repulsion energy Σ Z_i Z_j / r_ij (Hartree when coords are in
48    /// bohr); `None` when the geometry/charges cannot support it.
49    pub nuclear_repulsion_energy: Option<f64>,
50    /// Center of mass (same length unit as the coordinates).
51    pub center_of_mass: [f64; 3],
52    /// Principal moments of inertia, ascending (amu·length²).
53    pub principal_moments_of_inertia: [f64; 3],
54}