[Paper Review] CellListMap.jl: Efficient and customizable cell list implementation for calculation of pairwise particle properties within a cutoff
CellListMap.jl is a high-performance, customizable Julia package for efficiently computing pairwise particle properties within a cutoff using cell lists. It enables users to define arbitrary functions for distance-dependent calculations—such as potential energies, forces, and velocity distributions—while supporting parallel execution, periodic boundary conditions, automatic differentiation, and unit propagation, achieving performance comparable to state-of-the-art simulation tools.
N-body simulations and trajectory analysis rely on the calculation of attributes that depend on pairwise particle distances within a cutoff. Interparticle potential energies, forces, distribution functions, neighbor lists, and distance-dependent distributions, for example, must be calculated. Cell lists are widely used to avoid computing distances outside the cutoff. However, efficient cell list implementations are difficult to customize. Here, we provide a fast and parallel implementation of cell lists in Julia that allows the mapping of custom functions dependent on particle positions in 2 or 3 dimensions. Arbitrary periodic boundary conditions are supported. Automatic differentiation and unit propagation can be used. The implementation provides a framework for the development of new analysis tools and simulations with custom potentials. The performance of resulting computations is comparable to state-of-the-art implementations of neighbor list algorithms and cell lists, available in specialized software. Examples are provided for the computation of potential energies, forces, distribution of pairwise velocities, neighbor lists and other typical calculations in molecular and astrophysical simulations. The Julia package is freely available at http://m3g.github.io/CellListMap.jl. Interfacing with Python and R with minimal overhead is possible.
Motivation & Objective
- To address the lack of extensible, high-performance cell list implementations for custom particle simulations and trajectory analysis.
- To enable researchers to implement novel pairwise particle properties—like custom potentials or correlation functions—without low-level coding.
- To provide a performant, type-generic framework for 2D and 3D systems with support for periodic boundary conditions.
- To integrate seamlessly with scientific workflows by supporting unit propagation, automatic differentiation, and interoperability with Python and R.
- To offer a user-friendly, high-level interface that maintains performance comparable to specialized simulation software.
Proposed method
- The package uses Julia’s high-level syntax and multiple dispatch to allow users to define custom functions that operate on particle pairs within a distance cutoff.
- It constructs cell lists by partitioning space into grid cells based on the system’s box geometry and cutoff radius, enabling O(n) neighbor search instead of O(n²).
- The core computation is performed via the `map_pairwise` function, which applies a user-defined function to all particle pairs within the cutoff, with automatic parallelization across threads.
- The implementation supports general periodic boundary conditions by computing minimum-image distances between particles.
- It enables type-generic programming, allowing units, uncertainties, and automatic differentiation (via ForwardDiff.jl) to be propagated through calculations.
- Memory efficiency is achieved through optional reuse of output buffers and configurable thread limits for cell list construction and mapping phases.
Experimental results
Research questions
- RQ1Can a high-level, user-extensible framework achieve performance comparable to specialized, low-level neighbor list implementations in particle simulations?
- RQ2How well does the package scale with increasing particle count and number of parallel threads for common calculations like Lennard-Jones potentials and velocity distributions?
- RQ3To what extent can automatic differentiation and unit propagation be integrated into a performant, parallel cell list framework for scientific computing?
- RQ4Can the framework handle large-scale simulations—such as 100 million particles—with reasonable memory and time overhead?
- RQ5How does the performance of cell list construction compare to the mapping phase, and can this bottleneck be mitigated through tuning or architectural improvements?
Key findings
- The package achieves performance comparable to state-of-the-art neighbor list implementations, with linear scaling in computation time as a function of particle count for both serial and parallel execution.
- For a Lennard-Jones potential calculation, the mapping phase scales linearly with the number of particles and up to 128 threads, demonstrating strong parallel efficiency.
- The construction of cell lists scales poorly beyond 8 threads, becoming a performance bottleneck for smaller systems or when the mapping function is inexpensive.
- The framework successfully computed pairwise velocity distributions for 100 million particles using ~70% of available memory and completing in ~30 minutes, outperforming halotools in memory efficiency and scalability.
- The implementation supports advanced features like unit propagation and automatic differentiation without sacrificing performance, enabling derivative-based analysis and uncertainty quantification.
- The package enables interactive, high-level coding of complex simulations and analyses in a few lines of code, with minimal boilerplate and high maintainability.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.