pyxtal.XRD module

Module for XRD simulation (experimental stage)

class pyxtal.XRD.Profile(method='mod_pseudo-voigt', res=0.02, user_kwargs=None)[source]

Bases: object

This class applies a profiling function to simulated or experimentally obtained XRD spectra.

  • method (str) – Type of function used to profile

  • res (float) – resolution of the profiling array in degree

  • user_kwargs (dict) – The parameters for the profiling method.

get_profile(two_thetas, intensities, min2theta, max2theta)[source]

Performs profiling with selected function, resolution, and parameters

  • two_thetas (-) – 1d float array simulated/measured 2 theta values

  • intensities (-) – simulated/measures peaks

class pyxtal.XRD.Similarity(f, g, N=None, x_range=None, l=2.0, weight='cosine')[source]

Bases: object


cosine function to weight correlations

show(filename=None, fontsize=None, labels=['profile 1', 'profile 2'])[source]

show the comparison plot

  • filename (None) – name of the xrd plot. If None, show the plot

  • [A (labels) – labels of each plot

  • B] – labels of each plot


Triangle function to weight correlations

class pyxtal.XRD.XRD(crystal, wavelength=1.54184, thetas=[0, 180], res=0.01, per_N=30000, ncpu=1, filename=None, preferred_orientation=False, march_parameter=None)[source]

Bases: object

a class to compute the powder XRD.

  • crystal – ase atoms object

  • wavelength – float

  • max2theta – float

  • per_N – int

  • ncpu – int

  • preferred_orientation – boolean

  • march_parameter – float


3x3 representation -> 1x6 (a, b, c, alpha, beta, gamma)


d for any give abitray [h,k,l] index

static draw_hkl(hkl)[source]

turn negative numbers in hkl to overbar

get_profile(method='gaussian', res=0.01, user_kwargs=None)[source]

return the profile detail


Returns unique families of Miller indices. Families must be permutations of each other. :param hkls: List of Miller indices. :type hkls: [h, k, l]


multiplicity}: A dict with unique hkl and multiplicity.

Return type:


intensity(crystal, TWO_THETA_TOL=1e-05, SCALED_INTENSITY_TOL=1e-05)[source]

This function calculates all that is necessary to find the intensities. This scheme is similar to pymatgen If the number of hkl is significanly large, will automtically switch to the fast mode in which we only calculate the intensity and do not care the exact hkl families

  • TWO_THETA_TOL – tolerance to find repeating angles

  • SCALED_INTENSITY_TOL – threshold for intensities


Load the pxrd from txt file

plot_pxrd(filename=None, profile=None, minimum_I=0.01, show_hkl=True, fontsize=None, figsize=(20, 10), res=0.02, fwhm=0.1, ax=None, xlim=None, width=1.0, legend=None, show=False)[source]

plot PXRD

  • filename (None) – name of the xrd plot. If None, show the plot

  • profile – type of peak profile

  • minimum_I (0.01) – the minimum intensity to include in the plot

  • show_hkl (True) – whether or not show hkl labels

  • fontsize (None) – fontsize of text in the plot

  • figsize ((20, 10)) – figsize

  • xlim (None) – the 2theta range [x_min, x_max]

plotly_pxrd(profile='gaussian', minimum_I=0.01, res=0.02, FWHM=0.1, height=450, html=None)[source]

Group the equivalent hkl planes together by 2 heta angle N*6 arrays, Angle, d_hkl, h, k, l, intensity


savetxt file

pyxtal.XRD.create_index(imax=1, jmax=1, kmax=1)[source]

shortcut to get the index

pyxtal.XRD.gaussian(theta2, alpha, fwhm)[source]

Gaussian function for profiling peaks

pyxtal.XRD.get_all_intensity(N_cycles, N_atom, per_N, positions, hkls, s2s, coeffs, zs)[source]
pyxtal.XRD.get_all_intensity_par(cpu, queue, cycles, Start, End, hkl_per_proc, positions, hkls, s2s, coeffs, zs)[source]
pyxtal.XRD.get_intensity(positions, hkl, s2, coeffs, z)[source]
pyxtal.XRD.lorentzian(theta2, alpha, fwhm)[source]

Lorentzian function for profiling peaks

pyxtal.XRD.mod_pseudo_voigt(x, fwhm, A, eta_h, eta_l, N)[source]

A modified split-type pseudo-Voigt function for profiling peaks - Izumi, F., & Ikeda, T. (2000).

pyxtal.XRD.pseudo_voigt(theta2, alpha, fwhm, eta)[source]

Original Pseudo-Voigt function for profiling peaks - Thompson, D. E. Cox & J. B. Hastings (1986).

pyxtal.XRD.similarity_calculate(r, w, d, Npts, fy, gy)[source]

Compute the similarity between the pair of spectra f, g