pyextal.symmetry

Symmetry Operations and Grouping.

This module provides tools for handling crystallographic symmetry operations. It includes a class for grouping symmetry-equivalent reflections and functions for applying symmetry operations to find all equivalent reflections for a given vector. The functionalities rely on the spgr common block from the Fortran Bloch wave code, which must be initialized before use.

Classes

GroupSymmetry

Groups symmetry-equivalent beams and manages their relationships.

Functions

appliedSymmetry(gg[, sf])

Calculates symmetry-equivalent reflections and their structure factors.

getSymmetry()

Retrieves the active symmetry operations.

Module Contents

class pyextal.symmetry.GroupSymmetry(beams)

Groups symmetry-equivalent beams and manages their relationships.

This class takes a list of beams (reflections) and groups them based on the crystal’s symmetry operations. It creates a mapping from each beam to its symmetry group and stores the positions of these beams in the Ugh matrix used in Bloch wave calculations.

centro

True if the crystal structure is centrosymmetric.

Type:

bool

beamGroup

A list of lists, where each inner list contains a group of symmetry-equivalent beams.

Type:

list

beam2Group

A mapping from each beam (tuple) to its group index in beamGroup.

Type:

OrderedDict

Ugh_dict

A dictionary mapping a group index to a list of (i, j) positions in the Ugh matrix.

Type:

defaultdict

gp

The symmetry operations from the spgr module.

Type:

np.ndarray

phaseDict

A dictionary to store phase factors for each beam.

Type:

dict

centro
beamGroup = []
beam2Group
Ugh_dict
beamDict
gp
phaseDict
getGroup(beam)

Retrieves the symmetry group for a given beam.

Parameters:

beam (tuple) – The Miller index (h, k, l) of the beam.

Returns:

A list of all beams that are symmetry-equivalent to the input beam.

Return type:

list

getPos(beam)

Yields the Ugh matrix positions for a given beam’s symmetry group.

Parameters:

beam (tuple) – The Miller index (h, k, l) of the beam.

Yields:

tuple[int, int] – The (row, column) indices in the Ugh matrix for each member of the beam’s symmetry group.

pyextal.symmetry.appliedSymmetry(gg, sf=None)

Calculates symmetry-equivalent reflections and their structure factors.

This function applies the crystal’s symmetry operations to a given reflection vector gg to find all unique equivalent reflections. If structure factors sf are provided, it also calculates the corresponding structure factors for each equivalent reflection, including phase shifts.

Note

The spgr module from the Fortran code must be initialized (e.g., by running a simulation) before calling this function.

Parameters:
  • gg (array_like) – A 1D sequence (list, tuple, or np.ndarray) representing the reflection vector (h, k, l).

  • sf (np.ndarray, optional) – A 1D NumPy array of shape (4,) containing the

  • [abs (structure factor components)

  • None. (input reflection gg. Defaults to)

Returns:

  • If sf is None, returns a list of tuples, where each tuple is a symmetry-equivalent reflection (h, k, l).

  • If sf is not None, returns a tuple (ggs, sfs), where ggs is the list of equivalent reflections and sfs is a 2D NumPy array of shape (n_equivalent, 4) containing the transformed structure factors.

Return type:

list[tuple] | tuple[list[tuple], np.ndarray]

Raises:

ValueError – If the spgr.gp symmetry parameters are not initialized or if the input gg is not a 1D sequence.

pyextal.symmetry.getSymmetry()

Retrieves the active symmetry operations.

Returns:

A 2D NumPy array containing the symmetry operations (rotation matrices and translation vectors) from the spgr common block.

Return type:

np.ndarray