Skip to content

XTB

XTB runs semi-empirical extended tight-binding calculations with g-xTB (method="gxtb") and GFN2-xTB (method="gfn2"). Accepted method aliases are "gxtb" / "g-xtb" and "gfn2" / "GFN2-xTB"; GFN1-xTB and IPEA1 are not substituted.

from atomli.build import molecule
from atomli.calculators.xtb import XTB
atoms = molecule("H2O")
atoms.calc = XTB(method="gxtb", device="gpu")
energy = atoms.get_potential_energy() # eV
forces = atoms.get_forces() # eV/Å

GFN2-xTB with implicit ALPB solvation:

atoms.calc = XTB(
method="gfn2",
solvent="water",
solvation="alpb",
scf={"electronic_temperature_kelvin": 300.0, "mixer_damping": 0.3},
)
dipole = atoms.get_dipole_moment() # e·Å
Propertyg-xTB (method="gxtb")GFN2-xTB (method="gfn2")
DevicesCPU, GPU (root_protection=True uses CPU)CPU only (explicit GPU raises)
Default device behaviorSelects available hardware GPU for closed-shell non-protected molecules/cellsAlways defaults to "cpu"
PeriodicityMolecular (0D) and 3D Gamma bulk supercells (gamma_exchange_radii=(Rd, Rc) required)0D, 1D, 2D, and 3D leading-axis PBC
Implicit solvationNot supported (raises on solvation args)alpb, gbsa, cpcm, and *_cds (water, methanol, ethanol)
Analytical derivativesenergy, forces, stress (3D), molecular hessian (CPU)energy, forces, stress (periodic), molecular hessian
Response & spectroscopyget_dipole_moment(), get_dipole_derivatives(), get_polarizability(), get_atomic_polarizabilities()All responses + get_excitations() (molecular sTDA), get_dos(), get_pdos()

gxtb and gfn2 use distinct atomic reference energies.

ParameterTypeDefaultUnitDescription
methodstr"gfn2"—"gfn2", "GFN2-xTB", "gxtb", or "g-xtb"
chargefloat | NoneNoneeeTotal charge override
unpairedint | NoneNone—Unpaired electron count (Nα−NβN_\alpha - N_\beta)
devicestr | Adapter | NoneAuto per method—"cpu", "gpu" ("wgpu" alias), "gpu:<selector>", or Adapter
adapterAdapter | int | str | NoneNone—Physical GPU selector
gamma_exchange_radii(float, float) | NoneNoneÅRequired (Rd, Rc) pair for periodic g-xTB; shortest lattice vector must exceed 2Rc2 R_c
scfdict | NoneNoneMixed (see below)Tight-binding SCF convergence and mixing controls
solventstr | NoneNone—Solvent name ("water", "methanol", "ethanol") for GFN2-xTB
solvationstr | dict | NoneNone—Model name ("alpb", "gbsa", "cpcm", "*_cds") or {"model": ..., "solvent": ...}
require_convergenceboolTrue—Raise on unconverged SCF
root_protectionboolFalse—Pin fixed-geometry CPU, Te=0T_e = 0 K protected root recovery for g-xTB
root_recovery_cyclesint250—Maximum completion/restart cycles when root_protection=True
root_energy_thresholdfloat1e-11HaProtected-root SCF energy threshold
root_fock_thresholdfloat1e-12HaProtected-root Fock residual threshold
root_max_iterationsint250—Protected-root primary SCF cycle limit
  • Passing a periodic cell to XTB(method="gxtb") requires gamma_exchange_radii=(Rd, Rc) in angstrom.
  • Every lattice translation vector magnitude ∣T∣>2Rc|T| > 2 R_c must hold at every evaluated geometry, including during cell relaxation.
KeyTypeUnitDescription
electronic_temperature_kelvinfloatKFermi electronic smearing temperature
temperature_schedule_kelvinlist[float]KStrictly decreasing electronic temperature annealing schedule
mixer_dampingfloat—Broyden/linear SCF density damping factor
initial_guessstr—Initial charge/Hamiltonian guess: "zero", "sad", "eeq", or "ceh"
energy_threshold_evfloateVSCF total-energy convergence threshold
density_thresholdfloat—SCF density/charge convergence threshold
max_iterationsint—Maximum SCF iterations per evaluation

Retained state, responses, and diagnostics

Section titled “Retained state, responses, and diagnostics”
  • Electronic observables: get_atomic_charges(), get_dipole_moment() (e⋅A˚e\cdot\text{Å}), get_dos(), get_pdos(), get_eigenvalues(), make_rdm1(), and real-space fields (write_cube(), analyze_fields()).
  • Molecular linear response (g-xTB & GFN2-xTB): get_dipole_derivatives() returns (natoms, 3, 3) in ee, and get_polarizability() returns the static (3, 3) dipole polarizability tensor in A˚3\text{Å}^3 via Z-vector orbital response (3 linear solves, no finite fields). get_atomic_polarizabilities() returns D4-reference atomic parameters in A˚3\text{Å}^3.
  • Excited states (GFN2-xTB): calc.get_excitations(atoms, nstates=10, include_transition_vectors=True) solves molecular algebraic sTDA excitations (energies in eV, transition dipoles in e⋅A˚e\cdot\text{Å}).
  • Diagnostics: calc.get_gxtb_scf_diagnostics() reports g-xTB GPU stopping norms (None if no matching GPU calculation exists); calc.get_gxtb_root_diagnostics() reports root_protection=True certificate work across independent restores.