torchref.base.direct_summation.anisotropic module

Anisotropic structure factor calculations.

Functions for computing structure factors from atomic models with anisotropic (non-spherical) atomic displacement parameters.

torchref.base.direct_summation.anisotropic.aniso_structure_factor_torched(hkl, s_vector, xyz_fractional, occ, scattering_factors, U, spacegroup, max_memory_gb=None, A=None, B_coeff=None)[source]

Calculate anisotropic structure factors using PyTorch.

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

  • s_vector (torch.Tensor) – Scattering vectors of shape (N_reflections, 3).

  • xyz_fractional (torch.Tensor) – Fractional coordinates of shape (N_atoms, 3).

  • occ (torch.Tensor) – Occupancies of shape (N_atoms,).

  • scattering_factors (torch.Tensor or None) – Atomic scattering factors of shape (N_reflections, N_atoms). If None, must provide A and B_coeff to compute them in batches.

  • U (torch.Tensor) – Anisotropic displacement parameters of shape (N_atoms, 6).

  • spacegroup (callable) – Space group symmetry operator function.

  • max_memory_gb (float, optional) – Maximum memory to use in GB. If None, no batching is applied.

  • A (torch.Tensor, optional) – ITC92 A coefficients (N_atoms, 5) for computing scattering factors.

  • B_coeff (torch.Tensor, optional) – ITC92 B coefficients (N_atoms, 5) for computing scattering factors.

Returns:

Complex structure factors of shape (N_reflections,).

Return type:

torch.Tensor

torchref.base.direct_summation.anisotropic.aniso_structure_factor_torched_no_complex(hkl, s_vector, fractional_coords, occ, scattering_factors, U, space_group)[source]

Calculate anisotropic structure factors without complex numbers.

Returns real and imaginary parts as separate rows.

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

  • s_vector (torch.Tensor) – Scattering vectors of shape (N_reflections, 3).

  • fractional_coords (torch.Tensor) – Fractional coordinates of shape (N_atoms, 3).

  • occ (torch.Tensor) – Occupancies of shape (N_atoms,).

  • scattering_factors (torch.Tensor) – Atomic scattering factors of shape (N_reflections, N_atoms).

  • U (torch.Tensor) – Anisotropic displacement parameters of shape (N_atoms, 6).

  • space_group (callable) – Space group symmetry operator function.

Returns:

Structure factors as [real, imag] of shape (2, N_reflections).

Return type:

torch.Tensor