[ase-users] Query about NEB

Eric Hermes ehermes at chem.wisc.edu
Tue Mar 28 22:56:21 CEST 2017


On Tue, 2017-03-28 at 17:40 +0000, Protik Das via ase-users wrote:
> I used the procedure described in the example (https://wiki.fysik.dtu
> .dk/ase/tutorials/neb/diffusion.html#diffusion-tutorial%29.) for my
> calculation. For my case I used vasp as my calculator on 5 images.
> But selecting Tools->NEB in ase-gui does not show any curve and the
> values are all NaN. Also I tried the post processing script on the
> last 5 images. That also shows an error. The way I coded the neb step
> is:
> 
> from ase.constraints import FixAtoms
> from ase.calculators.vasp import Vasp
> from ase.neb import NEB
> from ase.optimize import BFGS
> import ase.io.vasp as vp
> 
> initial = vp.read_vasp('start.vasp') 
> final = vp.read_vasp('end.vasp')
> 
> constraint = FixAtoms(mask=[atom.position[2] < z_thr for atom in
> initial])
> 
> calc1=Vasp(...)
> 
> fmax=0.05
> 
> images = [initial]
> for i in range(3):
>     image = initial.copy()
>     image.set_calculator(calc1)
>     image.set_constraint(constraint)
>     images.append(image)
> 
> images.append(final)
> 
> neb = NEB(images)
> neb.interpolate()
> qn = BFGS(neb, trajectory='traj_neb.traj')
> qn.run(fmax=fmax)
> 
> I tried post-processing with this code:
> 
> import matplotlib.pyplot as plt
> from ase.neb import NEBTools
> from ase.io import read
> 
> images = read('traj_neb.traj at -5:')
> nebtools = NEBTools(images)
> 
> # Get the calculated barrier and the energy change of the reaction.
> Ef, dE = nebtools.get_barrier()
> 
> And getting the following error:
> 
> -------------------------------------------------------------------
> --------
> RuntimeError                              Traceback (most recent call
> last)
> <ipython-input-2-38055ba692ba> in <module>()
>       2 
>       3 # Get the calculated barrier and the energy change of the
> reaction.
> ----> 4 Ef, dE = nebtools.get_barrier()
>       5 
>       6 # # Get the barrier without any interpolation between highest
> images.
> 
> C:\Users\Protik\Miniconda3\envs\ptk.pmg\lib\site-packages\ase\neb.py
> in get_barrier(self, fit, raw)
>     536         without interpolation. Set raw=True to get the raw
> energy of the
>     537         transition state instead of the forward barrier."""
> --> 538         s, E, Sfit, Efit, lines = self.get_fit()
>     539         dE = E[-1] - E[0]
>     540         if fit:
> 
> C:\Users\Protik\Miniconda3\envs\ptk.pmg\lib\site-packages\ase\neb.py
> in get_fit(self)
>     581         images = self._images
>     582         R = [atoms.positions for atoms in images]
> --> 583         E = [atoms.get_potential_energy() for atoms in
> images]
>     584         F = [atoms.get_forces() for atoms in images]
>     585         A = images[0].cell
> 
> C:\Users\Protik\Miniconda3\envs\ptk.pmg\lib\site-packages\ase\neb.py
> in <listcomp>(.0)
>     581         images = self._images
>     582         R = [atoms.positions for atoms in images]
> --> 583         E = [atoms.get_potential_energy() for atoms in
> images]
>     584         F = [atoms.get_forces() for atoms in images]
>     585         A = images[0].cell
> 
> C:\Users\Protik\Miniconda3\envs\ptk.pmg\lib\site-
> packages\ase\atoms.py in get_potential_energy(self, force_consistent,
> apply_constraint)
>     675         """
>     676         if self._calc is None:
> --> 677             raise RuntimeError('Atoms object has no
> calculator.')
>     678         if force_consistent:
>     679             energy = self._calc.get_potential_energy(
> 
> RuntimeError: Atoms object has no calculator.
> 
> For your convenience I have attached the trajectory file. Any idea
> about how I can fix this?

I have several comments about your setup.

First, you are attaching a *single* VASP calculator object to all 3 of your images (we would typically say that your NEB calculation has 3 images, not 5, since we only count the images that are involved in the actual calculation). This will not work the way you want it to! You need to attach a *different* calculator to each object. I would suggest creating the calculator object inside of your loop, and attaching the newly created calculator to the image.

Second, running ASE's NEB algorithm with the regular VASP calculator is *very* inefficient, as VASP has to start and stop at every step of the NEB. This results in a lot of wasted overhead time. You should either use Graeme Henkelman's patches which implement NEB in VASP natively (http://theory.cm.utexas.edu/vtsttools/), or if you are feeling adventurous you could try out the VaspInteractive calculator some other ASE developers and I have been working on. The VaspInteractive calculator is very similar to the regular Vasp calculator, but any keywords which tell VASP to move atoms (e.g. IBRION) are forbidden. It is also currently only available in the ASE gitlab repository.

Third, the trajectory file that ASE's NEB utility creates include the initial and final images. In your case, that means that each iteration will write 5 images to the trajectory, even though only 3 images have calculators attached. The NEB postprocessing tools will only work correctly if your initial and final images have energies, e.g. because you read the geometry from a VASP OUTCAR file which also contained the energies. Otherwise, if you read the initial and final geometries from e.g. a POSCAR (which does *not* contain energies), the NEB postprocessing tools will not work correctly. The error message you are seeing are due to your initial and final images not having energies (which are stored in calculators -- hence "Atoms object has no calculator").

Eric

> -- 
> Protik Das,
> ECE Graduate Student,
> LATTE (http://latte.ece.ucr.edu),
> University of California, Riverside.
> _______________________________________________
> ase-users mailing list
> ase-users at listserv.fysik.dtu.dk
> https://listserv.fysik.dtu.dk/mailman/listinfo/ase-users



More information about the ase-users mailing list