Basic calculations

Your first SCF calculation

Run an SCF calculation for crystalline Si and get the total energy, Fermi energy and atomic forces.

Category
Basic calculations
APIs used
AOFDFTCalculatorkin_typekin_modelget_potential_energyget_forces
Script
si_scf.py

The calculation engine of Advance/OF-DFT is provided as AOFDFTCalculator, a subclass of the ASE Calculator. It is used like any other ASE calculator, in three steps:

  1. build the structure (an Atoms object) with ASE
  2. create an AOFDFTCalculator and assign it to atoms.calc
  3. call a method such as get_potential_energy(), which triggers the SCF calculation
si_scf.pyDownload
"""
Advance/OF-DFT example: SCF calculation of diamond Si (total energy and forces).

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"

# 1) build the structure with ASE: the cubic cell of diamond Si (8 atoms)
atoms = bulk("Si", crystalstructure="diamond", a=5.43, cubic=True)

# 2) attach the calculator
atoms.calc = AOFDFTCalculator(
    kin_type  = "AS26",         # deep-learned kinetic energy functional AdvanceSoft26
    kin_model = "Crystal26",    # pre-trained model for crystals
    vps_dir   = VPS_DIR,        # pseudopotentials
    pao_dir   = PAO_DIR,        # pseudo-atomic orbitals
    e_cut     = 150 * Hartree,  # cutoff energy of the density grid (in eV)
)

# 3) the SCF calculation runs when a property is requested
energy = atoms.get_potential_energy()  # eV
forces = atoms.get_forces()            # eV/Angstrom

print(f"Total energy : {energy:.6f} eV")
print(f"Fermi energy : {atoms.calc.e_fermi:.4f} eV")
print("Forces on atoms (eV/Angstrom):")
print(forces)

Example output

text
Total energy : -922.106107 eV
Fermi energy : -4.1663 eV
Forces on atoms (eV/Angstrom):
[[ 3.41600111e-08  2.29190580e-09  4.39892732e-10]
 [-7.82860179e-08 -2.21783884e-09  4.04976802e-09]
 [ 3.41494729e-08 -2.29382501e-09 -4.33588955e-10]
 [-7.82611585e-08  2.21741511e-09 -4.05374134e-09]
 [-3.41263435e-08  2.29398744e-09 -4.09054015e-10]
 [ 7.82435210e-08 -2.22307330e-09 -4.07185277e-09]
 [-3.41460626e-08 -2.28995788e-09  4.16622376e-10]
 [ 7.82665430e-08  2.22135964e-09  4.06197898e-09]]

In the diamond structure the forces vanish by symmetry, which the output confirms. The numbers may differ slightly depending on the version and the environment.

Notes

  • The cell is the cubic cell of the diamond structure (8 atoms). With v1.0.0 the results change when the cell has a short period, as the primitive cell (2 atoms) does. For a new system, check that a larger cell gives the same result.
  • kin_type="AS26" selects the deep-learned kinetic energy functional AdvanceSoft26. Use kin_model="Crystal26" for crystals and "Molecule26" for molecules.
  • vps_dir and pao_dir point to the pseudopotential (VPS) and pseudo-atomic orbital (PAO) folders shipped with the product.
  • Arguments use the ASE units, eV and Angstrom. To think of e_cut in Hartree, convert it with ase.units, as in 150 * Hartree.
  • The total energy is returned in eV and the forces as a NumPy array in eV/Angstrom.
  • By default the SCF log is printed on the console. See Controlling and monitoring the SCF to write it to a file.