Structure optimization
Atomli optimizers update an Atoms structure using the attached calculator’s
analytical forces. run(fmax=..., steps=...) returns a convergence flag.
fmax is the maximum force-vector norm over the active coordinates, in eV/Å.
Benzene relaxation with g-xTB
Section titled “Benzene relaxation with g-xTB”The benzene input displaces every Cartesian coordinate with a seeded random
vector of standard deviation 0.18 Å. The calculation uses
CPU g-xTB and BFGS at fmax=0.02 eV/Å.
import numpy as npfrom atomli.build import moleculefrom atomli.calculators import XTBfrom atomli.optimize import BFGS
atoms = molecule("C6H6")rng = np.random.default_rng(20260807)atoms.set_positions(atoms.get_positions() + rng.normal(0, .18, (len(atoms), 3)))atoms.calc = XTB(method="gxtb", device="cpu")opt = BFGS(atoms, trajectory="benzene.traj", logfile="benzene.log")if not opt.run(fmax=.02, steps=200): raise RuntimeError("Benzene relaxation did not converge")The saved run takes 25 steps, lowers the electronic energy by 16.00 eV, and ends at a maximum force of 0.0185 eV/Å. Its mean C–C distance is 1.3853 Å; the spread among the six C–C distances is 0.23 mÅ. These values describe this method and stopping criterion.
Force tolerance and remaining geometric error
Section titled “Force tolerance and remaining geometric error”The same displaced input was independently relaxed to several force thresholds. The energy difference is measured against the tightest run in the saved study.
| Requested fmax (eV/Å) | Steps | Achieved fmax | Energy above tightest (meV) |
|---|---|---|---|
| 0.5 | 9 | 0.4511 | 45.507 |
| 0.2 | 14 | 0.1007 | 6.276 |
| 0.1 | 15 | 0.0838 | 5.125 |
| 0.05 | 21 | 0.0482 | 1.095 |
| 0.02 | 25 | 0.0185 | 0.218 |
| 0.01 | 30 | 0.0093 | 0.000 |
Choose the stopping criterion for the intended observable. A tolerance adequate for an initial conformer screen can leave unacceptable low-frequency Hessian errors. Preserve the achieved residual with an energy, bond length, or frequency. Electronic convergence must be tighter than the changes used by the optimizer.
Energy and maximum force need not decrease together. The g-xTB benzene energy falls monotonically in this saved run, while the maximum force increases on 5 steps. Reassess persistent oscillation or stagnation using the complete trajectory and electronic convergence records.
Native optimizer selection
Section titled “Native optimizer selection”All seven optimizers below use the same input, calculator, and 0.02 eV/Å threshold. The table records measured behavior for this molecule.
| Optimizer | Steps | Converged | Final fmax (eV/Å) |
|---|---|---|---|
| BFGS | 25 | true | 0.0185 |
| LBFGS | 25 | true | 0.0185 |
| LBFGSLineSearch | 26 | true | 0.0114 |
| FIRE | 99 | true | 0.0175 |
| FIRE2 | 90 | true | 0.0187 |
| ABCFIRE | 84 | true | 0.0199 |
| MDMin | 101 | true | 0.0197 |
from atomli.optimize import BFGS, LBFGS, LBFGSLineSearch, FIRE, FIRE2, ABCFIRE, MDMin
optimizer = LBFGS(atoms, maxstep=.12)converged = optimizer.run(fmax=.02, steps=200)BFGS stores a dense curvature approximation; LBFGS uses a limited history. Line-search variants spend additional evaluations choosing a step. FIRE-family and MDMin optimizers use damped dynamical updates. Step counts alone do not measure total calculator cost or predict another system’s behavior.
Constrained adsorption and force residuals
Section titled “Constrained adsorption and force residuals”The PBE/def2-SVP adsorption study relaxes water at an exposed Li site of a frozen
(LiF)₂ cluster. The four host atoms remain fixed while all nine adsorbate
coordinates relax to fmax=0.003 eV/Å.
PBE constrained water adsorption and force convergence history
get_forces() applies constraints. Retain the raw electronic forces when
examining the host reaction forces:
raw = ads.get_forces(apply_constraint=False)projected = ads.get_forces()active_fmax = np.linalg.norm(projected, axis=1).max()Check the fixed coordinates directly against their initial values. Convergence of the active subspace does not imply a minimum of the unconstrained system. The constraint guide compares fixed coordinates, line/plane directions, bond lengths, collective coordinates, and a soft restraint using the same adsorption model.
Minima and saddle points
Section titled “Minima and saddle points”A small gradient establishes stationarity in the selected subspace. Determine local stability with an appropriate analytical Hessian. For an isolated molecule, separate rigid translation/rotation from internal modes. For a fixed-host adsorbate, retain its frustrated translations and rotations as physical active-subspace modes.
from atomli.vibrations import Vibrations
# ads is the converged PBE complex, with host indices 0–3 fixed.vib = Vibrations(ads, indices=[4, 5, 6], method="analytical").run()frequencies = vib.get_frequencies()The adsorbate Hessian has nine positive eigenvalues. Bond, line, and plane constraints require their independent-coordinate Hessian and curvature treatment; selecting atom indices alone does not construct it. g-xTB supplies analytical forces for relaxation but currently lacks a public analytical Hessian. Refine candidates with a supported PBE configuration before requesting Hessian-based classification or thermochemistry.
A transition-state search has a different target. The ammonia climbing-image NEB locates the inversion saddle and verifies its single substantial imaginary umbrella mode. The conformer search checks refined ethanol candidates with analytical Hessians before calling them minima.
Convergence troubleshooting
Section titled “Convergence troubleshooting”Inspect failed SCF cycles before changing an optimizer. A force threshold below
the electronic noise floor cannot converge reliably. For large structural steps,
reduce maxstep; for flat directions, inspect the full residual history and
consider a different optimizer or physically motivated constraints.
A step budget is a limit rather than a convergence criterion. Restart from the last accepted geometry, preserve constraints and calculator settings, and verify the returned flag and final forces before analysis. The saved benzene five-step budget ends at 1.85 eV/Å and is correctly recorded as unconverged.