neighbors
Neighbor-list construction for periodic MD.
import mlx_atomistic.neighbors
Classes
Section titled “Classes”NeighborBlocks
Section titled “NeighborBlocks”class NeighborBlocks def __init__(left: mx.array, right: mx.array, valid_mask: mx.array, block_size: int, candidate_count: int, compact_pair_count: int)Fixed-shape candidate pair blocks for MLX-side cutoff filtering.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
left | mx.array | ||
right | mx.array | ||
valid_mask | mx.array | ||
block_size | int | ||
candidate_count | int | ||
compact_pair_count | int |
Properties
block_countint— Number of fixed-size candidate blocks.candidate_waste_countint— Number of emitted block candidates outside the neighbor radius.estimated_bytesint— Estimated storage bytes for block indices and validity mask.padded_candidate_countint— Number of candidate slots including padding.
NeighborList
Section titled “NeighborList”class NeighborList def __init__(pairs: mx.array, cutoff: float, skin: float = 0.0, stats: PairListStats | None = None, blocks: NeighborBlocks | None = None)Neighbor interactions for pairwise potentials.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
pairs | mx.array | ||
cutoff | float | ||
skin | float | 0.0 | |
stats | PairListStats | None | None | |
blocks | NeighborBlocks | None | None |
Properties
backendstr— Pair-construction backend name.candidate_countint | None— Number of candidate interactions tested before cutoff filtering.candidate_waste_countint | None— Number of candidate interactions rejected by compaction/filtering.candidate_waste_fractionfloat | None— Fraction of emitted candidates rejected by compaction/filtering.compact_pair_countint— Number of compact pairs accepted by the neighbor search radius.compaction_backendstr | None— Backend used to compact candidates into explicit pairs, if any.estimated_candidate_bytesint— Estimated bytes for backend candidate testing arrays.estimated_cell_list_bytesint— Estimated bytes for cell-list construction arrays.estimated_compact_pair_bytesint— Estimated bytes for compact int32 pairs accepted by the search radius.estimated_pair_bytesint— Estimated bytes for the compact int32 pair array.fallback_reasonstr | None— Reason an accelerated representation fell back or used a hybrid step.interactionsmx.array | NeighborBlocks— Return the active force-evaluation representation.pair_countint— Number of unique pairs or candidate block entries.representation_kindstr— Neighbor interaction representation shape.
NeighborListManager
Section titled “NeighborListManager”class NeighborListManager def __init__(cell: Cell, cutoff: float, skin: float = 0.3, check_interval: int = 1, sort_pairs: bool = False, max_workers: int | None = None, backend: NeighborBackend = 'auto', max_mlx_dense_atoms: int = DEFAULT_MLX_DENSE_PAIR_LIMIT, block_size: int = DEFAULT_MLX_CELL_BLOCK_SIZE, displacement_check_backend: NeighborCheckBackend = 'numpy', neighbor_list: NeighborList | None = None, reference_positions: mx.array | None = None, rebuild_count: int = 0, last_max_displacement: float = 0.0, updates_since_check: int = 0, rebuild_wall_seconds: float = 0.0, update_wall_seconds: float = 0.0)Manage Verlet neighbor-list rebuilds during an MD trajectory.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
cell | Cell | ||
cutoff | float | ||
skin | float | 0.3 | |
check_interval | int | 1 | |
sort_pairs | bool | False | |
max_workers | int | None | None | |
backend | NeighborBackend | 'auto' | |
max_mlx_dense_atoms | int | DEFAULT_MLX_DENSE_PAIR_LIMIT | |
block_size | int | DEFAULT_MLX_CELL_BLOCK_SIZE | |
displacement_check_backend | NeighborCheckBackend | 'numpy' | |
neighbor_list | NeighborList | None | None | |
reference_positions | mx.array | None | None | |
rebuild_count | int | 0 | |
last_max_displacement | float | 0.0 | |
updates_since_check | int | 0 | |
rebuild_wall_seconds | float | 0.0 | |
update_wall_seconds | float | 0.0 |
Properties
rebuild_thresholdfloat— Maximum displacement before the Verlet list must be rebuilt.
Methods
needs_rebuild
Section titled “needs_rebuild”def needs_rebuild(positions) -> boolReturn true when positions have moved too far from the reference frame.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
positions |
Returns
bool
rebuild
Section titled “rebuild”def rebuild(positions) -> NeighborListForce a neighbor-list rebuild from current positions.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
positions |
Returns
NeighborList
update
Section titled “update”def update(positions) -> NeighborListReturn a current neighbor list, rebuilding if needed.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
positions |
Returns
NeighborList
Functions
Section titled “Functions”build_neighbor_list
Section titled “build_neighbor_list”def build_neighbor_list(positions, cell: Cell, *, cutoff: float, skin: float = 0.3, sort_pairs: bool = True, max_workers: int | None = None, backend: NeighborBackend = 'periodic_cell_list', max_mlx_dense_atoms: int = DEFAULT_MLX_DENSE_PAIR_LIMIT, block_size: int = DEFAULT_MLX_CELL_BLOCK_SIZE) -> NeighborListBuild a periodic cell-list neighbor list with unique i < j pairs.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
positions | |||
cell | Cell | ||
cutoff | float | ||
skin | float | 0.3 | |
sort_pairs | bool | True | |
max_workers | int | None | None | |
backend | NeighborBackend | 'periodic_cell_list' | |
max_mlx_dense_atoms | int | DEFAULT_MLX_DENSE_PAIR_LIMIT | |
block_size | int | DEFAULT_MLX_CELL_BLOCK_SIZE |
Returns
NeighborList
validate_neighbor_backend
Section titled “validate_neighbor_backend”def validate_neighbor_backend(backend: str) -> NeighborBackendValidate and normalize a neighbor-list construction backend.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
backend | str |
Returns
NeighborBackend
validate_neighbor_check_backend
Section titled “validate_neighbor_check_backend”def validate_neighbor_check_backend(backend: str) -> NeighborCheckBackendValidate and normalize a neighbor-list displacement check backend.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
backend | str |
Returns
NeighborCheckBackend