triqs_modest.utils.checkpoint.Checkpointer

class triqs_modest.utils.checkpoint.Checkpointer(dirname, initial_data=None)[source]

MPI-aware checkpoint manager for DMFT calculations.

Enforces saving the minimal restart set (mu, Sigma_imp_list, Sigma_hartree_list) per iteration and optionally stores additional quantities (Green’s functions, density matrices, etc.) in the same HDF5 group via keyword arguments.

All methods are safe to call on all MPI ranks — no is_master_node() guards required in user code. Only the master process performs HDF5 file I/O.

Parameters:
dirnamestr

Path to the checkpoint directory.

initial_datadict, optional

Data to store in initial_data.h5 (e.g. {"obe": obe, "embedding": E}). Ignored if dirname already exists (i.e., when reopening).

Attributes

dirname

Path to the checkpoint directory.

Methods

append(iteration_data, **extras)

Append an iteration to the checkpoint.

restart()

Return last iteration data on all MPI ranks, or None if empty.

Examples

Create or resume, then run the DMFT loop (all ranks):

chkpt    = Checkpointer("my_calc", initial_data={"obe": obe, "Embedding" : E})
last     = chkpt.restart()          # collective — data on all ranks
if last is not None:
    Sigma_dyn    = last.Sigma_imp_list[0]
    Sigma_static = last.Sigma_hartree_list[0]
else:
    Sigma_dyn, Sigma_static = make_zero_self_energies(mesh)

it_shift = len(chkpt)

for n in range(it_shift, n_loops):
    ...
    chkpt.append(
        IterationData(mu=mu, Sigma_imp_list=[Sigma_dyn],
                      Sigma_hartree_list=[Sigma_static]),
        Delta_iw=Delta, Gimp_iw=Gimp, dm=dm,
    )