Skip to main content

Fast XRD pattern calculator with Rust acceleration (5-10x faster than original pymatgen implementation)

Project description

XRD-Rust

Compute powder X-ray diffraction (XRD) patterns using modified pymatgen’s XRDCalculator, with the performance-critical routines reimplemented in Rust, achieving an average ⚡ 4–6× speedup. The larger and more complex your structure (more peaks and atoms), the greater the speedup gains.

The XRD-Rust follows the same notation as the XRDCalculator, with the only change being the renamed class, XRDCalculatorRust. Due to this, it can be easily implemented into existing workflows that use the original pymatgen package for powder XRD pattern calculations. Simply import the XRD-Rust package and replace the class name (see also example below).

Benchmark results (2θ range = 2–60° (Mo radiation)) on two large crystallographic datasets demonstrate the following acceleration:

  • COD (515 181 structures): ⚡ 6.1 ± 4.6× average speedup, up to 719× faster (1437 min (original pymatgen implementation) → 2 min (Rust-accelerated))

  • MC3D (33 142 structures): ⚡ 4.7 ± 1.6× average speedup, up to 25× faster (34.9 s → 1.4 s)

Full benchmarking details are available at: 📖 https://arxiv.org/abs/2602.11709

If you like the package, please cite:

  • For XRD-Rust (arXiv): LEBEDA, Miroslav, et al. Rust-accelerated powder X-ray diffraction simulation for high-throughput and machine-learning-driven materials science. arXiv preprint arXiv:2602.11709, 2026.
  • For pymatgen: ONG, Shyue Ping, et al. Python Materials Genomics (pymatgen): A robust, open-source python library for materials analysis. Computational Materials Science, 2013, 68: 314-319.

How to install it (tested on Python 3.12)

pip install xrd-rust

Example: Calculate powder XRD pattern

from pymatgen.core import Structure
from xrd_rust_calculator import XRDCalculatorRust

# Load structure and calculate powder XRD pattern
structure = Structure.from_file("structure.cif")
calc = XRDCalculatorRust(wavelength="CuKa")
pattern = calc.get_pattern(structure, scaled=False, two_theta_range=(5, 70))

# Save to file
with open("xrd_pattern.csv", 'w') as f:
    f.write("2theta,intensity,hkl\n")
    for i in range(len(pattern.x)):
        hkl = str([tuple(h['hkl']) for h in pattern.hkls[i]])
        f.write(f"{pattern.x[i]},{pattern.y[i]},{hkl}\n")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

