Skip to content

WIP: Make calculations exit cleanly before the given wall time limit is reached

Tuomas Rossi requested to merge trossi/gpaw:add-eta into master

Add ETA (estimated time of arrival) class. This class can be used to exit the calculations cleanly before exceeding the given time limit (after which the calculation can be restarted).

This MR implements the feature for SCFLoop and LCAOTDDFT classes. ETA class can be used to break cleanly other time-consuming loops as well.

An example user script for the case of SCF:

# Create ETA object early in the script
# to account all the spent time
from gpaw.utilities.eta import ETA
eta = ETA(timelimit=60)  # 60 seconds time limit

from ase.build import molecule
from gpaw import GPAW
from gpaw import KohnShamConvergenceError

atoms = molecule('H2O')
atoms.center(vacuum=6.0)

# Use tight convergence criterion to
# make this calculation run longer
calc = GPAW(convergence={'density': 1e-12},
            eta=eta,
            txt='gs.out'
            )
atoms.set_calculator(calc)
try:
    energy = atoms.get_potential_energy()
    calc.write('gs.gpw', mode='all')
except KohnShamConvergenceError:
    fname = 'gs_nonconv.gpw'
    calc.write(fname, mode='all')
    print('Did not converge. Use %s to restart.' % fname)
Edited by Tuomas Rossi

Merge request reports