build_naive_neighborhood¶
- torch_sim.transforms.build_naive_neighborhood(positions, cell, pbc, cutoff, n_atoms, self_interaction)[source]¶
- Build a naive neighborhood list for atoms based on positions
and periodic boundary conditions.
This function computes a neighborhood list of atoms within a specified cutoff distance, considering periodic boundary conditions defined by the unit cell. It returns the mapping of atom pairs, the batch mapping for each structure, and the corresponding shifts.
- Parameters:
positions (Tensor) – A tensor of shape (n_atoms, 3) representing the positions of atoms.
cell (Tensor) – A tensor of shape (n_cells, 3, 3) representing the unit cell matrices.
pbc (Tensor) – A tensor indicating whether periodic boundary conditions are applied.
cutoff (float) – The cutoff distance beyond which atoms are not considered neighbors.
n_atoms (Tensor) – A tensor containing the number of atoms in each structure.
self_interaction (bool) – A flag indicating whether to include self-interactions.
- Returns:
- A tuple containing:
- mapping (torch.Tensor): A tensor of shape (n_pairs, 2)
representing the pairs of indices for neighboring atoms.
- batch_mapping (torch.Tensor): A tensor of shape (n_pairs,)
indicating the structure index for each pair.
- shifts_idx (torch.Tensor): A tensor of shape (n_pairs, 3)
representing the shifts applied for periodic boundary conditions.
- Return type: