Pysimxrd
Physical simulation of powder X-ray diffraction patterns.
Pysimxrd provides high-level utilities for generating simulated powder XRD profiles from crystal structures stored in ASE database files. It includes a pymatgen-backed simulation path and a WPEM path for diffraction conditions, systematic extinction, multiplicity, structure factors, peak broadening, background, and noise.
Bin Cao, PhD of HKUST(Guangzhou), https://bin-cao.github.io
URL: https://github.com/Bin-Cao/SimXRD
Features
- Simulate powder XRD patterns from ASE database entries.
- Support 2-theta output and d-spacing output.
- Include peak broadening from crystallite size and instrumental effects.
- Add preferred-orientation variation, thermal vibration, background, and noise.
- Provide a WPEM path with symmetry-based extinction and multiplicity handling.
- Support optional random lattice deformation for data augmentation.
Installation
Install from PyPI:
pip install Pysimxrd
Install from the project root:
pip install .
For editable development:
pip install -e .
Quick Start
from ase.db import connect
from Pysimxrd import generator
database = connect("sim/demo_mp.db")
x, y = generator.parser(database, entry_id=1)
print(len(x), len(y))
print(x[:5], y[:5])
Use the WPEM simulation path:
from ase.db import connect
from Pysimxrd import generator
database = connect("sim/demo_mp.db")
x, y = generator.parser(database, entry_id=1, sim_model="WPEM")
Use d-spacing output instead of 2-theta:
x_d, intensity = generator.parser(
database,
entry_id=1,
sim_model="WPEM",
xrd="real",
)
Main API
Pysimxrd.generator.parser
parser(
database,
entry_id,
grainsize=20,
prefect_orientation=[0.1, 0.1],
thermo_vibration=0.1,
zero_shift=0.1,
dis_detector2sample=500,
half_height_slit_detector=5,
half_height_sample=2.5,
deformation=False,
sim_model=None,
xrd="reciprocal",
background_order=6,
background_ratio=0.05,
mixture_noise_ratio=0.02,
lattice_extinction_ratio=0.01,
lattice_torsion_ratio=0.01,
verbose=False,
)
Important arguments:
database: an open ASE database connection.entry_id: row id in the ASE database.sim_model: set to"WPEM"for the WPEM simulation path; useNonefor the pymatgen-backed default path.xrd:"reciprocal"returns 2-theta;"real"returns d-spacing.deformation: applies random lattice deformation for peak-position augmentation.lattice_extinction_ratio: random stretching/compression ratio used whendeformation=True.lattice_torsion_ratio: random shear ratio used whendeformation=True.verbose: prints package and run metadata before simulation.
Returns:
x, y
where x is the simulated x-axis and y is the normalized intensity profile.
WPEM Deformation Behavior
For sim_model="WPEM" with deformation=True, symmetry information is taken
from the undeformed conventional cell:
- space group
- centering symbol
- crystal system
- atom coordinates
The deformed lattice constants are then used for peak position and d-spacing calculation. This keeps the symmetry/extinction logic tied to the original crystal while allowing peak shifts from lattice perturbation.
Package Layout
src/Pysimxrd/
__init__.py
generator.py
CGCNN_atom_emb.json
utils/
MatgenKit.py
WPEMsim.py
funs.py
Development Checks
Run a simple import and smoke test from the repository root:
python -c "from ase.db import connect; from Pysimxrd import generator; db=connect('sim/demo_mp.db'); x,y=generator.parser(db,1); print(len(x), len(y))"
Build a source distribution and wheel:
python setup.py sdist bdist_wheel
Citation
If this package or the associated SimXRD dataset is useful in your work, please cite the related project and repository:
SimXRD / Pysimxrd
Cao Bin
https://github.com/Bin-Cao/SimXRD
License
This project is released under the MIT License. See LICENSE for details.
Metadata
Release files for Pysimxrd 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pysimxrd-1.0.0.tar.gz | 33.1 kB | Without provenance | Details for pysimxrd-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pysimxrd-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for pysimxrd-1.0.0-py3-none-any.whl |
Total release size: 66.4 kB
Release files / pysimxrd-1.0.0.tar.gz
| Download URL | pysimxrd-1.0.0.tar.gz |
|---|---|
| Size | 33.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
91579ac359e59ea72dbea47976c1f99c5658ee6119b7d0ce898aa24aa65d755e
|
|
BLAKE2b-256 checksum How to use checksums |
e9eaeb7ea72e631478ee2447c043e666531a026eefa777b5bf1024de124dfd47
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.19
|
Release files / pysimxrd-1.0.0-py3-none-any.whl
| Download URL | pysimxrd-1.0.0-py3-none-any.whl |
|---|---|
| Size | 33.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
236687f33bb250a57ee74f6bd93c0874ede2da4136045e40cd8bf9f2f43567c2
|
|
BLAKE2b-256 checksum How to use checksums |
6d84d2f55e32ccb96e060f4d848ec4ab30476ec1fab6f80ec6a067366295b55a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.19
|
Security for Pysimxrd 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.