standard_nl¶
- torch_sim.neighbors.standard.standard_nl(positions, cell, pbc, cutoff, system_idx, self_interaction=False)[source]¶
Compute neighbor lists using primitive neighbor list algorithm.
- Parameters:
positions (Tensor) – Atomic positions tensor [n_atoms, 3]
cell (Tensor) – Unit cell vectors [n_systems, 3, 3] or [3, 3]
pbc (Tensor) – Boolean tensor [n_systems, 3] or [3]
cutoff (Tensor) – Maximum distance for considering atoms as neighbors
system_idx (Tensor) – Tensor [n_atoms] indicating which system each atom belongs to
self_interaction (bool) – If True, include self-pairs. Default: False
- Returns:
mapping: Tensor [2, num_neighbors] - pairs of atom indices
system_mapping: Tensor [num_neighbors] - system assignment for each pair
shifts_idx: Tensor [num_neighbors, 3] - periodic shift indices
- Return type:
tuple containing
Example
>>> # Single system (all atoms belong to system 0) >>> positions = torch.tensor([[0.0, 0.0, 0.0], [1.0, 0.0, 0.0]]) >>> cell = torch.eye(3) * 10.0 >>> pbc = torch.tensor([True, True, True]) >>> cutoff = torch.tensor(1.5) >>> system_idx = torch.zeros(2, dtype=torch.long) >>> mapping, sys_map, shifts = standard_nl( ... positions, cell, pbc, cutoff, system_idx ... )
>>> # Batched systems >>> positions = torch.randn(20, 3) # 20 atoms total >>> cell = torch.eye(3).repeat(2, 1) * 10.0 # 2 systems >>> system_idx = torch.cat([torch.zeros(10), torch.ones(10)]).long() >>> mapping, sys_map, shifts = standard_nl( ... positions, cell, pbc, cutoff, system_idx ... )
References