nvalchemi.dynamics.hooks.ConvergedSnapshotHook#
- class nvalchemi.dynamics.hooks.ConvergedSnapshotHook(sink, frequency=1, stage=DynamicsStage.ON_CONVERGE)[source]#
Write only newly converged samples to a
DataSink.Fires at
ON_CONVERGEand uses the converged sample indices (available viadynamics._last_converged) to build a boolean mask passed toDataSink.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
FusedStagepipeline, where multiple relaxations run concurrently and structures converge at different steps.- Parameters:
sink (DataSink) – The storage backend to write converged samples to.
ZarrDatais the typical choice for persistent storage.frequency (int, optional) – Execute every
frequencysteps. Default1(check every step that convergence fires).stage (Enum, optional) – The stage at which to run this hook. Default is
DynamicsStage.ON_CONVERGE.
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, stage=DynamicsStage.ON_CONVERGE)[source]#
- Parameters:
sink (DataSink)
frequency (int)
stage (Enum)
- Return type:
None
Methods
__init__(sink[, frequency, stage])