kups.core.neighborlist.common
¶
Shared algorithmic helpers for neighbor list selectors and masks.
Contains:
num_cells— per-axis spatial bin counts (used by the cell-list selector and byparameters.estimate).Candidates— private intermediate struct used inside individual selector algorithms while raw(key_idx, query_idx)index arrays are being built. Not the pipeline carrier (seeCandidateBatch).candidate_image_counts— per-axis periodic-image window width a cutoff reaches; used by_get_candidate_imagesand byparameters.estimate._generate_image_offsets,_get_candidate_images— image-expansion primitives (per-pair anchored windows).replicate_for_images— adapts rawCandidatesinto aCandidateBatchwith shifts andis_minimum_imageset, replicating each pair across its anchored image window whencutoff > perp/2.make_batch_with_mic— pack raw candidates with minimum-image shifts andis_minimum_image=all-True(used by selectors that don't replicate).real_distance_sq— squared real-space distance between candidate pairs given fractional shifts; used byDistanceCutoffMask.
Candidates
¶
Private intermediate produced inside selector algorithms.
Not the pipeline carrier — selectors convert Candidates into a
CandidateBatch (via replicate_for_images or
make_batch_with_mic) before returning.
Source code in src/kups/core/neighborlist/common.py
candidate_image_counts(cells, cutoffs)
¶
Return per-system, per-axis periodic-image window widths.
Each periodic axis needs ceil(2 * cutoff / perpendicular_length)
consecutive integer shifts -- the tight count of lattice planes a sphere of
radius cutoff can reach along that axis under the strict < cutoff
distance mask (the max number of integers in an open interval of that
width). At ratio <= 0.5 this collapses to one image, recovering the
minimum-image convention. Open axes and non-finite ratios use one image.
perpendicular_lengths is the correct per-axis measure for arbitrary
skew (it equals 1 / |column of inverse_vectors|).
Source code in src/kups/core/neighborlist/common.py
candidates_to_batch(candidates, shifts, is_minimum_image)
¶
Pack (candidates, flat shifts, is_min) into a CandidateBatch[2].
Source code in src/kups/core/neighborlist/common.py
lift_query_candidates(candidates, ctx)
¶
Convert query-local self-update candidates to ctx.keys positions.
Source code in src/kups/core/neighborlist/common.py
make_batch_with_mic(candidates, keys, queries, systems)
¶
Pack raw candidates with minimum-image shifts; is_minimum_image=all-True.
Source code in src/kups/core/neighborlist/common.py
real_distance_sq(key_positions, query_positions, frames, shifts)
¶
Squared real-space distance between already-broadcast candidate pairs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key_positions
|
Array
|
Fractional left endpoint positions, shape |
required |
query_positions
|
Array
|
Fractional right endpoint positions, shape |
required |
frames
|
MaterializedFrame
|
Materialized cell frames broadcast to the candidate key system. |
required |
shifts
|
Array
|
|
required |
Returns:
| Type | Description |
|---|---|
Array
|
|
Source code in src/kups/core/neighborlist/common.py
replicate_for_images(candidates, keys, queries, systems, cutoffs, max_image_candidates)
¶
Replicate candidates across their periodic-image windows.
For each candidate pair:
- If cutoff[sys] / perp_axes <= 0.5 on every axis: emit 1 copy with MIC
shifts (the minimum image is the only image in range).
- Otherwise: emit the per-axis window of integer shifts anchored at the pair's
separation (see _get_candidate_images); is_minimum_image flags the
closest copy per pair (via real-distance argmin) so ExclusionMask keeps
non-minimum image periodic copies of excluded pairs. Over-emitted copies are
pruned downstream by DistanceCutoffMask.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
candidates
|
Candidates
|
Raw candidate pair indices. |
required |
keys, queries, systems
|
Pipeline tables (fractional coords). |
required | |
cutoffs
|
Table[SystemId, Array]
|
Per-system cutoff. |
required |
max_image_candidates
|
Capacity[int] | None
|
Capacity for replicated-candidates buffer.
When |
required |
Returns:
| Type | Description |
|---|---|
CandidateBatch[Literal[2]]
|
|