Basic calculations
Cutoff energy convergence test
Vary the density cutoff energy e_cut, check the convergence of the total energy and inspect the FFT grid.
Advance/OF-DFT represents the electron density on a uniform real-space grid (FFT grid). Its resolution is determined by the density cutoff energy e_cut, whose default is 150 Hartree (about 4082 eV).
"""
Advance/OF-DFT example: convergence with respect to the cutoff energy.
Copyright (C) 2026 AdvanceSoft Corporation, All rights reserved.
"""
import matplotlib.pyplot as plt
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"
cutoffs = [50, 100, 150, 200, 250, 300] # Hartree
energies = []
for e_cut in cutoffs:
atoms = bulk("Si", crystalstructure="diamond", a=5.43, cubic=True) # 8 atoms
atoms.calc = AOFDFTCalculator(
console = False,
logging_file = f"si_ecut{e_cut}.log",
kin_type = "AS26",
kin_model = "Crystal26",
vps_dir = VPS_DIR,
pao_dir = PAO_DIR,
e_cut = e_cut * Hartree, # e_cut is given in eV
)
energy = atoms.get_potential_energy() / len(atoms)
energies.append(energy)
# the FFT grid that was generated from e_cut
n_grids = atoms.calc.aofdft.lattice.n_grids
print(f"e_cut = {e_cut:4d} Ha grid = {n_grids} E = {energy:.6f} eV/atom")
# energy difference from the largest cutoff, in meV/atom
diffs = [(e - energies[-1]) * 1000.0 for e in energies]
plt.plot(cutoffs, diffs, marker="o")
plt.axhline(0.0, color="gray", linewidth=0.8)
plt.xlabel("Cutoff energy (Hartree)")
plt.ylabel("E - E(300 Ha) (meV/atom)")
plt.tight_layout()
plt.savefig("si_cutoff_convergence.png", dpi=150)
print("Saved si_cutoff_convergence.png")
Example output
e_cut = 50 Ha grid = (32, 32, 32) E = -115.330021 eV/atom
e_cut = 100 Ha grid = (46, 46, 46) E = -115.284157 eV/atom
e_cut = 150 Ha grid = (56, 56, 56) E = -115.263263 eV/atom
e_cut = 200 Ha grid = (65, 65, 65) E = -115.264919 eV/atom
e_cut = 250 Ha grid = (73, 73, 73) E = -115.265763 eV/atom
e_cut = 300 Ha grid = (80, 80, 80) E = -115.265322 eV/atom
Saved si_cutoff_convergence.png

Notes
- The cell is the cubic cell of Si (8 atoms). With v1.0.0 the results change when the cell has a short period, as the primitive cell (2 atoms) does.
e_cutis given in eV. Multiply byase.units.Hartreeto specify it in Hartree.- The FFT grid actually used is available as
calc.aofdft.lattice.n_grids.calc.aofdftis theAOFDFTobject that drives the SCF calculation. - To set the grid directly, pass
n_grids=[na, nb, nc]. Whenn_gridsis given it takes precedence overe_cut. - Compare energies of different structures at the same cutoff energy (or grid density).
- Computation time and memory scale almost linearly with the number of grid points. Note that cells with a vacuum region need many grid points.