Interatomic
A Rust library for calculating interatomic interactions such as van der Waals, electrostatics, and other two-body or many-body potentials. Designed for molecular simulations with support for SIMD acceleration and spline tabulation.
Features
- Two-body potentials: Lennard-Jones, Mie, Morse, WCA, FENE, Harmonic, Hard Sphere, Ashbaugh-Hatch, Kim-Hummer, Urey-Bradley
- Electrostatics: Ion-ion interactions with Plain Coulomb, Yukawa, and polarization schemes (via coulomb crate)
- Three-body potentials: Harmonic and Cosine angle/torsion potentials
- Four-body potentials: Harmonic and Periodic dihedral potentials
- Combination rules: Lorentz-Berthelot, geometric, arithmetic, and Fender-Halsey mixing rules
- Spline tabulation: Andrea spline for fast potential evaluation
- SIMD support: Vectorized operations via the wide crate
- Serialization: Optional serde support for all potentials
Installation
Add to your Cargo.toml:
[]
= "0.3"
With serde support:
[]
= { = "0.3", = ["serde"] }
Usage
Two-body Potentials
use ;
let epsilon = 1.5; // depth of potential well (kJ/mol)
let sigma = 2.0; // distance at which potential is zero (Å)
let lj = new;
let r_squared = 4.0; // squared distance (Ų)
let energy = lj.isotropic_twobody_energy;
Combining Potentials
Potentials can be combined using static or dynamic dispatch:
use ;
// Static dispatch
let lj = new;
let harmonic = new;
let combined = new;
// Dynamic dispatch with Box
let pot1 = Boxnew as ;
let pot2 = Boxnew as ;
let combined = pot1 + pot2;
Electrostatics
use ELECTRIC_PREFACTOR;
let z1 = 1.0; // charge number
let z2 = -1.0; // charge number
let r = 7.0; // separation (Å)
let rel_dielectric = 80.0; // relative dielectric constant
let energy = ELECTRIC_PREFACTOR * z1 * z2 / ; // kJ/mol
Combination Rules
use CombinationRule;
let rule = LorentzBerthelot;
let = ;
let = ;
let = rule.mix;
Spline Tabulation
For expensive potentials, spline tabulation can significantly improve performance:
use ;
let lj = new;
let config = default;
let cutoff = 12.0;
let splined = with_cutoff;
let energy = splined.isotropic_twobody_energy;
Units
The library uses:
- Distance: Ångström (Å)
- Energy: kJ/mol
License
Licensed under the Apache License, Version 2.0. See LICENSE for details.