Defects, surfaces and diffusion

Vacancy migration barrier with the NEB method

Find the path along which a neighbouring atom hops into a vacancy in fcc Al with ASE's climbing-image NEB method, and compute the activation energy of vacancy migration.

Category
Defects, surfaces and diffusion
APIs used
ase.mep.NEBNEBToolsase.optimize.FIREscf_must_conv
Script
neb_diffusion.py

Diffusion of atoms in crystals usually takes place through vacancies. The energy barrier that a neighbouring atom crosses when it hops into a vacancy (the vacancy migration energy Em) determines the temperature dependence of the diffusion coefficient.

The barrier is the maximum (saddle point) along the minimum energy path between the initial and final states. Here ASE's NEB (Nudged Elastic Band) method is used: intermediate structures (images) are placed between the initial and final states, connected by springs, and optimized together to find the minimum energy path. With the climbing-image method, the highest image moves to the saddle point, so the barrier height is obtained accurately.

Procedure

  1. remove one atom from a 3×3×3 primitive supercell (27 sites) to make the initial state with a vacancy
  2. make the final state by moving a nearest neighbour of the vacancy into the vacancy
  3. optimize the initial and final states
  4. interpolate the intermediate images with the IDPP method and optimize them with climbing-image NEB
  5. take the barrier from the energy maximum and plot the energy profile
neb_diffusion.pyDownload
"""
Advance/OF-DFT example: migration barrier of a vacancy in fcc Al with the
nudged elastic band (NEB) method of ASE.

A neighbouring atom hops into the vacancy. The initial and final states are
relaxed first, and the minimum energy path between them is found with the
climbing-image NEB method.

Copyright (C) 2026 AdvanceSoft Corporation, All rights reserved.
"""

import matplotlib.pyplot as plt
import numpy as np
from ase.build import bulk
from ase.mep import NEB, NEBTools
from ase.optimize import BFGS, FIRE

from aofdft.calculator import AOFDFTCalculator

VPS_DIR = "path/to/DFT_DATA19_AS/VPS"  # edit these two paths for your environment
PAO_DIR = "path/to/DFT_DATA19_AS/PAO"

A_LAT    = 4.05  # lattice constant of fcc Al (Angstrom)
N_CELL   = 3     # 3x3x3 primitive cells = 27 sites, 26 atoms with the vacancy
N_IMAGES = 3     # number of intermediate images


def attach_calc(atoms, label):
    atoms.calc = AOFDFTCalculator(
        console       = False,
        logging_file  = f"{label}.log",
        kin_type      = "AS26",
        kin_model     = "Crystal26",
        vps_dir       = VPS_DIR,
        pao_dir       = PAO_DIR,
        scf_must_conv = True,
    )


# 1) initial state: vacancy at site 0
perfect = bulk("Al", "fcc", a=A_LAT).repeat((N_CELL, N_CELL, N_CELL))
dist = perfect.get_distances(0, range(1, len(perfect)), mic=True)
j = 1 + int(np.argmin(dist))  # a nearest neighbour of site 0
hop = perfect.get_distance(j, 0, mic=True, vector=True)  # vector from atom j to the vacancy

initial = perfect.copy()
del initial[0]  # atom j has the index j - 1 from here on

# 2) final state: atom j has moved into the vacancy
final = initial.copy()
final.positions[j - 1] += hop

for atoms, label in ((initial, "initial"), (final, "final")):
    attach_calc(atoms, label)
    BFGS(atoms, logfile=f"{label}_opt.log").run(fmax=0.03)
    print(f"{label:8s} E = {atoms.get_potential_energy():.6f} eV", flush=True)

# 3) NEB: intermediate images by IDPP interpolation, each with its own calculator
images = [initial]
for i in range(N_IMAGES):
    image = initial.copy()
    attach_calc(image, f"image{i + 1}")
    images.append(image)
images.append(final)

neb = NEB(images, climb=True)  # climbing image: the highest image goes to the saddle point
neb.interpolate(method="idpp", mic=True)
FIRE(neb, logfile="neb_opt.log").run(fmax=0.05, steps=300)

# 4) barrier and energy profile
nebtools = NEBTools(images)
barrier, delta_e = nebtools.get_barrier()
print(f"Migration barrier : {barrier:.3f} eV")
print(f"Reaction energy   : {delta_e:.3f} eV")

fig = nebtools.plot_band()
fig.savefig("al_vacancy_neb.png", dpi=150)
print("Saved al_vacancy_neb.png")

Example output

Results with v1.0.0 (Crystal26). The NEB optimization converged in 27 steps.

text
initial  E = -1742.896191 eV
final    E = -1742.892719 eV
Migration barrier : 0.663 eV
Reaction energy   : 0.003 eV
Saved al_vacancy_neb.png
Minimum energy path of vacancy migration in fcc Al (v1.0.0, Crystal26). The points are the energies of the images. The short green line at each point is the slope of the energy, obtained from the component of the atomic forces along the path. The curve interpolates between the points using the energies and these slopes. E_f and E_r at the top are the forward and reverse barriers.
Minimum energy path of vacancy migration in fcc Al (v1.0.0, Crystal26). The points are the energies of the images. The short green line at each point is the slope of the energy, obtained from the component of the atomic forces along the path. The curve interpolates between the points using the energies and these slopes. E_f and E_r at the top are the forward and reverse barriers.

The vacancy migration energy is 0.663 eV. The initial and final states are equivalent by symmetry, so the reaction energy (0.003 eV) is almost zero.

Notes

  • Each intermediate image has its own calculator (by default ASE's NEB does not allow a shared calculator). With one calculator per image, the electronic state converged in the previous step of each image is used as the initial guess of its next SCF calculation.
  • neb.interpolate(method="idpp", mic=True) builds the initial path with the IDPP method, which interpolates interatomic distances linearly. Atoms are less likely to come too close than with plain linear interpolation, which makes the optimization more stable. mic=True uses the nearest periodic images.
  • NEB(images, climb=True) turns on the climbing-image method, so the saddle-point energy is obtained even with few intermediate images.
  • The optimizer FIRE is commonly used for NEB. Convergence (fmax) is judged on the NEB forces (the component of the atomic forces perpendicular to the path plus the spring forces along the path).
  • To reduce the interaction between vacancies, enlarge the supercell and check the convergence of the barrier. The same calculation in a 4×4×4 cell (64 sites) gives a vacancy migration energy of 0.715 eV, which is 0.05 eV larger than in the 27-site cell. In Vacancy formation energy the 27-atom and 64-atom cells differ by 0.004 eV, so the barrier is more sensitive to the cell size.
  • scf_must_conv=True prevents forces from an unconverged SCF from being used in the optimization.