Skip to content
ikibalinPublic

About

A software for polarized neutron diffraction data analysis by a library CrysPy

Resources

Contributing

Stars

11 stars

Watchers

2 watching

Forks

Repository files navigation

CrysPy

PyPI Python Tests License: MIT DOI

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.

Features

  • 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.

Installation

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 extra

Example

Refine 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/.

Links

License

MIT License, Copyright (c) 2018-2026 Iurii Kibalin. See LICENSE.

About

A software for polarized neutron diffraction data analysis by a library CrysPy

Resources

Contributing

Stars

11 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages