Basic calculations

Choosing the kinetic energy functional

Switch between AdvanceSoft26 and the conventional kinetic energy functionals (TFvW, LKT) and compare the results and timings.

Category
Basic calculations
APIs used
kin_typekin_modele_fermi
Script
kinetic_functionals.py

The kinetic energy functional is selected with kin_type. Besides the deep-learned functional AdvanceSoft26, conventional functionals are available for comparison and quick checks.

kin_typeDescription
"AS26"Deep-learned kinetic energy functional AdvanceSoft26. Choose the pre-trained model with kin_model.
"TFvW"Thomas-Fermi-von Weizsäcker functional. The default vW fraction is 1/5.
"LKT"Luo-Karasiev-Trickey functional (GGA type).
kinetic_functionals.pyDownload
"""
Advance/OF-DFT example: choose the kinetic energy functional.

Runs the same Si crystal with AdvanceSoft26 and with the conventional
TF + 1/5 vW and LKT functionals, and prints energy, Fermi energy and timing.

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

import time

from ase.build import bulk

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"

# (label, kin_type, kin_model)
functionals = [
    ("AS26 / Crystal26", "AS26",    "Crystal26"),  # deep-learned functional
    ("TF + 1/5 vW",      "TF1/5vW", None),         # same as kin_type="TFvW"
    ("LKT",              "LKT",     None),         # GGA-type functional
]

print(f"{'functional':18s} {'E_total (eV)':>14s} {'E_Fermi (eV)':>13s} {'time (s)':>9s}")

for label, kin_type, kin_model in functionals:
    atoms = bulk("Si", crystalstructure="diamond", a=5.43, cubic=True)  # 8 atoms

    atoms.calc = AOFDFTCalculator(
        console      = False,
        logging_file = f"si_{kin_type.replace('/', '_')}.log",
        kin_type     = kin_type,
        kin_model    = kin_model,
        vps_dir      = VPS_DIR,
        pao_dir      = PAO_DIR,
    )

    start   = time.time()
    energy  = atoms.get_potential_energy()
    elapsed = time.time() - start

    print(f"{label:18s} {energy:14.4f} {atoms.calc.e_fermi:13.4f} {elapsed:9.1f}")

Example output

text
functional           E_total (eV)  E_Fermi (eV)  time (s)
AS26 / Crystal26        -922.1061       -4.1663      61.2
TF + 1/5 vW             -926.5235       -3.5647      14.9
LKT                     -903.8581       -3.2712      16.1

The results are for the cubic cell of Si (8 atoms). The timings are from a CPU with 4 threads. The AS26 time includes loading the pre-trained models.

Notes

  • The cubic cell is used instead of the primitive cell (2 atoms). With v1.0.0 the results change when the cell has a short period, and this also holds for the conventional functionals.
  • kin_model accepts "Crystal26" (crystals), "Molecule26" (molecules) and "Molecule26-large" (molecules, with an additional larger model).
  • The TFvW mixture can be written in the kin_type string, e.g. "TF1/5vW", "TF0.8vW", "TF" or "vW". "TFvW" is the same as "TF1/5vW".
  • Conventional functionals need no pre-trained model and are fast, but less accurate than AdvanceSoft26. They are handy for checking inputs and estimating the cost of large systems.
  • Accuracy comparisons between functionals are published in the case studies.