nvalchemi.dynamics.hooks.ConvergedSnapshotHook#

class nvalchemi.dynamics.hooks.ConvergedSnapshotHook(sink, frequency=1)[source]#

Write only newly converged samples to a DataSink.

Fires at ON_CONVERGE and uses the converged sample indices (available via dynamics._last_converged) to build a boolean mask passed to DataSink.write(). Only samples that just satisfied the convergence criterion are written — samples that converged on earlier steps are not re-written.

This is the recommended hook for persisting optimized structures to Zarr in a FusedStage pipeline, where multiple relaxations run concurrently and structures converge at different steps.

Parameters:
  • sink (DataSink) – The storage backend to write converged samples to. ZarrData is the typical choice for persistent storage.

  • frequency (int, optional) – Execute every frequency steps. Default 1 (check every step that convergence fires).

Examples

>>> from nvalchemi.dynamics.hooks import ConvergedSnapshotHook
>>> from nvalchemi.dynamics.sinks import ZarrData
>>> sink = ZarrData(store="converged.zarr", capacity=100_000)
>>> hook = ConvergedSnapshotHook(sink=sink)
>>> dynamics.register_hook(hook)
__init__(sink, frequency=1)[source]#
Parameters:
Return type:

None

Methods

__init__(sink[, frequency])