xrd_rust-0.3.2-cp313-cp313-manylinux_2_28_x86_64.whl (305.0 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

xrd_rust-0.3.2-cp313-cp313-macosx_11_0_arm64.whl (269.8 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

xrd_rust-0.3.2-cp313-cp313-macosx_10_12_x86_64.whl (275.7 kB view details)

Uploaded CPython 3.13macOS 10.12+ x86-64

xrd_rust-0.3.2-cp312-cp312-manylinux_2_28_x86_64.whl (305.6 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

xrd_rust-0.3.2-cp312-cp312-macosx_11_0_arm64.whl (270.3 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

xrd_rust-0.3.2-cp312-cp312-macosx_10_12_x86_64.whl (276.1 kB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

xrd_rust-0.3.2-cp311-cp311-manylinux_2_28_x86_64.whl (306.7 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

xrd_rust-0.3.2-cp311-cp311-macosx_11_0_arm64.whl (271.1 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

xrd_rust-0.3.2-cp311-cp311-macosx_10_12_x86_64.whl (277.0 kB view details)

Uploaded CPython 3.11macOS 10.12+ x86-64

xrd_rust-0.3.2-cp310-cp310-manylinux_2_28_x86_64.whl (307.0 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

xrd_rust-0.3.2-cp310-cp310-macosx_11_0_arm64.whl (271.3 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

xrd_rust-0.3.2-cp310-cp310-macosx_10_12_x86_64.whl (277.1 kB view details)

Uploaded CPython 3.10macOS 10.12+ x86-64

xrd_rust-0.3.2-cp39-cp39-manylinux_2_28_x86_64.whl (307.3 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.28+ x86-64

xrd_rust-0.3.2-cp39-cp39-macosx_11_0_arm64.whl (271.4 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

xrd_rust-0.3.2-cp39-cp39-macosx_10_12_x86_64.whl (277.4 kB view details)

Uploaded CPython 3.9macOS 10.12+ x86-64

xrd_rust-0.3.2-cp38-cp38-manylinux_2_28_x86_64.whl (307.1 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.28+ x86-64

xrd_rust-0.3.2-cp38-cp38-macosx_11_0_arm64.whl (271.3 kB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64

xrd_rust-0.3.2-cp38-cp38-macosx_10_12_x86_64.whl (277.2 kB view details)

Uploaded CPython 3.8macOS 10.12+ x86-64

File details

Details for the file xrd_rust-0.3.2-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for xrd_rust-0.3.2-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 24732e0905c0107defce92e21b06cc5f7ec70f07af51ba1eac6800f258f65c16
MD5 102c76fccfe0b326b2dfcb33123c84e9
BLAKE2b-256 e3c16391589426f887c6976508f40d4617f26e70ead1d045d0a0424af03a8c23

See more details on using hashes here.

File details

Details for the file xrd_rust-0.3.2-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for xrd_rust-0.3.2-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5a779ca33e35757a53e0feebf0ebf10d19ed0064c4255ae6efc2fe561b18728f
MD5 3457d58442ba295b934276563a0c4d46
BLAKE2b-256 6b60a0295ec7b87f053d10c050ff2d90b2500cb9a4bd53b81df46e312cd88fda

See more details on using hashes here.

File details

Details for the file xrd_rust-0.3.2-cp313-cp313-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for xrd_rust-0.3.2-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 7c9532c3ab006140213d31f99c261bade7cc199fc4a7726c8a95bdb09b9ac464
MD5 42d065482df2f9529400efd19784d0a9
BLAKE2b-256 da920670cabbf7c669bc3a35b0686757a9447ecaf5e1f62b97b0fa3b9c253518

See more details on using hashes here.

File details

Details for the file xrd_rust-0.3.2-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for xrd_rust-0.3.2-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b994127058e983046f1630cea201acd63a9a233e128792d0fb3d52b85c96d4b0
MD5 0d3642742bf531d1c464b9819dd87ed0
BLAKE2b-256 2dfdbc17cbff282f912b957f283d2e1839f1736cccdbc46c88fa0c56e0085e51

See more details on using hashes here.

File details

Details for the file xrd_rust-0.3.2-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for xrd_rust-0.3.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 eafe6b4ecaec743928c95aaf9c5befdfdf9295335905b9b0ada069a2fac69d56
MD5 7eb1fa6d4d23d1337bcc2e777ec66c67
BLAKE2b-256 b3c6ecd77cd808171a41ebd12516eda4c5db21d62545dc620d7a7ef37d5da431

See more details on using hashes here.

File details

Details for the file xrd_rust-0.3.2-cp312-cp312-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for xrd_rust-0.3.2-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 f36165b9413858946105f89980067ed0918cf79eb9b0255e41629448443be439
MD5 d01295e014b660d71eca11d3dd538ceb
BLAKE2b-256 e70cfa50a0f1259a6e3bf075d1511106b790901a8fe692328f891932f4256ef5

See more details on using hashes here.

File details

Details for the file xrd_rust-0.3.2-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for xrd_rust-0.3.2-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4b33b27b1bfb68a0997a9ba96b485d1bee01325d663e2987a7d3e376c332e752
MD5 9e5a368b4232e8fc99bd7a6c329813f2
BLAKE2b-256 f798009372400068f427f1e5323b5fef6cd1aec245dada70531c7039d7918aba

See more details on using hashes here.

File details

Details for the file xrd_rust-0.3.2-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for xrd_rust-0.3.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 81b716ec6cdc20714973965c6fa237239a1f293f45711b1af8c3c0c189202ad3
MD5 e474adc36723499e6d853452ea591577
BLAKE2b-256 dddc4be2bdf201e5bb7b9db3c1b46baa7ece6a66cb2eae7330b31f8120c11fa4

See more details on using hashes here.

File details

Details for the file xrd_rust-0.3.2-cp311-cp311-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for xrd_rust-0.3.2-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 615d9abc621ae68aae0d73c2044a4ea44c9d61d786bafd04ee0c7d8c20efd6c4
MD5 36209a043d30f61be37a348e829fbecb
BLAKE2b-256 e533c54f757ef5846e92a666586406ca74426090bd2664dc17e78c0891d52892

See more details on using hashes here.

File details

Details for the file xrd_rust-0.3.2-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for xrd_rust-0.3.2-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 294efd1e588e29da7f060dec5fc955baa08d5542a913242554c4b16a5d563776
MD5 5e3dd62349bcdf17f19226df7860a366
BLAKE2b-256 d3a9e019f10ba59fa5399194d5f0e028dd3ad9eedff8d2d164f0eb79244d463f

See more details on using hashes here.

File details

Details for the file xrd_rust-0.3.2-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for xrd_rust-0.3.2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3d102b97fa0c94aabe38607e81cc2ccd1aecb219f1d8e0ad5e6065a7cacf91e2
MD5 babe100ecbe5dfbf91aecf62757ec07c
BLAKE2b-256 da4cc46d50841cc2196de7fc3ce1c0567fc07f9b85b02a01c7386f83679aef8b

See more details on using hashes here.

File details

Details for the file xrd_rust-0.3.2-cp310-cp310-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for xrd_rust-0.3.2-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 962b8f53d25f0cbdc8ec39d121c94c54c3aa2d7066207af314a6c173e21d299e
MD5 38cf93ee918093f07a361df0ccc98d31
BLAKE2b-256 9bf546004d0ad000927c70655b28e68ce9348c5c1591aaef540de1f9b13291b3

See more details on using hashes here.

File details

Details for the file xrd_rust-0.3.2-cp39-cp39-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for xrd_rust-0.3.2-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f75bd4133c14bb6715fe4b8079d6914a6e251e1b35999d0f6db84f1fcc1747ba
MD5 f11e8a12df5c3f8c8501c6fa90985d4f
BLAKE2b-256 40ed6bafdaa3f9cabf3c1b99cc91d7fe9708abe80916b0dc33fe9f38d62379e1

See more details on using hashes here.

File details

Details for the file xrd_rust-0.3.2-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for xrd_rust-0.3.2-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7ef616b208f5af7ead02f0ae431dbd825bfb9ec39f156e50bde6f22c517fcc57
MD5 420f4c54a7b7ea1f120cac55b8cecafa
BLAKE2b-256 3ae3e387425885d5ac136c4da987cbb8b6d58d6a8f1fe7ee84f62ad2f6578c6a

See more details on using hashes here.

File details

Details for the file xrd_rust-0.3.2-cp39-cp39-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for xrd_rust-0.3.2-cp39-cp39-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 1b4c7c077d64dee8edad7df2b4d7920007091bd515d371af3ec7edf0122e4b25
MD5 3b4b499fcacec5e69d29e12367dfb346
BLAKE2b-256 83a962ec1f1411c3790e861b72d7f126a61d9e728a69c5d4956c09a10ddd496d

See more details on using hashes here.

File details

Details for the file xrd_rust-0.3.2-cp38-cp38-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for xrd_rust-0.3.2-cp38-cp38-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ab7d326532103099984a0c311810aaeb56a5e70262cfb58d37a15a355c0942f8
MD5 7afa4a12400ee6d840b38605a9ce6d13
BLAKE2b-256 aa977fa64c8891aacaf4b9aa68b70c2d7674eb95fe4edd1de7ab822ed9525b67

See more details on using hashes here.

File details

Details for the file xrd_rust-0.3.2-cp38-cp38-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for xrd_rust-0.3.2-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e17d9581abebddaa0d3e5f936bb0ba39739837669f0d3d24bffc8c6bb73b6369
MD5 52cfc9ebf2f72e50b413b6caf07e0599
BLAKE2b-256 846686b982a2225f13a8df3df4833df5037322b1592e4c2cdd03f8dd9bdb656c

See more details on using hashes here.

File details

Details for the file xrd_rust-0.3.2-cp38-cp38-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for xrd_rust-0.3.2-cp38-cp38-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 5918ffaa9663794b8b6502961d2f97840967c4f48acb38dc62cf41e2a70641d5
MD5 df181ad5b1205e9b81071751b31b5378
BLAKE2b-256 33aac1cb96b1f2ef68fc8827f9bd2645670e03b18eadaa1b23580deee5fd0cdb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page