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.
Quick usage
Section titled “Quick usage”from atomli.build import moleculefrom atomli.calculators.xtb import XTB
atoms = molecule("H2O")atoms.calc = XTB(method="gxtb", device="gpu")energy = atoms.get_potential_energy() # eVforces = 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·ÅMethod matrix (g-xTB vs GFN2-xTB)
Section titled “Method matrix (g-xTB vs GFN2-xTB)”| Property | g-xTB (method="gxtb") | GFN2-xTB (method="gfn2") |
|---|---|---|
| Devices | CPU, GPU (root_protection=True uses CPU) | CPU only (explicit GPU raises) |
| Default device behavior | Selects available hardware GPU for closed-shell non-protected molecules/cells | Always defaults to "cpu" |
| Periodicity | Molecular (0D) and 3D Gamma bulk supercells (gamma_exchange_radii=(Rd, Rc) required) | 0D, 1D, 2D, and 3D leading-axis PBC |
| Implicit solvation | Not supported (raises on solvation args) | alpb, gbsa, cpcm, and *_cds (water, methanol, ethanol) |
| Analytical derivatives | energy, forces, stress (3D), molecular hessian (CPU) | energy, forces, stress (periodic), molecular hessian |
| Response & spectroscopy | get_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.
Constructor parameters
Section titled “Constructor parameters”| Parameter | Type | Default | Unit | Description |
|---|---|---|---|---|
method | str | "gfn2" | — | "gfn2", "GFN2-xTB", "gxtb", or "g-xtb" |
charge | float | None | None | Total charge override | |
unpaired | int | None | None | — | Unpaired electron count () |
device | str | Adapter | None | Auto per method | — | "cpu", "gpu" ("wgpu" alias), "gpu:<selector>", or Adapter |
adapter | Adapter | int | str | None | None | — | Physical GPU selector |
gamma_exchange_radii | (float, float) | None | None | Å | Required (Rd, Rc) pair for periodic g-xTB; shortest lattice vector must exceed |
scf | dict | None | None | Mixed (see below) | Tight-binding SCF convergence and mixing controls |
solvent | str | None | None | — | Solvent name ("water", "methanol", "ethanol") for GFN2-xTB |
solvation | str | dict | None | None | — | Model name ("alpb", "gbsa", "cpcm", "*_cds") or {"model": ..., "solvent": ...} |
require_convergence | bool | True | — | Raise on unconverged SCF |
root_protection | bool | False | — | Pin fixed-geometry CPU, K protected root recovery for g-xTB |
root_recovery_cycles | int | 250 | — | Maximum completion/restart cycles when root_protection=True |
root_energy_threshold | float | 1e-11 | Ha | Protected-root SCF energy threshold |
root_fock_threshold | float | 1e-12 | Ha | Protected-root Fock residual threshold |
root_max_iterations | int | 250 | — | Protected-root primary SCF cycle limit |
Periodic g-xTB rules
Section titled “Periodic g-xTB rules”- Passing a periodic cell to
XTB(method="gxtb")requiresgamma_exchange_radii=(Rd, Rc)in angstrom. - Every lattice translation vector magnitude must hold at every evaluated geometry, including during cell relaxation.
SCF controls (scf=)
Section titled “SCF controls (scf=)”| Key | Type | Unit | Description |
|---|---|---|---|
electronic_temperature_kelvin | float | K | Fermi electronic smearing temperature |
temperature_schedule_kelvin | list[float] | K | Strictly decreasing electronic temperature annealing schedule |
mixer_damping | float | — | Broyden/linear SCF density damping factor |
initial_guess | str | — | Initial charge/Hamiltonian guess: "zero", "sad", "eeq", or "ceh" |
energy_threshold_ev | float | eV | SCF total-energy convergence threshold |
density_threshold | float | — | SCF density/charge convergence threshold |
max_iterations | int | — | 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()(),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 , andget_polarizability()returns the static(3, 3)dipole polarizability tensor in via Z-vector orbital response (3 linear solves, no finite fields).get_atomic_polarizabilities()returns D4-reference atomic parameters in . - Excited states (
GFN2-xTB):calc.get_excitations(atoms, nstates=10, include_transition_vectors=True)solves molecular algebraicsTDAexcitations (energies in eV, transition dipoles in ). - Diagnostics:
calc.get_gxtb_scf_diagnostics()reportsg-xTBGPU stopping norms (Noneif no matching GPU calculation exists);calc.get_gxtb_root_diagnostics()reportsroot_protection=Truecertificate work across independent restores.