Diffraction Module

Overview

freud.diffraction.DiffractionPattern

Computes a 2D diffraction pattern.

Details

The freud.diffraction module provides functions for computing the diffraction pattern of particles in systems with long range order.

Stability

freud.diffraction is unstable. When upgrading from version 2.x to 2.y (y > x), existing freud scripts may need to be updated. The API will be finalized in a future release.

class freud.diffraction.DiffractionPattern(grid_size=512, output_size=None)

Bases: freud.util._Compute

Computes a 2D diffraction pattern.

The diffraction image represents the scattering of incident radiation, and is useful for identifying translational and/or rotational symmetry present in the system. This class computes the static structure factor \(S(\vec{k})\) for a plane of wavevectors \(\vec{k}\) orthogonal to a view axis. The view orientation \((1, 0, 0, 0)\) defaults to looking down the \(z\) axis (at the \(xy\) plane). The points in the system are converted to fractional coordinates, then binned into a grid whose resolution is given by grid_size. A higher grid_size will lead to a higher resolution. The points are convolved with a Gaussian of width \(\sigma\), given by peak_width. This convolution is performed as a multiplication in Fourier space. The computed diffraction pattern can be accessed as a square array of shape (output_size, output_size).

This method is based on the implementations in the open-source GIXStapose application and its predecessor, diffractometer [JJ17].

Parameters
  • grid_size (unsigned int) – Resolution of the diffraction grid (Default value = 512).

  • output_size (unsigned int) – Resolution of the output diffraction image, uses grid_size if not provided or None (Default value = None).

compute(self, system, view_orientation=None, zoom=4, peak_width=1)

Computes diffraction pattern.

Parameters
  • system – Any object that is a valid argument to freud.locality.NeighborQuery.from_system.

  • view_orientation ((\(4\)) numpy.ndarray, optional) – View orientation. Uses \((1, 0, 0, 0)\) if not provided or None (Default value = None).

  • zoom (float) – Scaling factor for incident wavevectors (Default value = 4).

  • peak_width (float) – Width of Gaussian convolved with points, in system length units (Default value = 1).

property diffraction

(output_size, output_size) numpy.ndarray: diffraction pattern.

grid_size

Resolution of the diffraction grid.

Type

int

property k_values

k-values.

Type

(output_size, ) numpy.ndarray

property k_vectors

(output_size, output_size, 3) numpy.ndarray: k-vectors.

output_size

Resolution of the output diffraction image.

Type

int

plot(self, ax=None, cmap='afmhot', vmin=4e-6, vmax=0.7)

Plot Diffraction Pattern.

Parameters
  • ax (matplotlib.axes.Axes, optional) – Axis to plot on. If None, make a new figure and axis. (Default value = None)

  • cmap (str) – Colormap name to use (Default value = 'afmhot').

  • vmin (float) – Minimum of the color scale (Default value = 4e-6).

  • vmax (float) – Maximum of the color scale (Default value = 0.7).

Returns

Axis with the plot.

Return type

(matplotlib.axes.Axes)

to_image(self, cmap='afmhot', vmin=4e-6, vmax=0.7)

Generates image of diffraction pattern.

Parameters
  • cmap (str) – Colormap name to use (Default value = 'afmhot').

  • vmin (float) – Minimum of the color scale (Default value = 4e-6).

  • vmax (float) – Maximum of the color scale (Default value = 0.7).

Returns

RGBA array of pixels.

Return type

((output_size, output_size, 4) numpy.ndarray)