Constants Module (constants)#
Overview#
The constants module centralizes the global constants used throughout the REST codebase, including physical and mathematical constants, numerical thresholds, the index constants required by the libcint interface, and periodic-table-related data. The module entry point is src/constants/mod.rs, with several submodules holding larger data tables.
Centralizing constants serves to:
Single source of truth: each physical quantity has exactly one definition across the codebase, avoiding inconsistent hardcoded duplicates;
Traceability: physical constants carry source annotations (e.g. the CODATA year) for easy verification and updating;
Ease of maintenance: a single update propagates to all usage sites.
Module Structure#
Submodule |
File |
Contents |
|---|---|---|
|
|
Physical and mathematical constants, unit conversion constants, numerical thresholds, scale constants, libcint index constants |
|
|
Element names, atomic masses and charges, electron configurations, atomic radii, shell information |
|
|
Numerical potential tables for the VSAP (superposition of atomic potentials) initial guess |
|
|
Cartesian-to-spherical basis transformation matrices |
|
|
Layout information for Cartesian Gaussian-type orbitals (GTOs) |
|
|
Solvent parameter data used by solvent models |
Each submodule is re-exported in the root module via pub use, so all constants can be referenced uniformly from crate::constants.
Physical and Mathematical Constants#
The physical constants are defined in src/constants/mod.rs, each with a source annotation. Note that these constants originate from different CODATA release years and are not fully internally consistent (see the “Source” column below).
Constant |
Value |
Meaning |
Source |
|---|---|---|---|
|
27.2113845 |
Hartree → eV |
CODATA 2002 |
|
1822.8884861920776 |
Ratio of atomic mass unit u to electron mass mₑ (= 1 / electron mass in u) |
CODATA 2014 |
|
|
Euler’s number e |
mathematical constant |
|
|
π |
mathematical constant |
|
137.03599967994 |
Inverse fine-structure constant α⁻¹ (speed of light in atomic units) |
CODATA 2006 |
|
0.52917721092 |
Bohr radius (in Å), used for Å↔Bohr conversion |
CODATA 2010 |
|
|
Bohr radius (in m) |
derived |
|
2.00231930436182 |
Electron g-factor |
CODATA 2014 |
|
9.10938356e-31 |
Electron mass (kg) |
CODATA 2014 |
|
6.022140857e23 |
Avogadro constant |
CODATA 2014 |
|
6.626070040e-34 |
Planck constant (J·s) |
CODATA 2014 |
|
1.380649e-23 |
Boltzmann constant (J/K) |
CODATA 2018 (exact, SI 2019) |
|
2.99792458e10 |
Speed of light (cm/s) |
SI definition (exact) |
|
|
Ideal gas constant (J/(mol·K)) |
derived |
|
1.6021766208e-19 |
Elementary charge (C) |
CODATA 2014 |
|
3.335641e-30 |
1 debye in C·m |
defined via the speed of light |
Note
For historical reasons, the constants above are taken from several different CODATA releases, most of them (G_ELECTRON, E_MASS, AVOGADRO, PLANCK, E_CHARGE) from CODATA 2014. Newer constants (HARTREE2J, HARTREE2WAVENUMBERS, AMU2KG, SPEED_OF_LIGHT) use CODATA 2022. If you wish to unify them to a single release, please carefully assess the impact on regression test baselines.
Unit Conversion Constants#
These constants handle conversions between different unit systems. They are also defined in src/constants/mod.rs, grouped under the unit conversion comment block.
Constant |
Value |
Meaning |
Source |
|---|---|---|---|
|
4.359744722206e-18 |
Hartree → joule |
CODATA 2022 |
|
|
Hartree → kJ/mol (≈2625.5) |
derived |
|
|
Hartree → kcal/mol |
derived |
|
627.5094841703362 |
Hartree → kcal/mol (= HARTREE2KCALMOL) |
derived |
|
219474.63 |
Hartree → cm⁻¹ |
CODATA |
|
219474.63136314 |
Hartree → cm⁻¹ (higher precision) |
CODATA 2022 |
|
4.184 |
calorie → joule |
Wikipedia |
|
1.66053906892e-27 |
amu → kg |
CODATA 2022 |
|
299792458.0 |
Speed of light (m/s) |
CODATA 2022 |
|
|
Bohr → Å (alias) |
alias |
|
|
Atomic-unit dipole → debye (≈2.541746) |
derived |
Numerical Thresholds and Scale Constants#
Constant |
Value |
Meaning |
|---|---|---|
|
1.0e-10 |
Threshold for the inverse (and inverse square root) of the auxiliary Coulomb matrix |
|
1.0e-10 |
Matrix inversion threshold |
|
1.0e-10 |
Matrix square-root threshold |
|
1.0e5 – 1.0e9 |
Common order-of-magnitude scale factors |
|
134217728 |
MPI transfer chunk size (about 1 GB) |
libcint Index Constants#
These integer constants are used to access fixed slots in libcint’s bas, atm, and env arrays, and must be kept consistent with libcint’s conventions.
Category |
Constants |
|---|---|
|
|
|
|
ECP-related |
|
|
|
For more details on libcint data structures, refer to the code agent skill rest-libcint-knowledge (if available).
Element Data (element)#
Periodic-table-related data is collected in src/constants/element.rs:
Constant / static |
Type |
Meaning |
|---|---|---|
|
|
Element symbols (H to Og) |
|
|
(atomic mass, nuclear charge) for each element; atomic masses use the IUPAC 2021 standard atomic weights |
|
|
Element symbol lists grouped by period |
|
|
List of transition-metal elements |
|
|
Electron filling configuration of each element in the s/p/d/f shells |
|
|
Occupation templates for each angular-momentum shell (used by SAD and ECP) |
|
|
Shell occupation templates for noble-gas cores |
|
|
Number of electrons each shell can hold |
|
|
Map from element symbol to (mass, charge) ( |
|
|
Map from element symbol to atomic radius (Å) ( |
Usage Conventions#
To keep the codebase consistent, please follow these conventions:
Import constants with
useat the top of the file; do not use fully qualified paths inside function bodies.// Recommended use crate::constants::BOHR; // ... let dist_bohr = dist_ang / BOHR; // Not recommended let dist_bohr = dist_ang / crate::constants::BOHR;
Do not hardcode physical constant values in the code (such as
0.52917721092,27.2114,1822.8885, etc.). Always reference them from theconstantsmodule.If a required constant does not yet exist, add it to
src/constants/mod.rswith a source annotation (e.g. the CODATA year and the corresponding NIST value).
Sources and Updates#
The values of the physical constants are taken from the NIST CODATA database. Historical releases can be verified against the archive files, for example:
https://physics.nist.gov/cuu/Constants/ArchiveASCII/allascii_2010.txt
When updating a constant, indicate the adopted CODATA release year in its inline comment, and record the value change in the commit message so that its impact on computed results (energies, gradients, frequencies, etc.) and regression baselines can be assessed.