Basic calculations

Fermi energy and smearing

See how the results depend on the smearing setting, and read the entropy term and the Fermi energy.

Category
Basic calculations
APIs used
smearingdegausswithout_TSsmeared_energye_fermi
Script
fermi_smearing.py

In AOF-DFT the occupations of the atom-wise eigenstates are determined by a smearing function. The method is set with smearing and the width with degauss (in eV).

smearingMethod
"fermi" (default)Fermi-Dirac distribution
"gauss"Gaussian
"m-p"Methfessel-Paxton
"m-v"Marzari-Vanderbilt

In general, leave smearing and degauss at their defaults (smearing="fermi", degauss = 0.02 * Hartree).

In KS-DFT the smearing is a numerical setting that stabilizes the k-point integration, and the results no longer change once the width is small enough. In AOF-DFT the smearing decides how the electrons are distributed over the eigenstates of each atom. A different setting gives a different electron density, so energy differences and the Fermi energy change as well.

The following script shows this for fcc Al and bcc Al. It runs five settings and prints the total energy, the entropy term, the Fermi energy and the energy difference between bcc and fcc.

fermi_smearing.pyDownload
"""
Advance/OF-DFT example: Fermi energy and smearing.

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

from ase.build import bulk
from ase.units import Hartree

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_FCC = 4.05                        # lattice constant of fcc Al (angstrom)
A_BCC = A_FCC / 2.0 ** (1.0 / 3.0)  # bcc Al with the same volume per atom

# (smearing method, width in Hartree)
# In general, use the default in your own calculations. The other settings are listed only
# to show that the results depend on the setting.
settings = [
    ("fermi", 0.02),  # default: Fermi-Dirac, 0.02 Hartree
    ("fermi", 0.01),
    ("gauss", 0.01),  # Gaussian
    ("m-p",   0.01),  # Methfessel-Paxton
    ("m-v",   0.01),  # Marzari-Vanderbilt
]


def calculate(structure, a, smearing, width):
    """Return the total energy and the -TS term per atom, and the Fermi energy of bulk Al (all in eV)."""
    atoms = bulk("Al", structure, a=a).repeat((3, 3, 3))  # 27 atoms

    atoms.calc = AOFDFTCalculator(
        console      = False,
        logging_file = f"al_{structure}_{smearing}_{width}.log",
        kin_type     = "AS26",
        kin_model    = "Crystal26",
        vps_dir      = VPS_DIR,
        pao_dir      = PAO_DIR,
        smearing     = smearing,
        degauss      = width * Hartree,  # smearing width in eV
    )

    energy = atoms.get_potential_energy()  # includes the smearing correction -TS
    calc   = atoms.calc

    return energy / len(atoms), calc.smeared_energy / len(atoms), calc.e_fermi


# E and -TS (per atom) and E_F are the values of fcc Al; the last column is the energy difference bcc - fcc
print(f"{'smearing':8s} {'width/Ha':>8s} {'E (eV/atom)':>13s} {'-TS (eV/atom)':>14s} {'E_F (eV)':>9s} {'bcc - fcc (meV/atom)':>21s}")

for smearing, width in settings:
    e_fcc, minus_ts, e_fermi = calculate("fcc", A_FCC, smearing, width)
    e_bcc, _, _              = calculate("bcc", A_BCC, smearing, width)

    print(f"{smearing:8s} {width:8.3f} {e_fcc:13.6f} {minus_ts:14.6f} {e_fermi:9.4f} {(e_bcc - e_fcc) * 1000.0:21.1f}")

Example output

text
smearing width/Ha   E (eV/atom)  -TS (eV/atom)  E_F (eV)  bcc - fcc (meV/atom)
fermi       0.020    -67.066240      -3.962700   -5.7245                  76.8
fermi       0.010    -65.085062      -1.491082   -5.4938                  68.0
gauss       0.010    -64.273331      -0.318223   -5.3147                  57.6
m-p         0.010    -64.038122      -0.061366   -5.2186                  44.7
m-v         0.010    -64.184098      -0.217504   -5.2432                  55.9

E, -TS and E_F are the values of fcc Al; E and -TS are given per atom. The last column is the energy difference between bcc Al and fcc Al at the same volume per atom. The first row is the default setting.

  • The total energy changes by up to 3.0 eV per atom with the setting. Total energies obtained with different settings cannot be compared.
  • The energy difference between bcc and fcc varies between 45 and 77 meV. Even when both structures are calculated with the same setting, the energy difference depends on which setting is used.
  • The Fermi energy changes by up to 0.51 eV.

Notes

  • If smearing and degauss are not given, the defaults are used.
  • The cells are 3×3×3 repetitions of the primitive cells (27 atoms). With v1.0.0 the results change when the cell has a short period, as the primitive cell (1 atom) does.
  • If you increase degauss because the SCF does not converge, use the same value for all calculations whose energies are compared (see What to do when the SCF does not converge).
  • The total energy returned by get_potential_energy() includes the entropy term -TS of the smearing. -TS is available as calc.smeared_energy and the Fermi energy as calc.e_fermi (both in eV).
  • With without_TS=True the total energy without -TS is returned (-63.103540 eV per atom for fcc Al with the default setting). The SCF result and the Fermi energy do not change.
  • The size of -TS depends on the volume and other conditions. Use the default total energy, which includes -TS, for energy differences and lattice constants.