kups.core.neighborlist.refine
¶
Refinement neighbor lists that post-process precomputed edges.
These let one expensive base neighbor list be shared across multiple potentials
with different masking rules
(RefineMaskNeighborList)
or tighter cutoffs
(RefineCutoffNeighborList).
PrecomputedEdgesSelector
¶
Selector that wraps precomputed Edges for both refine variants.
Precomputed edges use the same index convention as the call that produced
them: public lh-space edges when an rh remap is supplied, and raw
rh-space indices for a disjoint rh without a remap. Remapped rh
rows are overlaid onto lh before this selector runs.
Attributes:
| Name | Type | Description |
|---|---|---|
candidates |
Edges[Literal[2]]
|
Precomputed edges (indices in lh-space). |
recompute_mic_shifts |
bool
|
When |
Source code in src/kups/core/neighborlist/refine.py
RefineCutoffNeighborList
¶
Refine precomputed edges by re-checking distances with new cutoffs.
This neighbor list takes an existing set of candidate edges and filters them by computing actual distances and comparing to cutoffs. Enables sharing a single conservative neighbor list across multiple potentials with different cutoff distances.
Key benefit: Compute expensive neighbor list once with maximum cutoff, then refine for each potential with its specific cutoff (e.g., Lennard-Jones at 10 Å, Coulomb at 15 Å).
Attributes:
| Name | Type | Description |
|---|---|---|
candidates |
Edges[Literal[2]]
|
Precomputed edges to refine (should be conservative/over-inclusive). |
avg_edges |
Capacity[int]
|
Capacity for output edge array. |
Use cases
- Multiple potentials sharing one neighbor list with different cutoffs
- Multi-stage neighbor list construction (coarse then fine)
- Adaptive cutoffs that change during simulation
- Using a static "super" neighbor list with varying actual cutoffs
Example
# Compute base neighbor list once with maximum cutoff
max_cutoff = 15.0 # Maximum of all potential cutoffs
base_edges = base_nl(particles, None, cells, max_cutoff, None)
# Share across potentials with different cutoffs
lj_nl = RefineCutoffNeighborList(candidates=base_edges, avg_edges=cap1)
lj_edges = lj_nl(particles, None, cells, cutoff=10.0, None) # LJ cutoff
coulomb_nl = RefineCutoffNeighborList(candidates=base_edges, avg_edges=cap2)
coulomb_edges = coulomb_nl(particles, None, cells, cutoff=15.0, None) # Coulomb cutoff
Source code in src/kups/core/neighborlist/refine.py
RefineMaskNeighborList
¶
Refine a precomputed neighbor list by applying inclusion/exclusion masks.
This neighbor list takes an existing set of candidate edges and filters them based on segmentation masks, without recomputing distances. Enables sharing a single base neighbor list across multiple potentials with different interaction rules.
Key benefit: Compute expensive neighbor list once, apply different masks for different potentials (e.g., Lennard-Jones excludes 1-4 interactions, Coulomb has different exclusions).
Attributes:
| Name | Type | Description |
|---|---|---|
candidates |
Edges[Literal[2]]
|
Precomputed edges to refine |
Use cases
- Multiple potentials sharing one neighbor list with different exclusions
- Excluding bonded pairs (1-2, 1-3, 1-4) from non-bonded interactions
- Applying group-specific interaction rules
- Multi-scale simulations with different interaction levels
Example
# Compute base neighbor list once
base_edges = base_nl(particles, None, cells, cutoffs, None)
# Share across potentials with different masks
lj_nl = RefineMaskNeighborList(candidates=base_edges)
lj_edges = lj_nl(lj_particles, None, cells, cutoffs, None) # 1-4 exclusions
coulomb_nl = RefineMaskNeighborList(candidates=base_edges)
coulomb_edges = coulomb_nl(coulomb_particles, None, cells, cutoffs, None) # 1-2 exclusions only