Source code: https://github.com/qzhu2017/PyXtal
Created by Qiang Zhu (2020/11/25)
Last updated: 2022/08/11
An interactive webpage can be found at the following link
# load the necessary libraries
from pyxtal import pyxtal
from pyxtal.XRD import Similarity
from pkg_resources import resource_filename
# specify the path of an experimental structure
cif_nacl = resource_filename("pyxtal", "database/cifs/NaCl.cif")
cif_aspirin = resource_filename("pyxtal", "database/cifs/aspirin.cif")
# load the structure from pyxtal
# if you load the atomic crystal
#xtal1 = pyxtal()
#xtal1.from_seed(seed = cif_nacl)
# to load a molecular crystal, also needs to specify the molecule tag
xtal1 = pyxtal(molecular=True)
xtal1.from_seed(seed=cif_aspirin, molecules=['aspirin'])
print(xtal1)
# visualize the structure
# xtal1.show()
------Crystal from Seed------ Dimension: 3 Composition: [aspirin]4 Group: P 1 21/c 1 (14) 11.2330, 6.5440, 11.2310, 90.0000, 95.8900, 90.0000, monoclinic Wyckoff sites: H8C9O4 @ [ 0.2414 0.5782 0.0168] WP [4e] Site [1] Euler [ 0.0 0.0 0.0]
# compute the xrd project
xrd = xtal1.get_XRD(thetas=[0, 35])
# you can easily access the diffraction information by hkl indices
print(xrd)
2theta d_hkl hkl Intensity Multi 7.912 11.174 [ 1 0 0] 43.69 2 15.693 5.647 [ 1 1 0] 11.94 4 15.694 5.647 [ 0 1 1] 13.85 4 15.863 5.587 [ 2 0 0] 15.35 2 15.866 5.586 [ 0 0 2] 100.00 2 17.002 5.215 [ 1 0 -2] 6.52 2 17.224 5.148 [ 1 1 -1] 1.15 4 17.965 4.938 [ 1 1 1] 2.18 4 18.472 4.803 [ 1 0 2] 1.69 2 20.907 4.249 [ 2 1 0] 8.59 4 20.909 4.249 [ 0 1 2] 22.40 4 21.308 4.170 [ 2 0 -2] 6.03 2 21.791 4.079 [ 2 1 -1] 6.94 4 21.792 4.078 [ 1 1 -2] 1.73 4 22.967 3.872 [ 2 1 1] 49.23 4 22.968 3.872 [ 1 1 2] 46.39 4 23.651 3.762 [ 2 0 2] 17.19 2 23.891 3.725 [ 3 0 0] 2.41 2 25.327 3.517 [ 2 1 -2] 4.51 4 27.255 3.272 [ 0 2 0] 13.80 2 27.346 3.261 [ 2 1 2] 50.63 4 27.384 3.257 [ 3 0 -2] 1.87 2 27.556 3.237 [ 3 1 0] 50.62 4 27.560 3.237 [ 0 1 3] 0.76 4 28.006 3.186 [ 3 1 -1] 5.42 4 28.009 3.186 [ 1 1 -3] 3.34 4 28.423 3.140 [ 1 2 0] 1.21 4 28.424 3.140 [ 0 2 1] 0.02 4 29.322 3.046 [ 1 2 -1] 0.25 4 29.405 3.038 [ 3 1 1] 7.16 4 29.408 3.037 [ 1 1 3] 2.32 4 29.776 3.001 [ 1 2 1] 2.25 4 30.175 2.962 [ 3 0 2] 2.27 2 30.662 2.916 [ 3 1 -2] 6.68 4 30.664 2.916 [ 2 1 -3] 1.43 4 31.691 2.823 [ 2 2 0] 3.22 4 31.693 2.823 [ 0 2 2] 2.77 4 32.040 2.793 [ 4 0 0] 3.69 2 32.046 2.793 [ 0 0 4] 0.02 2 32.230 2.777 [ 1 0 -4] 2.15 2 32.298 2.772 [ 2 2 -1] 0.25 4 32.299 2.772 [ 1 2 -2] 0.18 4 33.127 2.704 [ 2 2 1] 1.38 4 33.128 2.704 [ 1 2 2] 2.22 4 33.203 2.698 [ 3 1 2] 11.60 4 33.204 2.698 [ 2 1 3] 13.36 4 33.872 2.646 [ 1 0 4] 0.00 2 34.390 2.608 [ 4 0 -2] 0.70 2 34.394 2.607 [ 2 0 -4] 2.82 2 34.854 2.574 [ 2 2 -2] 2.34 4 34.923 2.569 [ 4 1 0] 0.01 4 34.929 2.569 [ 0 1 4] 2.85 4
# plot XRD
fig = xrd.plot_pxrd(fontsize=18,
figsize=(16,6),
show_hkl=False,
xlim=[5,36],
width=0.5,
minimum_I=0.1)
# plot XRD
xrd.plotly_pxrd()
This is running on Jupyter Notebook