Rust-accelerated powder X-ray diffraction simulation for high-throughput and machine-learning-driven materials science
arXiv:2602.11709 · doi:10.1107/S1600576726005273
Abstract
High-throughput powder X-ray diffraction (XRD) simulations are a key prerequisite for generating large datasets used in the development of machine-learning models for XRD-based materials analysis. However, the widely used pymatgen powder XRD calculator, implemented entirely in Python, can be computationally inefficient for large-scale workloads, limiting throughput. We present XRD-Rust, a Rust-accelerated implementation of the pymatgen powder XRD calculator that maintains compatibility with existing Python-based workflows. The method retains pymatgen for crystal structure handling while reimplementing the computationally intensive parts of the XRD calculation in Rust, with optional further acceleration via SIMD vectorization and multi-threaded execution across reflections using the Rayon library. Performance benchmarking on two large crystallographic datasets, the Materials Cloud Three-Dimensional Structure Database (MC3D, 33 142 structures) and the Crystallography Open Database (COD, 515 181 structures), demonstrates substantial speedups. For MC3D, XRD-Rust achieves a median serial SIMD speedup of 10.8x (median absolute deviation, MAD, 1.8x), increasing to 15.1x (MAD 3.8x) with 8-thread parallel execution, with a maximum runtime reduction from 40.5 s to 0.9 s. For COD, the median serial SIMD acceleration reaches 10.7x (MAD 4.2x), while 8-thread parallel execution yields 19.5x (MAD 10.0x), with a maximum reduction from 1437 min to 1 min. SIMD vectorization alone provides additional performance gains ranging from a few percent to several tens of percent, depending on the workload and execution mode. Overall, these benchmarks demonstrate that XRD-Rust significantly accelerates powder XRD simulations compared to the original pymatgen implementation, enabling efficient high-throughput dataset generation and improving performance in interactive diffraction analysis applications.