"""
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}")
