nvalchemi.dynamics.hooks.NeighborListHook#
- class nvalchemi.dynamics.hooks.NeighborListHook(config)[source]#
Compute and cache neighbor lists before each model evaluation.
This hook runs at
BEFORE_COMPUTEand writes neighbor data into the batch so that the model’sadapt_inputcan read it. An optional Verlet skin buffer avoids rebuilding the list every step: the list is only recomputed when the maximum atomic displacement since the last build exceedsconfig.skin / 2, or when the set of active systems changes (detected viasystem_id).For
MATRIXformat the following tensors are written to the atoms group of the batch (and thus accessible asbatch.neighbor_matrixetc.):neighbor_matrix— shape(N, max_neighbors), int32num_neighbors— shape(N,), int32neighbor_shifts— shape(N, max_neighbors, 3), int32 (only written when PBC is active)
For
COOformat the edges group of the batch is created or replaced on every rebuild, making the following accessible:batch.edge_index— shape(E, 2), int32 (nvalchemi convention)batch.unit_shifts— shape(E, 3), int32 (only when PBC active)batch.edge_ptr— shape(N+1,), int32, derived on demand via theedge_ptrproperty
- Parameters:
config (NeighborConfig) – Neighbor list configuration read from the model card. The
max_neighborsfield must be set whenformat=MATRIX.- Raises:
ValueError – If
format=MATRIXandconfig.max_neighborsis not set.
Methods
__init__(config)Attributes
frequencystage