xnn.common.data.grid_pairs.grid_pairs#

xnn.common.data.grid_pairs.grid_pairs(pos, cutoff, lengths, shape, capacity=None, span=1, index_dtype=torch.int64, shift_dtype=torch.int64)[source]#

Every pair within cutoff once, as (i, k, shift) with i < k, sorted by i.

Parameters:
  • pos (Tensor) – Cartesian positions (N, 3) on the GPU, wrapped into the cell or not.

  • cutoff (float) – Neighbor cutoff radius.

  • lengths (Tensor) – The edges of the orthorhombic cell (3,).

  • shape (tuple of int or None) – The cells per axis, from grid_shape() with span; None searches without a grid, every atom against those of higher index (a cell too small for one, every edge over cutoff; positions on a GPU, or on the CPU under Triton’s interpreter).

  • capacity (int, optional) – Write the pairs into buffers of this many entries, without reading their number on the host: the entries past it repeat the first pair, and their number comes back on the device (a pair list staged behind a running step).

  • span (int)

  • index_dtype (dtype)

  • shift_dtype (dtype)

Returns:

  • tuple of Tensor – i and k (M,) and the integer image shifts (M, 3), with the displacement pos[k] - pos[i] + shift * lengths; with capacity the buffers (capacity,) and the number of pairs (1,) (more than the capacity when they did not fit).

  • span (int, optional) – The cells per cutoff on each axis (a CPU search; 1 on a GPU).

  • index_dtype, shift_dtype (torch.dtype, optional) – The types of the atom indices and of the shifts (int64 by default).

Return type:

tuple