torchref.base.reciprocal.grid_operations module
Grid operations for reciprocal space.
Functions for placing structure factors on grids and extracting them, which are essential for FFT-based calculations.
- torchref.base.reciprocal.grid_operations.place_on_grid(hkls, structure_factor, grid_size, enforce_hermitian=True)[source]
Place structure factors on a reciprocal-space grid.
Vectorized placement of batched structure factors on reciprocal-space grid.
- Parameters:
hkls (torch.Tensor) – Miller indices of shape (N, 3).
structure_factor (torch.Tensor) – Structure factors of shape (N,) or (B, N) for batched input.
grid_size (tuple or torch.Tensor) – Grid dimensions (Nx, Ny, Nz).
enforce_hermitian (bool, optional) – Whether to enforce Hermitian symmetry. Default is True.
- Returns:
Complex tensor grid of structure factors of shape (Nx, Ny, Nz) or (B, Nx, Ny, Nz) for batched input.
- Return type:
- torchref.base.reciprocal.grid_operations.extract_structure_factor_from_grid(reciprocal_grid, hkls)[source]
Extract structure factors from reciprocal space grid at given Miller indices.
- Parameters:
reciprocal_grid (torch.Tensor) – Complex tensor of shape (Nx, Ny, Nz) or (B, Nx, Ny, Nz).
hkls (torch.Tensor) – Miller indices of shape (N, 3).
- Returns:
Structure factors of shape (N,) or (B, N) for batched input.
- Return type:
- torchref.base.reciprocal.grid_operations.apply_translation_phase(F_calc, hkl, translation_frac)[source]
Apply translation phase shift to structure factors.
For a translation t in fractional coordinates, the structure factor transforms as: F’(hkl) = F(hkl) * exp(2πi * hkl · t)
- Parameters:
F_calc (torch.Tensor) – Complex structure factors of shape (N,).
hkl (torch.Tensor) – Miller indices of shape (N, 3).
translation_frac (torch.Tensor) – Translation vector in fractional coordinates of shape (3,).
- Returns:
Phase-shifted structure factors of shape (N,).
- Return type: