Skip to content

Prevent application of constraints in SingleCalculatorNEB which are otherwise applied twice

Oliver Brügner requested to merge GitEdit/ase:SingleCalculatorNEB into master

As I've already mentioned in the ase mailing list (https://listserv.fysik.dtu.dk/pipermail/ase-users/2018-March/004277.html), I've found that any constraint is applied twice in each step of the optimization using SingleCalculatorNEB and I've looked into the code of it (https://wiki.fysik.dtu.dk/ase/_modules/ase/neb.html) and was confused about the method get_energies_and_forces where all the calculators of the images are replaced by the SinglePointCalculator which gets the energy and forces corrected by the constraint:

            if not isinstance(calc, SinglePointCalculator):
                self.images[i].set_calculator(
                    SinglePointCalculator(
                        image,
                        energy=image.get_potential_energy(),
                        forces=image.get_forces()))

Energies and forces which are obtained with this SinglePointCalculator are again corrected by the constraint. This happens for instance one line later in this code:

            self.emax = min(self.emax, image.get_potential_energy())

This bug can be corrected by giving energies and forces to the the SinglePointCalculator, which are not corrected by the constraint, see the changes of this commit.

Merge request reports