Skip to content

Analytical electronic API

Atomli exposes native electronic calculations through public Python imports. Forces, stress, Hessians, and response properties use analytical derivatives where supported by the selected calculator.

Scf.energy_tolerance and Scf.level_shift, their dict equivalents, and echoed calculator parameters use eV. Named electronic/nuclear energy components are None when the backend does not provide that decomposition.

from atomli import Atoms
from atomli.calculators import QC
from atomli.vibrations import Vibrations
atoms = Atoms("H2", positions=[[0, 0, 0], [0, 0, 0.74]])
calc = QC(xc="PBE", basis="def2-svp", device="cpu")
atoms.calc = calc
energy = calc.kernel(atoms) # eV
forces = calc.get_forces() # eV/angstrom
hessian = calc.get_hessian() # eV/angstrom**2
product = calc.get_hessian_vector([[0, 0, 1], [0, 0, -1]])
dipole = calc.get_dipole_moment() # electron*angstrom
capabilities = calc.get_capabilities() # no SCF or displacement work

The standalone HF calculator remains available for method comparisons. Its method="auto" selects RHF for singlets and UHF otherwise. Explicit uhf permits unrestricted singlets. RHF and UHF provide analytical forces and Hessians. ROHF provides energy and electronic analysis; its analytical nuclear derivatives are not exposed. Standalone HF currently supports molecular CPU calculations. Unsupported device and boundary-condition requests raise.

kernel() also provides an energy entry point on QC and CCSD. QC retains its existing supported dm0= seed control. HF and CCSD do not accept dm0=.

from atomli.calculators.qc import MolecularBasis, available_basis_sets
basis = MolecularBasis(atoms, basis="def2-svp")
overlap = basis.get_overlap() # dimensionless (ao, ao)
hcore = basis.get_hcore() # eV (ao, ao)
eri = basis.intor("int2e") # eV (ao, ao, ao, ao)
dm = calc.make_rdm1()[0, 0].real
j, k = basis.get_jk(dm) # positive J and K, eV
core_plus_coulomb = hcore + j # XC operator is separate in KS DFT
mo_eri = basis.ao2mo(calc.mo_coeff[0, 0].real)
ao = basis.eval_ao([[0.1, 0.2, 0.3]], deriv=2)
catalog = available_basis_sets()

MolecularBasis owns an immutable geometry and Gaussian basis. Construct a new object after changing geometry. No SCF is required. Available one-electron integrals are int1e_ovlp, int1e_kin, int1e_nuc, int1e_hcore, and ECPscalar. Energy-valued integrals use eV. int1e_nuc excludes the scalar ECP; get_hcore() includes it.

AO values use angstrom**(-3/2). Each spatial derivative adds one inverse angstrom. deriv=0 returns (point, ao). deriv=1/2 returns (component, point, ao) in value,x,y,z,xx,xy,xz,yy,yz,zz order, truncated to the requested derivative order. These are analytical derivatives.

get_jk() accepts a finite real symmetric (ao, ao) density without an implicit spin factor. An auxiliary basis selects the native density-fitted J/K construction. Full int2e and ao2mo require an exact basis without auxiliary_basis; fitted tensors are not silently substituted. Complex inputs, unavailable integrals, periodic systems, and GTH basis operators raise explicit errors in this initial operator interface.

mo_coeff, mo_energy, and mo_occ expose copied retained state. Coefficient axes are (spin, kpoint, ao, band); orbital energy and occupation axes are (spin, kpoint, band). Orbital energies use eV. make_rdm1() preserves (spin, kpoint, ao, ao) and get_overlap() preserves (kpoint, ao, ao). Restricted densities are spin summed. Molecular CC requests retain the correlated analysis density, including the native Lambda solve.

from atomli.calculators import CCSD
from atomli.build import molecule
atoms = molecule("H2O")
cc = CCSD(basis="cc-pvdz", frozen=1, device="cpu")
energy = cc.kernel(atoms)
forces = cc.get_forces()
density = cc.make_rdm1()
dipole = cc.get_dipole_moment()

frozen accepts a core-orbital count, a list of zero-based MO indices, or separate alpha/beta index lists. This selection is currently molecular-only. Molecular CC gradients are analytical. CC Hessians and periodic CC derivatives are unavailable through this interface.

from atomli.calculators import XTB
calc = XTB(method="gfn2", solvent="water", solvation="alpb", device="cpu",
scf={"electronic_temperature_kelvin": 300,
"mixer_damping": 0.3, "initial_guess": "eeq"})

The solvent catalog contains water, methanol, and ethanol. GFN2 supports alpb, gbsa, cpcm, and the corresponding *_cds models. A dict may instead specify solvation={"model": ..., "solvent": ...}. Unsupported method/solvent combinations raise.

SCF controls also accept temperature_schedule_kelvin as a strictly decreasing list, plus the existing energy_threshold_ev, density_threshold, and max_iterations. Initial guesses are zero, sad, eeq, and ceh.

XTB.get_excitations(atoms, nstates=10) exposes the native molecular sTDA eigenproblem. Returned state energies use eV, transition dipoles use electron*angstrom, and unavailable strengths/dipoles remain None. Dominant orbital transitions retain native occupied/virtual indices and spin labels. get_atomic_polarizabilities() exposes D4-reference model values in angstrom³. These are atomic model parameters, not a molecular finite-field response tensor.

Vibrations(..., method="analytical") and method="auto" both require an analytical Hessian. An atom subset selects the corresponding block of the full analytical Hessian. Neither spelling enables a numerical fallback.

Phonons(...).run() constructs image-resolved force constants using periodic DFPT or an analytical supercell Hessian, according to calculator support. Converge the geometry, basis, electronic k mesh, force-constant range, and reciprocal-space sampling. Saved constants can be analyzed with Phonons.from_force_constants().

get_capabilities(atoms) reports the derivatives and responses supported by the selected calculator configuration.