xnn.common.models.ops.structure_sum#

xnn.common.models.ops.structure_sum(src, index, dim_size)[source]#

Sum per-atom values into per-structure totals, accumulated in float64.

A float32 total of tens of thousands of atoms is only good to its own rounding, about |E| * 6e-8 (tenths of an eV for 1e4 to 1e5 water atoms), so per-structure energies are summed and returned in float64 whatever the model’s dtype; the per-atom values keep theirs.

Parameters:
  • src (torch.Tensor) – Per-atom values of shape (N,).

  • index (torch.Tensor) – Structure index of every atom, shape (N,).

  • dim_size (int) – Number of structures.

Returns:

Float64 totals of shape (dim_size,).

Return type:

torch.Tensor