torch_nl_linked_cell¶
- torch_sim.neighbors.torch_nl.torch_nl_linked_cell(positions, cell, pbc, cutoff, system_idx, self_interaction=False)[source]¶
Compute the neighbor list for a set of atomic structures using the linked cell algorithm before applying a strict cutoff.
Positions are wrapped into the primary cell internally for the search; the returned
shifts_idxare corrected so they remain valid for the original (unwrapped) input positions. The input tensor is never modified.This is the recommended default for batched neighbor list calculations as it provides good performance for systems of various sizes using the linked cell algorithm which has O(N) complexity.
- Parameters:
positions (
torch.Tensor [n_atom, 3]) – Cartesian positions (may be unwrapped).cell (
torch.Tensor [n_systems, 3, 3]) – Unit cell vectors.pbc (
torch.Tensor [n_systems, 3] bool) – A tensor indicating the periodic boundary conditions to apply.cutoff (
torch.Tensor) – The cutoff radius used for the neighbor search.system_idx (
torch.Tensor [n_atom,] torch.long) – A tensor containing the index of the structure to which each atom belongs.self_interaction (
bool, optional) – A flag to indicate whether to keep the center atoms as their own neighbors. Default is False.
- Returns:
- mapping (torch.Tensor [2, n_neighbors]):
Pairs of atom indices;
mapping[0]are central atoms,mapping[1]are neighbors.- system_mapping (torch.Tensor [n_neighbors]):
System assignment for each pair.
- shifts_idx (torch.Tensor [n_neighbors, 3]):
Cell shift indices valid for the original input positions.
- Return type:
References