torchref.base.reciprocal.basis module

Reciprocal space basis matrix calculations.

Functions for computing reciprocal lattice vectors and scattering vectors from unit cell parameters.

torchref.base.reciprocal.basis.reciprocal_basis_matrix(cell)[source]

Compute the reciprocal space basis matrix from unit cell parameters.

Parameters:

cell (torch.Tensor) – Cell parameters [a, b, c, alpha, beta, gamma].

Returns:

Reciprocal basis matrix of shape (3, 3) with a*, b*, c* as rows.

Return type:

torch.Tensor

torchref.base.reciprocal.basis.reciprocal_basis_matrix_numpy(cell)[source]

Calculate the reciprocal basis matrix from unit cell parameters (NumPy version).

Computes the reciprocal space basis vectors (a*, b*, c*) that define the transformation from Miller indices to scattering vectors.

Parameters:

cell (numpy.ndarray or list) – Unit cell parameters [a, b, c, alpha, beta, gamma] where lengths are in Angstroms and angles are in degrees.

Returns:

3x3 matrix containing reciprocal basis vectors as rows [a*, b*, c*].

Return type:

numpy.ndarray

torchref.base.reciprocal.basis.get_scattering_vectors(hkl, cell, recB=None)[source]

Calculate scattering vectors from Miller indices.

Parameters:
  • hkl (torch.Tensor) – Miller indices of shape (N, 3).

  • cell (torch.Tensor) – Cell parameters [a, b, c, alpha, beta, gamma].

  • recB (torch.Tensor, optional) – Pre-computed reciprocal basis matrix of shape (3, 3).

Returns:

Scattering vectors of shape (N, 3).

Return type:

torch.Tensor

torchref.base.reciprocal.basis.get_scattering_vectors_numpy(hkl, cell)[source]

Calculate scattering vectors from Miller indices and unit cell (NumPy version).

Transforms Miller indices to reciprocal space scattering vectors using the reciprocal basis matrix.

Parameters:
  • hkl (numpy.ndarray or list) – Miller indices with shape (N, 3).

  • cell (numpy.ndarray or list) – Unit cell parameters [a, b, c, alpha, beta, gamma] where lengths are in Angstroms and angles are in degrees.

Returns:

Scattering vectors in reciprocal space with shape (N, 3).

Return type:

numpy.ndarray

torchref.base.reciprocal.basis.get_s(hkl, cell)[source]

Calculate the magnitude of scattering vectors for given Miller indices.

Computes |s| = 1/d where d is the interplanar spacing for each reflection.

Parameters:
  • hkl (numpy.ndarray) – Miller indices with shape (N, 3).

  • cell (numpy.ndarray or list) – Unit cell parameters [a, b, c, alpha, beta, gamma] where lengths are in Angstroms and angles are in degrees.

Returns:

Magnitude of scattering vectors with shape (N,).

Return type:

numpy.ndarray