pymatgen.analysis.diffraction.core module
This module implements core classes for calculation of diffraction patterns.
- class AbstractDiffractionPatternCalculator[source]
Bases:
abc.ABC
Abstract base class for computing the diffraction pattern of a crystal.
- abstract get_pattern(structure, scaled=True, two_theta_range=(0, 90))[source]
Calculates the diffraction pattern for a structure.
- Parameters
structure (Structure) – Input structure
scaled (bool) – Whether to return scaled intensities. The maximum peak is set to a value of 100. Defaults to True. Use False if you need the absolute values to combine XRD plots.
two_theta_range ([float of length 2]) – Tuple for range of two_thetas to calculate in degrees. Defaults to (0, 90). Set to None if you want all diffracted beams within the limiting sphere of radius 2 / wavelength.
- Returns
(DiffractionPattern)
- get_plot(structure, two_theta_range=(0, 90), annotate_peaks='compact', ax=None, with_labels=True, fontsize=16)[source]
Returns the diffraction plot as a matplotlib.pyplot.
- Parameters
structure – Input structure
two_theta_range ([float of length 2]) – Tuple for range of two_thetas to calculate in degrees. Defaults to (0, 90). Set to None if you want all diffracted beams within the limiting sphere of radius 2 / wavelength.
annotate_peaks (str or None) – Whether and how to annotate the peaks with hkl indices. Default is ‘compact’, i.e. show short version (oriented vertically), e.g. 100. If ‘full’, show long version, e.g. (1, 0, 0). If None, do not show anything.
ax – matplotlib
Axes
or None if a new figure should be created.with_labels – True to add xlabels and ylabels to the plot.
fontsize – (int) fontsize for peak labels.
- Returns
(matplotlib.pyplot)
- plot_structures(structures, fontsize=6, **kwargs)[source]
Plot diffraction patterns for multiple structures on the same figure.
- Parameters
structures (Structure) – List of structures
two_theta_range ([float of length 2]) – Tuple for range of two_thetas to calculate in degrees. Defaults to (0, 90). Set to None if you want all diffracted beams within the limiting sphere of radius 2 / wavelength.
annotate_peaks (str or None) – Whether and how to annotate the peaks with hkl indices. Default is ‘compact’, i.e. show short version (oriented vertically), e.g. 100. If ‘full’, show long version, e.g. (1, 0, 0). If None, do not show anything.
fontsize – (int) fontsize for peak labels.
Keyword arguments controlling the display of the figure:
kwargs
Meaning
title
Title of the plot (Default: None).
show
True to show the figure (default: True).
savefig
“abc.png” or “abc.eps” to save the figure to a file.
size_kwargs
Dictionary with options passed to fig.set_size_inches e.g. size_kwargs=dict(w=3, h=4)
tight_layout
True to call fig.tight_layout (default: False)
ax_grid
True (False) to add (remove) grid from all axes in fig. Default: None i.e. fig is left unchanged.
ax_annotate
Add labels to subplots e.g. (a), (b). Default: False
fig_close
Close figure. Default: False.
- show_plot(structure, **kwargs)[source]
Shows the diffraction plot.
- Parameters
structure (Structure) – Input structure
two_theta_range ([float of length 2]) – Tuple for range of two_thetas to calculate in degrees. Defaults to (0, 90). Set to None if you want all diffracted beams within the limiting sphere of radius 2 / wavelength.
annotate_peaks (str or None) – Whether and how to annotate the peaks with hkl indices. Default is ‘compact’, i.e. show short version (oriented vertically), e.g. 100. If ‘full’, show long version, e.g. (1, 0, 0). If None, do not show anything.
- class DiffractionPattern(x, y, hkls, d_hkls)[source]
Bases:
pymatgen.core.spectrum.Spectrum
A representation of a diffraction pattern
- Parameters
x – Two theta angles.
y – Intensities
hkls – [{“hkl”: (h, k, l), “multiplicity”: mult}], where {“hkl”: (h, k, l), “multiplicity”: mult} is a dict of Miller indices for all diffracted lattice facets contributing to each intensity.
d_hkls – List of interplanar spacings.