Defects, surfaces and diffusion

Surface energy

Calculate fcc Al(111), (100) and (110) slabs with different numbers of layers and obtain the surface energy from the difference between the slab and bulk energies.

Category
Defects, surfaces and diffusion
APIs used
ase.build.fcc111fcc100fcc110scf_stylemix_precondnumpy.polyfit
Script
surface_energy.py

The surface energy γ is the energy per unit area needed to create a surface by cleaving the crystal. It is used to discuss crystal shapes (Wulff construction) and the stability of thin films and particles. It is obtained from the total energy Eslab of a slab with the same surface on both sides, the number of atoms N in the slab and the bulk energy per atom Ebulk.

γ=Eslab(N)−NEbulk2A

Here A is the area of one surface of the slab. For Ebulk, use a bulk energy calculated under the same conditions as the slabs: different conditions (FFT grid, SCF settings) change the energy per atom slightly, and this difference enters γ in proportion to the number of atoms N. This script calculates a bulk cell with the same orientation as the slab and with the same settings. Ebulk is also given by the slope of a linear fit of Eslab against N, and the two are compared as a check.

surface_energy.pyDownload
"""
Advance/OF-DFT example: surface energy of fcc Al from slab calculations.

    gamma = (E_slab(N) - N * E_bulk) / (2 A)    N: number of atoms in the slab

E_bulk is calculated with a bulk cell that has the orientation of the slab, with
the same SCF parameters as the slabs, so that the slab and bulk energies are
consistent. It is compared with the slope of a linear fit of E_slab against N.

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

import numpy as np
from ase.build import fcc100, fcc110, fcc111

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)
EV_A2  = 16.0218  # 1 eV/Angstrom^2 = 16.0218 J/m^2


def energy(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,
        scf_style     = "bulk",  # the preset for bulk crystals also suits these metal slabs
        mix_precond   = None,    # without the Thomas-Fermi preconditioner of the preset
    )
    return atoms.get_potential_energy()


# (surface, builder, number of layers of the bulk cell: a multiple of the stacking period)
for name, build, n_bulk in (("111", fcc111, 6), ("100", fcc100, 4), ("110", fcc110, 6)):
    # bulk energy per atom: a bulk cell with the same orientation as the slab (periodic=True
    # makes the cell periodic along the surface normal), calculated with the same settings
    bulk_cell = build("Al", size=(2, 2, n_bulk), a=A_LAT, periodic=True)
    e_bulk = energy(bulk_cell, f"al{name}_bulk") / len(bulk_cell)

    n_layers, n_atoms, energies = [], [], []
    for n in (4, 6, 8):
        slab = build("Al", size=(2, 2, n), a=A_LAT, vacuum=8.0)  # 2x2 in the surface plane
        n_layers.append(n)
        n_atoms.append(len(slab))
        energies.append(energy(slab, f"al{name}_{n}"))

    area = np.linalg.norm(np.cross(slab.cell[0], slab.cell[1]))  # Angstrom^2

    print(f"\nAl({name})  area = {area:.3f} A^2, E_bulk = {e_bulk:.4f} eV/atom")
    print("  layers | atoms | E_slab (eV)  | gamma (J/m^2)")
    for n, n_at, e in zip(n_layers, n_atoms, energies):
        gamma = (e - n_at * e_bulk) / (2.0 * area) * EV_A2
        print(f"  {n:6d} | {n_at:5d} | {e:12.4f} | {gamma:.3f}")

    # check with a linear fit: E_slab(N) = N * E_bulk + 2 * gamma * A
    e_bulk_fit, intercept = np.polyfit(n_atoms, energies, 1)
    gamma_fit = intercept / (2.0 * area) * EV_A2
    print(f"  fit: E_bulk = {e_bulk_fit:.4f} eV/atom, gamma = {gamma_fit:.3f} J/m^2", flush=True)

Example output

Results with v1.0.0 (Crystal26).

text
Al(111)  area = 28.410 A^2, E_bulk = -67.0668 eV/atom
  layers | atoms | E_slab (eV)  | gamma (J/m^2)
       4 |    16 |   -1070.9567 | 0.595
       6 |    24 |   -1607.4839 | 0.597
       8 |    32 |   -2144.0166 | 0.598
  fit: E_bulk = -67.0662 eV/atom, gamma = 0.593 J/m^2

Al(100)  area = 32.805 A^2, E_bulk = -67.0666 eV/atom
  layers | atoms | E_slab (eV)  | gamma (J/m^2)
       4 |    16 |   -1069.4026 | 0.895
       6 |    24 |   -1605.9248 | 0.897
       8 |    32 |   -2142.4559 | 0.898
  fit: E_bulk = -67.0658 eV/atom, gamma = 0.892 J/m^2

Al(110)  area = 46.393 A^2, E_bulk = -67.0667 eV/atom
  layers | atoms | E_slab (eV)  | gamma (J/m^2)
       4 |    16 |   -1067.5757 | 0.948
       6 |    24 |   -1604.2109 | 0.931
       8 |    32 |   -2140.7372 | 0.932
  fit: E_bulk = -67.0726 eV/atom, gamma = 0.961 J/m^2

For (111) and (100), γ is almost the same for all numbers of layers and agrees with the value from the fit within 0.006 J/m². The Ebulk from the slope of the fit also agrees with the bulk calculation within 0.001 eV. The surface energy is converged with 4 to 8 layers.

For (110), γ of the 4-layer slab is about 0.02 J/m² larger than for 6 and 8 layers, and the Ebulk from the fit (-67.073 eV/atom) does not agree with the bulk calculation (-67.067 eV/atom). The layer spacing of (110) is only 1.43 Angstrom, so the 4-layer slab is just 4.3 Angstrom thick. The values for 6 and 8 layers agree within 0.001 J/m², so the surface energy is converged from 6 layers.

Notes

  • fcc111("Al", size=(2, 2, n), a=A_LAT, vacuum=8.0) is an n-layer slab with a 2×2 periodicity parallel to the surface (4 atoms per layer). vacuum is the thickness (Angstrom) of the vacuum added on each side of the slab.
  • The 2×2 periodicity parallel to the surface is used because, with v1.0.0, the results change when the cell has a short period, such as 1×1. For a new system, check that a larger cell gives the same result.
  • The bulk energy is calculated with a cell that is also periodic along the surface normal (periodic=True). Its number of layers is a multiple of the stacking period (3 layers for (111), 2 layers for (100) and (110)). Here 6, 4 and 6 layers are used, so that the period along the surface normal is not too short either. With the same orientation as the slab, the FFT grid parallel to the surface is the same as for the slab.
  • The SCF setting is the preset for bulk crystals, scf_style="bulk", without its Thomas-Fermi preconditioner (mix_precond=None). For these slabs the SCF needs fewer iterations without it. The bulk cell is calculated with the same setting. The presets are listed in Controlling and monitoring the SCF.
  • A small difference in Ebulk enters γ in proportion to the number of atoms. For example, an error of 1 meV/atom in Ebulk changes γ of the 8-layer (111) slab (32 atoms) by 0.009 J/m².
  • With few layers, the two surfaces still interact. Check that γ converges with the number of layers. Whether the Ebulk from the fit agrees with the bulk calculation is another indication of convergence.
  • The surface atoms are not relaxed here. For the relaxed surface energy, fix the central layers with FixAtoms and optimize the outer layers (see Adsorption energy and adsorption site).
  • With v1.0.0, CPU calculations of thin slabs can terminate abnormally. Setting the environment variable MKL_CBWR=COMPATIBLE avoids this (the results above were obtained with this setting).
  • 1 eV/Angstrom² = 16.0218 J/m².

Improving the accuracy and SCF convergence of AdvanceSoft26 for systems with surfaces and vacuum is part of the development roadmap.