torchref.base.reciprocal.hkl module

Miller index (HKL) operations for crystallography.

Functions for generating Miller indices, computing d-spacings, and other HKL-related calculations.

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

Calculate d-spacing 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:

D-spacing values of shape (N,) in Angstroms.

Return type:

torch.Tensor

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

Compute d-spacing for a batch of Miller indices.

Wrapper around get_d_spacing for convenience.

Parameters:
Returns:

D-spacing values in Angstroms.

Return type:

torch.Tensor, shape (N,)

torchref.base.reciprocal.hkl.generate_possible_hkl(cell, d_min, device=None)[source]

Generate all possible Miller indices within a resolution limit.

Creates a complete set of (h, k, l) indices where the d-spacing is greater than or equal to d_min.

Parameters:
  • cell (torch.Tensor, shape (6,)) – Unit cell parameters [a, b, c, alpha, beta, gamma] in Angstroms and degrees.

  • d_min (float) – High resolution limit in Angstroms (minimum d-spacing).

  • device (torch.device, optional) – Device for computation. If None, uses cell’s device.

Returns:

All Miller indices with d-spacing >= d_min.

Return type:

torch.Tensor, shape (M, 3), dtype int32

Examples

import torch
cell = torch.tensor([50.0, 60.0, 70.0, 90.0, 90.0, 90.0])
hkl = generate_possible_hkl(cell, d_min=2.0)
print(f"Generated {len(hkl)} reflections")