linkcell
Periodic linked-cell k-nearest neighbour search for molecular simulations.
vesin builds cutoff pair lists. nanoflann builds Euclidean KD-trees without a
minimum-image convention. This crate is the piece those two leave open: the
linked-cell walk of Allen and Tildesley (Computer Simulation of Liquids),
a k-heap per source, shells expanded until the k-th neighbour cannot sit
outside the visited cube. The optional gpulite path runs that walk on a
CUDA device (linkcell::gpu::Workspace); pair lists stay on the device.
It is a LODE library. The Rust crate is the implementation. The C ABI
(lc_*) is the hourglass waist, the same shape as
readcon-core. C++ is a RAII
header over that ABI.
Install
Rust:
cargo add linkcell
C and C++ consumers take the staticlib (--features capi, on by default)
plus include/linkcell.h or include/linkcell.hpp. Meson, CMake, and
pkg-config all install that archive and those headers.
Python takes the same search through DLPack (dlpk). Any __dlpack__()
object (numpy, torch, jax, cupy) is a valid xyz / cell, on any
device. A CUDA xyz stays on device; a CUDA cell is inverted on
device. torch.from_dlpack consumes (indices, dist2).
Wheels: one CPython 3.12 limited-ABI (abi3) artifact per platform, and
one free-threaded set (cp314t; PyO3 0.29 needs 3.14+ for t).
pip install linkcell
import numpy as np
import linkcell
xyz = np.array([[0.2, 0.0, 0.0], [9.4, 0.0, 0.0]], dtype=np.float64)
cell = np.array([10.0, 10.0, 10.0], dtype=np.float64)
nn, d2 = linkcell.knearest(xyz, cell, 1)
nn = np.from_dlpack(nn)
Meson
meson setup build
meson compile -C build
meson install -C build
As a wrap, Meson exposes linkcell_dep:
[wrap-git]
url = https://github.com/d-SEAMS/linkcell.git
revision = v0.3.2
depth = 1
[provide]
linkcell = linkcell_dep
linkcell_dep = dependency('linkcell', fallback: ['linkcell', 'linkcell_dep'])
CMake
cmake -B build -DCMAKE_INSTALL_PREFIX=$PREFIX
cmake --build build
cmake --install build
find_package(linkcell 0.3 REQUIRED)
target_link_libraries(app PRIVATE linkcell::linkcell)
In the same build tree the target is linkcell::linkcell.
pkg-config
pkg-config --cflags --libs linkcell
Both Meson and CMake write linkcell.pc (Libs includes the Rust
sysroot: pthread, dl, m on Linux).
Rust
use linkcell::{knearest, Cell};
let sim = Cell::ortho(10.0, 10.0, 10.0)?;
let sheared = Cell::from_vectors(
[10.0, 0.0, 0.0],
[5.0, 8.66, 0.0],
[0.0, 0.0, 10.0],
[0.0, 0.0, 0.0],
)?;
let xyz = [[0.0, 0.0, 0.0], [1.0, 0.0, 0.0]];
let rows = knearest(&xyz, &sim, 1, None, None)?;
assert_eq!(rows[0].indices, vec![1]);
mask[i] == false removes a point as both a source and a candidate.
cell_hint is the target cell edge; None uses 3.0 in the box units.
C
#include "linkcell.h"
double xyz[] = {0.0, 0.0, 0.0, 1.0, 0.0, 0.0};
lc_cell box = lc_cell_ortho(10.0, 10.0, 10.0);
int out[2];
if (lc_knearest(xyz, 2, &box, 1, NULL, 0.0, out) != 0) {
return 1;
}
n and k are size_t. out has length n * k. Unused slots are -1.
Neighbours of source i are out[i*k + 0 ..], nearest first.
C++
#include "linkcell.hpp"
const linkcell::Cell box = linkcell::Cell::ortho(10.0, 10.0, 10.0);
const double xyz[] = {0.0, 0.0, 0.0, 1.0, 0.0, 0.0};
const linkcell::Neighbours nn = linkcell::knearest(xyz, 2, box, 1);
nn owns the packed n * k buffer. Unused slots are -1.
nn.neighbour(i, j) is the j-th neighbour of i. Failure throws
linkcell::Error.
The optional device walk reads occupancy from the environment:
LINKCELL_TPP (threads per particle) and LINKCELL_BLOCK (CUDA
block size). Unset, the library picks a pair that maximises particles
per block under the device thread and 48 KiB shared-memory limits.
d-SEAMS writes the same keys from SEAMS_CONFIG / seams --tpp.
Docs
| Quadrant | Page |
|---|---|
| Tutorial | Two points |
| How-to | Embed from C, Embed from C++, pkg-config |
| Reference | C ABI, Algorithm |
| Explanation | MIC and cells |
Rust API: docs.rs/linkcell. Map: docs/index.md.
Design
- The cell is a general parallelepiped: three lattice vectors plus an
origin. Orthorhombic boxes are
Cell::ortho/lc_cell_ortho. Binning is in fractional space, so a sheared dump is not treated as orthogonal. - Points fold into the primary cell once. Each source then walks
Chebyshev shells of neighbour cells. Pair distances are a Cartesian
subtract plus that cell's lattice translation (
dist2_shiftedandlattice_shift), the vesin / LAMMPS ghost construction. Orthorhombic boxes use three independent wraps and skip the two Hinv matvecs. - One lattice shift per unique cell is wrong unless every wrap of that cell is visited. The walk visits integer cell offsets, so each wrap of a bin is a separate visit.
- The search does not take a cutoff. A cell-size hint only sets the bin width. Shells grow until the k-heap is exact.
- vesin remains the right library for a cutoff pair list.
License
MIT
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file linkcell-0.3.2.tar.gz.
File metadata
- Download URL: linkcell-0.3.2.tar.gz
- Upload date:
- Size: 188.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4bcc573d0560fbd76ba88100949063cefda5d069fc7c30d5fb30fb72a2a2d06e
|
|
| MD5 |
bdf8437f95f08f2b6864b938c5a97821
|
|
| BLAKE2b-256 |
af7e43db8938d6aad1f3da5f5532471d2dcd1681d647299cc79e83233f9947e6
|
Provenance
The following attestation bundles were made for linkcell-0.3.2.tar.gz:
Publisher:
wheels.yml on d-SEAMS/linkcell
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
linkcell-0.3.2.tar.gz -
Subject digest:
4bcc573d0560fbd76ba88100949063cefda5d069fc7c30d5fb30fb72a2a2d06e - Sigstore transparency entry: 2497071668
- Sigstore integration time:
-
Permalink:
d-SEAMS/linkcell@3352d93e816077e3855303abfa424da83058cbcb -
Branch / Tag:
refs/tags/v0.3.2 - Owner: https://github.com/d-SEAMS
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@3352d93e816077e3855303abfa424da83058cbcb -
Trigger Event:
push
-
Statement type:
File details
Details for the file linkcell-0.3.2-cp314-cp314t-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: linkcell-0.3.2-cp314-cp314t-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 372.1 kB
- Tags: CPython 3.14t, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c579da91f03226c1dd1666b1654c4317b13f1ce1fcfab9c9093876d60105556f
|
|
| MD5 |
0b9c6b679b0fc128d75c1373788f372a
|
|
| BLAKE2b-256 |
5edccdb556d473677962c6838c19e90157341f5c30a589615858b5cb1fea33e5
|
Provenance
The following attestation bundles were made for linkcell-0.3.2-cp314-cp314t-manylinux_2_28_x86_64.whl:
Publisher:
wheels.yml on d-SEAMS/linkcell
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
linkcell-0.3.2-cp314-cp314t-manylinux_2_28_x86_64.whl -
Subject digest:
c579da91f03226c1dd1666b1654c4317b13f1ce1fcfab9c9093876d60105556f - Sigstore transparency entry: 2497071724
- Sigstore integration time:
-
Permalink:
d-SEAMS/linkcell@3352d93e816077e3855303abfa424da83058cbcb -
Branch / Tag:
refs/tags/v0.3.2 - Owner: https://github.com/d-SEAMS
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@3352d93e816077e3855303abfa424da83058cbcb -
Trigger Event:
push
-
Statement type:
File details
Details for the file linkcell-0.3.2-cp314-cp314t-manylinux_2_28_aarch64.whl.
File metadata
- Download URL: linkcell-0.3.2-cp314-cp314t-manylinux_2_28_aarch64.whl
- Upload date:
- Size: 357.8 kB
- Tags: CPython 3.14t, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
db2d1c98d1db4295b41eddd4e0ac93c06bece6d1961b2a1f5862fef0756c276a
|
|
| MD5 |
71cc34699f43ae1a98c6adaadb22d3d9
|
|
| BLAKE2b-256 |
422e36aca49be7933f49b9fbf243942de1a0f422f14f70b2a1287895b9c8ca13
|
Provenance
The following attestation bundles were made for linkcell-0.3.2-cp314-cp314t-manylinux_2_28_aarch64.whl:
Publisher:
wheels.yml on d-SEAMS/linkcell
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
linkcell-0.3.2-cp314-cp314t-manylinux_2_28_aarch64.whl -
Subject digest:
db2d1c98d1db4295b41eddd4e0ac93c06bece6d1961b2a1f5862fef0756c276a - Sigstore transparency entry: 2497071816
- Sigstore integration time:
-
Permalink:
d-SEAMS/linkcell@3352d93e816077e3855303abfa424da83058cbcb -
Branch / Tag:
refs/tags/v0.3.2 - Owner: https://github.com/d-SEAMS
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@3352d93e816077e3855303abfa424da83058cbcb -
Trigger Event:
push
-
Statement type:
File details
Details for the file linkcell-0.3.2-cp314-cp314t-macosx_11_0_arm64.whl.
File metadata
- Download URL: linkcell-0.3.2-cp314-cp314t-macosx_11_0_arm64.whl
- Upload date:
- Size: 325.4 kB
- Tags: CPython 3.14t, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fb1292f4838ff71bc71c87634887bcd36555d381ad61b9e0593bcc88d9123475
|
|
| MD5 |
80ddc2a3764ba3af3e05eb073a6ab53d
|
|
| BLAKE2b-256 |
49e4c7175535c38c01651fc37bee16ce59a7ac2f6dfb6671dfcfbcc4e18e8d11
|
Provenance
The following attestation bundles were made for linkcell-0.3.2-cp314-cp314t-macosx_11_0_arm64.whl:
Publisher:
wheels.yml on d-SEAMS/linkcell
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
linkcell-0.3.2-cp314-cp314t-macosx_11_0_arm64.whl -
Subject digest:
fb1292f4838ff71bc71c87634887bcd36555d381ad61b9e0593bcc88d9123475 - Sigstore transparency entry: 2497071856
- Sigstore integration time:
-
Permalink:
d-SEAMS/linkcell@3352d93e816077e3855303abfa424da83058cbcb -
Branch / Tag:
refs/tags/v0.3.2 - Owner: https://github.com/d-SEAMS
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@3352d93e816077e3855303abfa424da83058cbcb -
Trigger Event:
push
-
Statement type:
File details
Details for the file linkcell-0.3.2-cp312-abi3-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: linkcell-0.3.2-cp312-abi3-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 371.7 kB
- Tags: CPython 3.12+, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e4c8b3cf2a62135434b2f437d1642881dce5fa43b58fb3254688aa36399ac8be
|
|
| MD5 |
cc30a37490b97c86b17671492c1722ac
|
|
| BLAKE2b-256 |
d018d93ed2e2d6c4d9b062a7ad7efba8ee6143613faffe9bcaa3f3090c7eb5da
|
Provenance
The following attestation bundles were made for linkcell-0.3.2-cp312-abi3-manylinux_2_28_x86_64.whl:
Publisher:
wheels.yml on d-SEAMS/linkcell
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
linkcell-0.3.2-cp312-abi3-manylinux_2_28_x86_64.whl -
Subject digest:
e4c8b3cf2a62135434b2f437d1642881dce5fa43b58fb3254688aa36399ac8be - Sigstore transparency entry: 2497071953
- Sigstore integration time:
-
Permalink:
d-SEAMS/linkcell@3352d93e816077e3855303abfa424da83058cbcb -
Branch / Tag:
refs/tags/v0.3.2 - Owner: https://github.com/d-SEAMS
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@3352d93e816077e3855303abfa424da83058cbcb -
Trigger Event:
push
-
Statement type:
File details
Details for the file linkcell-0.3.2-cp312-abi3-manylinux_2_28_aarch64.whl.
File metadata
- Download URL: linkcell-0.3.2-cp312-abi3-manylinux_2_28_aarch64.whl
- Upload date:
- Size: 357.1 kB
- Tags: CPython 3.12+, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a1d0aef36721c7df1043fbc526112bed9bc1fc01ca13fd8ab028db4ef5a0999
|
|
| MD5 |
e016e1678d1c2784521b9ffa9749095d
|
|
| BLAKE2b-256 |
f5e9464fd92b09bd0a40dab6f8020fb6898c4a9a26f9810dfbe08cd12e695f61
|
Provenance
The following attestation bundles were made for linkcell-0.3.2-cp312-abi3-manylinux_2_28_aarch64.whl:
Publisher:
wheels.yml on d-SEAMS/linkcell
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
linkcell-0.3.2-cp312-abi3-manylinux_2_28_aarch64.whl -
Subject digest:
9a1d0aef36721c7df1043fbc526112bed9bc1fc01ca13fd8ab028db4ef5a0999 - Sigstore transparency entry: 2497071773
- Sigstore integration time:
-
Permalink:
d-SEAMS/linkcell@3352d93e816077e3855303abfa424da83058cbcb -
Branch / Tag:
refs/tags/v0.3.2 - Owner: https://github.com/d-SEAMS
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@3352d93e816077e3855303abfa424da83058cbcb -
Trigger Event:
push
-
Statement type:
File details
Details for the file linkcell-0.3.2-cp312-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: linkcell-0.3.2-cp312-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 324.9 kB
- Tags: CPython 3.12+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4b496a3212a96afb307ee8f0f111a7ecb12179e0fa84e627c6a0229909fa4f64
|
|
| MD5 |
12d0d85a9b5a6db0ba32c1b7c006eff2
|
|
| BLAKE2b-256 |
2fa16267b054c7812cc3225e81108fb324bdd871bf3e989f4e10cbf7e8802e7e
|
Provenance
The following attestation bundles were made for linkcell-0.3.2-cp312-abi3-macosx_11_0_arm64.whl:
Publisher:
wheels.yml on d-SEAMS/linkcell
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
linkcell-0.3.2-cp312-abi3-macosx_11_0_arm64.whl -
Subject digest:
4b496a3212a96afb307ee8f0f111a7ecb12179e0fa84e627c6a0229909fa4f64 - Sigstore transparency entry: 2497071901
- Sigstore integration time:
-
Permalink:
d-SEAMS/linkcell@3352d93e816077e3855303abfa424da83058cbcb -
Branch / Tag:
refs/tags/v0.3.2 - Owner: https://github.com/d-SEAMS
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@3352d93e816077e3855303abfa424da83058cbcb -
Trigger Event:
push
-
Statement type: