Vesin: Fast Neighbor Lists for Atomistic Systems

0.5.4 · active · verified Thu Apr 16

Vesin is a fast and easy-to-use Python library for computing neighbor lists in atomistic systems. It provides interfaces for Python, C, C++, and TorchScript, leveraging highly optimized C++ and CUDA code for performance. The library focuses on efficient calculation of inter-atomic distances and periodic shifts, crucial for molecular simulations and materials science. The current version is 0.5.4, released on April 2, 2026, indicating an active development and release cadence.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize the `NeighborList` calculator, define an atomistic system with positions and a simulation box, and compute neighbor lists including indices, periodic shifts, and distances. It also shows the basic structure for using the ASE-compatible `ase_neighbor_list` function.

import numpy as np
from vesin import NeighborList

# Define positions and box (example for a 2-atom system in a cubic box)
positions = np.array([
    (0.0, 0.0, 0.0),
    (0.5, 0.0, 0.0)
])
box = 3.0 * np.eye(3) # 3x3 Angstrom cubic box
cutoff = 1.0 # Angstroms

# Initialize the NeighborList calculator
calculator = NeighborList(cutoff=cutoff, full_list=True)

# Compute the neighbor list, requesting indices (i, j), periodic shifts (S), and distances (d)
i, j, S, d = calculator.compute(
    points=positions,
    box=box,
    periodic=True, # Enable periodic boundary conditions
    quantities="ijSd"
)

print(f"Neighbor indices (i): {i}")
print(f"Neighbor indices (j): {j}")
print(f"Periodic shifts (S): {S}")
print(f"Distances (d): {d}")

# Example with ASE (requires 'ase' to be installed)
# try:
#     import ase
#     from vesin import ase_neighbor_list
#     atoms = ase.Atoms('H2', positions=[(0,0,0), (0,0,0.74)], cell=[10,10,10], pbc=True)
#     i_ase, j_ase, S_ase, d_ase = ase_neighbor_list("ijSd", atoms, cutoff=1.0)
#     print(f"\nASE-compatible Neighbor indices (i): {i_ase}")
# except ImportError:
#     print("\nASE not installed, skipping ase_neighbor_list example.")

view raw JSON →