RDF-Rust: Fast calculation of radial distribution functions

📚 If you like the app, please cite: Lebeda, Miroslav, et al. XRDlicious: an interactive web-based platform for online calculation of diffraction patterns and radial distribution functions from crystal structures. Applied Crystallography, 2025, 58.5.

RDF-Rust: Fast calculation of radial distribution functions in Python with a Rust backend

Details at GitHub: https://github.com/bracerino/rdf-rust

RDF-Rust is an open-source Python package with a Rust backend for calculating total and partial radial distribution functions (RDFs and PRDFs) from crystal structures and molecular dynamics trajectories. It directly supports partially occupied sites, parallel computation, and export of plots, animations, and numerical data.

 

⚡ For a benchmark structure containing 13 720 atoms, RDF-Rust was ~100× faster than Matminer on a single core and 340× faster using four cores, and  ~2× faster than Vesin, core for core. Memory usage was less than 1 MB, compared with 3.2 GB for Matminer and 454 MB for Vesin.

The calculator for (P)RDF with RDF-Rust is also available online at: https://prdf-xrdlicious.streamlit.app. Matminer, and Vesin are also available for comparing calculation speeds.

Fig. 1: Total PRDF calculation time as a function of the number of atoms in increasingly large BaTiO₃ supercells. Lower values = 🟢 faster calculations.

Fig. 2: Total used memory during the calculation time as a function of the number of atoms in increasingly large BaTiO₃ supercells. Lower values = 🟢 lower memory requirements.

Install and use the package

pip install rdf-rust
import rdfrust

s = rdfrust.read("BaSrTiO3.cif")                 # reports disorder on stderr
r, partials, total = s.prdf(cutoff=10.0, bin_size=0.1, n_threads=0)

partials[("Ba", "O")]     # numpy array, g_BaO(r)
total                     # number-weighted total RDF
r                         # left edge of each bin