ASE calculator

ferric.ase.FerricCalculator is an ASE calculator. Any ASE tool that takes a calculator can run on ferric's surfaces with it: the optimizers in ase.optimize, vibrations, NEB, molecular dynamics, and the programs that accept an ASE calculator (geomeTRIC's --engine ase, Sella, i-PI through ase.calculators.socketio).

ASE is optional. pip install ferric does not install it and import ferric does not import it; import ferric.ase needs ASE (pip install "ferric[ase]" or pip install ase).

from ase.build import molecule
from ase.optimize import BFGS
from ferric.ase import FerricCalculator

atoms = molecule("H2O")
atoms.calc = FerricCalculator(method="rhf", basis="6-31g")
BFGS(atoms).run(fmax=0.01)
print(atoms.get_potential_energy())          # eV
print(atoms.calc.results["certificate"])     # ferric's validation certificate

Parameters

ParameterDefaultMeaning
method"hf"See the table below
basis"sto-3g"A bundled basis name or a ferric.BasisSet
functionalNoneXC functional, required by the Kohn-Sham methods
auxbasisNoneRI basis, required by rimp2 / oo-rimp2; for a periodic cell it is passed as auxbasis (with options={"jk": "rsgdf"})
charge, multiplicity0, 1Electron count and spin
kptsNonePeriodic only: None is the Gamma point, (n1, n2, n3) a k-point mesh
optionsNoneA dict passed unchanged to the ferric driver as keyword arguments (density_conv, solvent, point_charges, jk, omega, ...)

An unknown parameter raises CalculatorSetupError; driver keywords go in options, where the driver's own checks apply.

methodMolecule (atoms.pbc all False)3-D cell (atoms.pbc all True)
hfrun_rhf for a singlet, else run_uhfrun_rhf_* / run_uhf_*
rhf, uhf, rohfrun_rhf, run_uhf, run_rohfrun_<method>_gamma / _kpts
dftrun_dft for a singlet, run_uks for multiplicity > 1run_rks_* for a singlet, run_uks_* for multiplicity > 1
rksrun_dft (closed shell)run_rks_*
uks, roksrun_uks, run_roksrun_uks_*, run_roks_*
rimp2, oo-rimp2run_rimp2, run_oo_rimp2not available

A cell periodic in one or two directions raises CalculatorSetupError: ferric's periodic code is 3-D only.

Properties and units

implemented_properties are energy, free_energy (the same number), forces and stress. Units are ASE's: Angstrom, eV, eV/Angstrom and eV/Angstrom^3, converted from ferric's Hartree and Bohr with ase.units.Hartree and ase.units.Bohr. The stress is ferric's sigma = (1/V) dE/d(strain) (strain of the cell and the atoms), symmetrised and in ASE's Voigt order (xx, yy, zz, yz, xz, xy). Stress on a molecule raises PropertyNotImplementedError.

Forces and stress are the analytic derivatives of the reported energy (the with_gradient=True / with_stress=True paths of the drivers). Their refusals carry over: for example run_rhf refuses a gradient with symmetry=True, fock_hook, smearing_sigma or mom_after_iter, and run_rimp2 refuses it for an open shell, a local model or a fitted reference SCF. The docstrings in ferric.pyi list each driver's rules.

The molecular SCF and Kohn-Sham drivers run with ri_j_precision="f64" unless options sets it, so energies and forces come from the same surface. The f32 RI-J default of energy-only run_rhf / run_dft calls gives an energy surface that is jagged between nearby geometries.

calc.results["certificate"] holds the certificate of the run (result.certificate; see Certificates), and calc.ferric_result the ferric result object itself.

Caching

The ASE base class caches results: asking again for a property of unchanged atoms returns the stored value. Moving the atoms, or changing a parameter with calc.set(...), clears the results; calc.reset() clears them by hand. A property is computed only when asked for. get_forces() returns the energy as well, so an optimizer runs one SCF per geometry, but calling get_potential_energy() first and get_forces() second runs two.

Each geometry runs a fresh SCF from the default guess; no density is carried between steps.

Accuracy

The force on each atom equals ferric's analytic gradient times -Hartree/Bohr exactly, and matches a central finite difference of the calculator's own energy to the bar derived in crates/ferric-python/tests/test_ase_calculator.py; the periodic stress matches ASE's numerical stress in the same file. For finite-difference work tighten the SCF through options (density_conv=1e-9; scf_density_conv for the MP2 drivers): the analytic gradient assumes a stationary SCF, so its error follows the SCF's residual.

Molecular dynamics through ASE has not been validated: per-step SCF cost and energy drift over long trajectories were not measured. ferric's own drivers, run_aimd and the CLI's task = "md", warm-start each step's SCF, report the conserved quantity and attach a certificate; see Molecular dynamics.