[go: up one dir, main page]

Bug in AutoNEB

Checklist

Minimal Example

import os

from ase import Atoms
from ase.io import write
from ase.calculators.lj import LennardJones
from ase.optimize import LBFGS
from ase.mep.autoneb import AutoNEB

from tempfile import TemporaryDirectory

def attach_calculators(images):
    for image in images:
        image.calc = LennardJones(rc=10)

with TemporaryDirectory() as tmp_dir:
    atoms = Atoms("ArHeNe", [(-4.484, 0., 0.),
                             (0.198, 0., 0.),
                             (3.286, 0., 0.)])
    atoms.calc = LennardJones(rc=10)
    optimizer = LBFGS(atoms)
    optimizer.run(steps=100)
    write(os.path.join(tmp_dir, "minimal000.traj"), atoms, format="traj")

    atoms.set_positions([(-3.286, 0., 0.),
                         (-0.198, 0., 0.),
                         (4.484, 0., 0.)])
    optimizer.run(steps=100)
    write(os.path.join(tmp_dir, "minimal001.traj"), atoms, format="traj")

    neb = AutoNEB(attach_calculators,
                  os.path.join(tmp_dir, "minimal"),
                  3,
                  11,
                  remove_rotation_and_translation=False, # Setting this to True breaks
                  parallel=False,
                  smooth_curve=True,
                  climb=True,
                  iter_folder=tmp_dir,
                  maxsteps=[100, 200],
                  interpolate_method='linear')
    neb.run()
    for energy in neb.get_energies():
        print(float(energy))
    write("finished-neb.xyz", neb.all_images)

Summary

The minimal example shows a very basic NEB of a He atom travelling from the vicinity of a Neon to an Argon atom, using only an LJ potential. AutoNEB breaks upon setting "remove_rotation_and_translation" to "True" due to the use of SinglePointCalculator instances to store energy values. The SinglePointCalculator inherently sees the removal of Rotation/Translation as a change in coordinates and invalidates the "energy" field, breaking the calculation. The energy is, of course, not changed in the removal of external rotations and translations, thus making this an unwanted behavior.

Two Solution proposals:

  1. Change the internals of AutoNEB to determine energy values after the removal step
  2. Stop using SinglePointCalculator instances and instead use something else that behaves correctly in case the flag was set to "True"
Edited by Dew Berryants