kups.core.neighborlist.cell_list_cache
¶
Persistent cell occupants shared by neighbor lists and fused pair evaluation.
Reuses cell-list binning and updates occupants after accepted particle moves.
CellListCache
¶
Bases: NamedTuple
Slot-sorted particle rows with per-cell occupancy and stencil tables.
Slots 0 .. n-1 hold the particles, slots up to n_pad are padding,
and slot n_pad is the inactive sentinel filling empty table entries.
Inactive rows occupy no cell entry and emit no candidates.
Attributes:
| Name | Type | Description |
|---|---|---|
rows |
CellRows[Data]
|
Per-slot rows, leaves |
slot_of_row |
Array
|
Slot of each original particle row, |
cells |
Array
|
Slot ids per cell, |
stencil |
Array
|
Neighbor cell ids per cell, |
bins |
Array
|
Per-system bin counts, |
Source code in src/kups/core/neighborlist/cell_list_cache.py
267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 | |
max_cells_per_system
property
¶
Allocated capacity, derived from the stored array shapes.
bin_rows(particles, systems, data)
¶
Bin further particles (e.g. proposal queries) into this table's cells.
Source code in src/kups/core/neighborlist/cell_list_cache.py
candidate_chunks(cell, chunk_size)
¶
Group candidate columns into blocks, with a leading chunk axis.
Columns from every neighboring cell share a block. Entirely unused
blocks can be skipped without reducing cell occupancy capacity.
The shape is (n_chunks, *cell.shape, stencil_width * chunk_size);
the last block is sentinel-padded.
Source code in src/kups/core/neighborlist/cell_list_cache.py
candidates(cell)
¶
Candidate slots of the given cells, (..., stencil_width * cell_capacity).
Source code in src/kups/core/neighborlist/cell_list_cache.py
select(ctx)
¶
Look up occupants for CellListSelector using the stored grid.
The cache must correspond to ctx.keys in original row order.
Candidate ids are mapped back to those rows; the shared selector uses
original coordinates when computing periodic shifts.
Source code in src/kups/core/neighborlist/cell_list_cache.py
CellListCacheParameters
¶
Static shapes of a cell table.
Attributes:
| Name | Type | Description |
|---|---|---|
chunk_size |
int
|
Query rows processed per local scan step; the padded slot count is a multiple of it. |
max_cells_per_system |
int
|
Capacity for spatial bins per system
( |
cell_capacity |
int
|
Maximum active particles per bin (asserted). |
stencil_width |
int
|
Distinct neighbor cells per cell. 27 is always valid;
with fewer than three bins along an axis the stencil wraps onto
duplicates and |
key_chunk_size |
int | None
|
Optional keys per block: columns of each neighboring cell
for |
key_layout |
Literal['cells', 'slots']
|
Read neighboring cells, or traverse all particle slots. Slot traversal still applies the exact distance and pair masks. |
max_images_per_pair |
int
|
Capacity for each pair's periodic-image window. Estimated from the cutoff and cell geometry; one in the minimum-image regime. |
Source code in src/kups/core/neighborlist/cell_list_cache.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | |
estimate(particles, systems, cutoffs, *, chunk_size=64, occupancy_factor=2.0, occupancy_headroom=32, key_chunk_size=None, key_layout='cells')
classmethod
¶
Estimate parameters from a concrete state.
Sizes cell_capacity from the exact per-cell occupancy of the
active particles with multiplicative and additive headroom to absorb
density growth (e.g. GCMC insertions); violations at runtime fail the
assertions in build_cell_list_cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
particles
|
Table[ParticleId, NeighborListPoints]
|
Current (possibly buffered) particle table. |
required |
systems
|
Table[SystemId, HasCell[AnyPeriodicity]]
|
System table with cells. |
required |
cutoffs
|
Table[SystemId, Array]
|
Per-system cutoff radii. |
required |
chunk_size
|
int
|
Query rows per local scan step. |
64
|
occupancy_factor
|
float
|
Multiplier on the observed maximum occupancy. |
2.0
|
occupancy_headroom
|
int
|
Additive slack on top of the scaled occupancy. |
32
|
key_chunk_size
|
int | Literal['auto'] | None
|
Keys per block, or |
None
|
key_layout
|
Literal['cells', 'slots', 'auto']
|
|
'cells'
|
Returns:
| Type | Description |
|---|---|
Self
|
Static parameters for the table. |
Source code in src/kups/core/neighborlist/cell_list_cache.py
CellListCacheUpdatePatch
¶
Bases: Patch[State]
Accept-conditional update of a persistent cell table.
Accepted rows refresh their coordinates and payload. Only rows changing
cells are removed and reinserted (overflow asserted); moves within a cell
retain membership. An entirely rejected proposal skips both operations.
Slots retain their original row identity, so slot_of_row stays valid.
Spatial sort order is not maintained after moves. Changed rows are grouped
by destination cell to assign insertion ranks with linear storage.
Attributes:
| Name | Type | Description |
|---|---|---|
slots |
Array
|
Slots of the changed rows, |
system_idx |
Index[SystemId]
|
Original proposal system ids for acceptance; |
new |
CellRows[Data]
|
Rows after the update, leaves |
lens |
Lens[State, CellListCache[Data]]
|
Lens to the cell table in the state. |
Source code in src/kups/core/neighborlist/cell_list_cache.py
479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 | |
CellRows
¶
Bases: NamedTuple
Binned particle rows: what a cell table stores per slot.
Attributes:
| Name | Type | Description |
|---|---|---|
frac |
Array
|
Folded fractional positions, |
system |
Index[SystemId]
|
System index (0 where inactive). |
inclusion |
Index[InclusionId]
|
Inclusion index; out of bounds for inactive rows. |
exclusion |
Index[ExclusionId]
|
Exclusion index. |
data |
Data
|
Caller payload (e.g. kernel features), leaves |
cell |
Array
|
Global cell id; the sentinel cell where inactive. |
Source code in src/kups/core/neighborlist/cell_list_cache.py
positions
property
¶
Fractional coordinates for the neighbor pipeline.
concatenate(*parts)
staticmethod
¶
Join rows, aligning index vocabularies and preserving count bounds.
Source code in src/kups/core/neighborlist/cell_list_cache.py
pad(padding, *, sentinel_cell)
¶
Append inactive rows with finite geometry and zero-filled payloads.
Source code in src/kups/core/neighborlist/cell_list_cache.py
build_cell_list_cache(particles, systems, cutoffs, data, parameters)
¶
Bin, sort, and tabulate the particles of a point cloud.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
particles
|
Table[ParticleId, NeighborListPoints]
|
Particle table (positions, system, inclusion, exclusion). |
required |
systems
|
Table[SystemId, HasCell[AnyPeriodicity]]
|
System table with cells. |
required |
cutoffs
|
Table[SystemId, Array]
|
Per-system cutoff radii sizing the bins. |
required |
data
|
Data
|
Per-particle payload to carry per slot, leaves |
required |
parameters
|
CellListCacheParameters
|
Static table shapes. |
required |
Returns:
| Type | Description |
|---|---|
CellListCache[Data]
|
The cell table. |
Source code in src/kups/core/neighborlist/cell_list_cache.py
cell_candidates(keys, queries, index, systems, cutoffs, max_images_per_pair)
¶
Adapt a cell-table query to the standard neighbor pipeline.
index contains key slots per query row. The same adapter handles
within-system query pairs, so geometry and masks have a single implementation.
Periodic images expand only this chunk, with capacity bounded per pair.
Source code in src/kups/core/neighborlist/cell_list_cache.py
cell_rows(particles, systems, bins, max_cells, data)
¶
Fold and bin particles into global cells system * max_cells + local.
Particles with an out-of-bounds inclusion index (the buffered-row
convention) are inactive and land in the sentinel cell n_systems *
max_cells.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
particles
|
Table[ParticleId, NeighborListPoints]
|
Particle table (positions, system, inclusion, exclusion). |
required |
systems
|
Table[SystemId, HasCell[AnyPeriodicity]]
|
System table with cells. |
required |
bins
|
Array
|
Per-system bin counts, |
required |
max_cells
|
int
|
Allocated cell capacity per system. |
required |
data
|
Data
|
Per-particle payload carried along. |
required |
Returns:
| Type | Description |
|---|---|
CellRows[Data]
|
The binned rows. |