Metadata-Version: 2.2
Name: matscipy-neighbours
Version: 1.0.0
Summary: Neighbour list for particle simulations
License: ### MIT license
         
         Permission is hereby granted, free of charge, to any person obtaining a copy
         of this software and associated documentation files (the "Software"), to deal
         in the Software without restriction, including without limitation the rights
         to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
         copies of the Software, and to permit persons to whom the Software is
         furnished to do so, subject to the following conditions:
         
         The above copyright notice and this permission notice shall be included in
         all copies or substantial portions of the Software.
         
         THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
         IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
         FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
         AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
         LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
         OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
         SOFTWARE.
         
Project-URL: repository, https://github.com/libAtoms/matscipy-neighbours
Requires-Python: >=3.10
Requires-Dist: numpy
Provides-Extra: ase
Requires-Dist: ase; extra == "ase"
Description-Content-Type: text/markdown

# matscipy-neighbours

Fast neighbour lists for particle simulations, with a Python-free C++ core, an
optional CUDA/HIP GPU backend, and zero-copy NumPy/CuPy interop via DLPack.

- **Simple API**: `neighbour_list("ijdDS", …)` returns one array per requested
  quantity (indices `i`, `j`, distance `d`, distance vector `D`, cell shift
  `S`), sorted by `i`.
- **Parallel CPU core** (OpenMP) built from a sorted cell list with a hashed
  compact backend for sparse/vacuum systems.
- **GPU backend** (single-source CUDA/HIP) that keeps results on the device and
  hands them to CuPy/PyTorch/JAX zero-copy through DLPack.
- **General geometry**: triclinic cells, per-direction periodicity, and scalar,
  per-atom, or per-type cutoffs.

This interface is compatible with
[`matscipy.neighbours`](https://github.com/libAtoms/matscipy).

## Quick start (Python)

```python
import numpy as np
from matscipy_neighbours import neighbour_list

positions = np.random.uniform(0, 10, (1000, 3))
cell = np.diag([10.0, 10.0, 10.0])
i, j, D = neighbour_list("ijD", positions=positions, cell=cell, pbc=True, cutoff=2.5)
# D[p] == positions[j[p]] - positions[i[p]] + S @ cell, output sorted by i
```

With a CuPy array in, the GPU backend runs and CuPy arrays come back, with no
host round-trip:

```python
import cupy as cp
i, j, D = neighbour_list("ijD", positions=cp.asarray(positions), cell=cell,
                         pbc=True, cutoff=2.5)
```

## Build

```bash
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --parallel
ctest --test-dir build --output-on-failure
```

Enable a GPU backend (one at a time):

```bash
cmake -S . -B build -DENABLE_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES=80   # NVIDIA
cmake -S . -B build -DENABLE_HIP=ON                                  # AMD
```

## Documentation

Full documentation (installation, Python and C++ APIs, the algorithm and its
references) is at **https://libatoms.github.io/matscipy-neighbours/** and in the
[`docs/`](docs/) folder.

## License

MIT — see [LICENSE.md](LICENSE.md).
