CrysPy is a crystallographic Python library for the analysis of polarized and unpolarized neutron diffraction data, and of X-ray diffraction data. It handles powders and single crystals: nuclear and magnetic structure refinement, local magnetic susceptibility, and the reconstruction of spin and magnetization densities by the maximum entropy method.
- Refinement (RhoChi) of single-crystal and powder data: polarized and unpolarized neutrons, X-rays, 1D and 2D powder patterns, time of flight.
- Magnetic structures in magnetic space groups (
mcif), local magnetic anisotropy by the susceptibility approach. - Spin and magnetization density reconstruction by the maximum entropy method (MEMPy).
- Input and output in
.rcif, a CIF-like format built on the IUCr Core CIF dictionary, so data and results can be archived and exchanged. - Works in scripts and Jupyter notebooks on Windows, macOS and Linux. CrysPy Editor is the graphical user interface for CrysPy.
pip install cryspy # calculations only
pip install cryspy[plot] # + matplotlib for the plot_* methods (Jupyter)
pip install cryspy[view3d] # + py3Dmol: crystal.view_structure() in 3D
pip install cryspy[all] # every optional extraRefine a powder pattern of PbSO4 from examples/:
import cryspy
rcif = cryspy.load_file("examples/rhochi_unpolarized_powder_1d_PbSO4/"
"rhochi_unpolarized_powder_1d_PbSO4.rcif")
result = cryspy.rhochi_rietveld_refinement(rcif) # refines the values marked with ()
print(result["chi_sq"])
print(rcif.crystal_pbso4.cell)
with open("refined.rcif", "w") as fid:
fid.write(rcif.to_cif())More examples, one folder per experiment type, are in examples/.
- Documentation and tutorials: cryspy.fr
- Try CrysPy in a web browser, without installing it: cryspy_webapp on Binder
- Graphical user interface: CrysPy Editor
- Bug reports and feature requests: GitHub issues
- Contributing: CONTRIBUTING.md
MIT License, Copyright (c) 2018-2026 Iurii Kibalin. See LICENSE.