kups.core.neighborlist.adaptive
¶
Adaptive cutoff neighbor-list construction.
The :func:adaptive_cutoff_neighborlist_from_state factory picks between
:class:DenseNearestNeighborList and :class:CellListNeighborList at
construction time using a static, count-based
:class:CutoffNeighborListPolicy. The returned object is a normal
NeighborList[Literal[2]] — its __call__ runs exactly one algorithm,
with no runtime branching.
The policy intentionally avoids inspecting cutoff values, cell volumes, or perpendicular box lengths: those are unreliable construction-time signals in the current architecture (cells can resize, cutoffs can be bound late). Coarse counts (total particle capacity, number of systems, average occupancy) are stable enough to drive a deterministic choice.
CutoffNeighborListPolicy
¶
Count-based policy for choosing between dense and cell-list.
Carries both the strategy gate and its tunable thresholds. With the
default strategy = AUTO, :meth:choose returns cell-list once the
average particles-per-system reaches
min_avg_particles_per_system_for_cell_list and dense otherwise — the
rough break-even under ordinary molecular densities. DENSE and
CELL_LIST short-circuit the heuristic and force the corresponding
implementation; useful for debugging, benchmarking, and reproducibility.
Attributes:
| Name | Type | Description |
|---|---|---|
strategy |
CutoffNeighborListStrategy
|
|
min_avg_particles_per_system_for_cell_list |
int
|
Average particles per
system at or above which cell-list is chosen under |
Source code in src/kups/core/neighborlist/adaptive.py
choose(num_particles, num_systems)
¶
Return the chosen concrete strategy (never AUTO).
Source code in src/kups/core/neighborlist/adaptive.py
CutoffNeighborListStrategy
¶
Bases: StrEnum
Concrete strategy for adaptive_cutoff_neighborlist_from_state.
AUTO defers to :class:CutoffNeighborListPolicy. The other two
bypass the policy and force the corresponding implementation — useful
for debugging, benchmarking, and reproducibility.
Source code in src/kups/core/neighborlist/adaptive.py
IsAdaptiveCutoffNeighborListState
¶
Bases: Protocol
State protocol consumed by adaptive_cutoff_neighborlist_from_state.
Extends :class:IsNeighborListState with the static shape information
(particle and system counts) needed to evaluate the count-based policy
without inspecting cutoff or cell values.
Source code in src/kups/core/neighborlist/adaptive.py
adaptive_cutoff_neighborlist_from_state(state, cutoffs, *, policy=CutoffNeighborListPolicy())
¶
Construct a cutoff-bound neighbor list using policy.
Returns a concrete :class:DenseNearestNeighborList or
:class:CellListNeighborList. The returned object runs exactly one
algorithm; tracing it does not compile both branches.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
IsAdaptiveCutoffNeighborListState[IsUniversalNeighborlistParams]
|
A state exposing |
required |
cutoffs
|
Table[SystemId, Array]
|
Per-system cutoff table bound onto the returned neighbor list. |
required |
policy
|
CutoffNeighborListPolicy
|
Gate + thresholds. Construct
|
CutoffNeighborListPolicy()
|
Returns:
| Name | Type | Description |
|---|---|---|
A |
NeighborList[Literal[2]]
|
class: |