Constraints in adsorption calculations
The examples use H₂O coordinated to an exposed Li site of a finite (LiF)₂
cluster. The four host atoms start in a 1.7 Å square; water starts above one Li
site. Calculations use molecular PBE/def2-SVP, analytical forces, and BFGS with
fmax=0.003 eV/Å.
This finite cluster isolates the constraint choices. A quantitative surface study requires a larger or periodic substrate, basis convergence, and appropriate correlation and electrostatics. These calculations do not define a surface coverage or adsorption free energy.
Each figure contains an optimization trajectory and a Geometry and force history panel with Li–O/O–H distances and raw/projected force residuals.
Runnable Python · Calculation records
Frozen substrate, relaxed adsorbate
Section titled “Frozen substrate, relaxed adsorbate”Host indices are 0–3; water is 4–6, with O at index 4.
from atomli import Atomsfrom atomli.calculators import QCfrom atomli.constraints import FixAtomsfrom atomli.optimize import BFGS
atoms = Atoms("LiFLiFOH2", positions=[ [0, 0, 0], [1.7, 0, 0], [1.7, 1.7, 0], [0, 1.7, 0], [-0.3, -0.25, 2.15], [-0.3, 0.513, 2.746], [-0.3, -1.013, 2.746],])atoms.set_constraint(FixAtoms(indices=[0, 1, 2, 3]))atoms.calc = QC(xc="PBE", basis="def2-svp", device="cpu", scf={"energy_tolerance": 1e-8})if not BFGS(atoms, maxstep=0.12).run(fmax=0.003, steps=160): raise RuntimeError("Adsorbate relaxation did not converge")Water adsorption at a frozen LiF cluster: optimization and force residuals
All nine adsorbate coordinates relax. The optimized water approaches the exposed Li site near the cluster edge. Gray host atoms retain their initial positions. The fixed host remains part of the electronic calculation.
Fixed lateral coordinates or a specified approach axis
Section titled “Fixed lateral coordinates or a specified approach axis”from atomli.constraints import FixCartesian
atoms.set_constraint([ FixAtoms(indices=[0, 1, 2, 3]), FixCartesian(4, mask=[True, True, False]),])True fixes the corresponding component. The O atom retains x and y while its
height and the hydrogen coordinates relax.
Water adsorption with lateral oxygen coordinates held fixed
For an oblique approach coordinate, use an allowed direction:
from atomli.constraints import FixedLine
atoms.set_constraint([ FixAtoms(indices=[0, 1, 2, 3]), FixedLine(4, direction=[0.25, 0.25, 1]),])Constrained oblique approach of water to the Li coordination site
These are restricted minima. Their transverse raw forces can remain nonzero. They are suitable starting points for a constrained adsorption-coordinate study; release the approach constraint before claiming a fully relaxed adsorption geometry.
Lateral relaxation at fixed height
Section titled “Lateral relaxation at fixed height”from atomli.constraints import FixedPlane
atoms.set_constraint([ FixAtoms(indices=[0, 1, 2, 3]), FixedPlane(4, direction=[0, 0, 1]),])The vector is the plane normal. O retains its initial height while lateral coordinates and both hydrogens relax.
Lateral adsorbate relaxation at a fixed oxygen height
For periodic slabs, FixScaled can constrain components relative to the cell:
from atomli.constraints import FixScaled
# On the intended periodic slab, allow motion along its third cell vector.atoms.set_constraint([ FixAtoms(indices=bottom_layer_indices), FixScaled(adsorbate_index, mask=[True, True, False]),])In a skew cell, cell-vector and Cartesian constraints define different subspaces. Use the actual surface normal when the third cell vector is oblique to it.
Constrained intramolecular distances
Section titled “Constrained intramolecular distances”A single O–H distance can be retained during adsorption:
from atomli.constraints import FixBondLength
atoms.set_constraint([ FixAtoms(indices=[0, 1, 2, 3]), FixBondLength(4, 5),])Adsorption relaxation with one O H distance constrained
For both O–H distances:
from atomli.constraints import FixBondLengths
atoms.set_constraint([ FixAtoms(indices=[0, 1, 2, 3]), FixBondLengths([(4, 5), (4, 6)]),])Adsorption relaxation with both O H distances constrained
The distances remain fixed; the H–O–H angle and adsorption geometry remain active. This is not a rigid-water model. Verify the retained distances in the saved trajectory and in the distance records.
Local host relaxation without host translation
Section titled “Local host relaxation without host translation”from atomli.constraints import FixSubsetCom
atoms.set_constraint(FixSubsetCom([0, 1, 2, 3]))Local LiF host relaxation with its center of mass fixed
The host deforms while its mass-weighted center remains fixed. Water is free.
FixCom() instead constrains the center of mass of the complete system.
Neither constraint makes the selected fragment rigid.
Remove one collective adsorbate displacement
Section titled “Remove one collective adsorbate displacement”import numpy as npfrom atomli.constraints import FixedMode
mode = np.zeros((len(atoms), 3))mode[[4, 5, 6], 0] = 1 # collective water translation along xatoms.set_constraint([ FixAtoms(indices=[0, 1, 2, 3]), FixedMode(mode),])Adsorbate optimization with one lateral collective direction projected out
FixedMode removes the supplied Cartesian direction; it does not calculate a
vibrational eigenvector. The mode array must follow the full atom ordering.
Soft restraint on the adsorption distance
Section titled “Soft restraint on the adsorption distance”from atomli.constraints import Hookean
atoms.set_constraint([ Hookean(0, 4, k=0.8, rt=1.8), # Li–O; eV/Ų, Å FixAtoms(indices=[0, 1, 2, 3]),])Water adsorption with a soft Hookean Li O restraint
The spring contributes above 1.8 Å. It does not enforce a hard upper bound, and its energy belongs to the restrained model. Do not mix restrained and unrestrained energies in an adsorption-energy difference.
Raw and projected convergence
Section titled “Raw and projected convergence”raw = atoms.get_forces(apply_constraint=False)projected = atoms.get_forces()raw_fmax = np.linalg.norm(raw, axis=1).max()projected_fmax = np.linalg.norm(projected, axis=1).max()The optimizer tests projected forces. A small projected residual establishes stationarity in the allowed subspace; raw forces quantify forces supported by the constraints. The figures retain both residuals.
set_constraint(...) replaces the constraint list. Pass one list to combine
constraints; set_constraint() clears it. Set constraints before constructing
the driver, and verify indices after slicing, replication, or an I/O round trip.
Adsorbate vibrations on the fixed host
Section titled “Adsorbate vibrations on the fixed host”For the fixed-host minimum, calculate the analytical Hessian block over the nine water coordinates:
from atomli.vibrations import Vibrations
vib = Vibrations(atoms, indices=[4, 5, 6], method="analytical").run()frequencies = vib.get_frequencies()hessian = vib.get_hessian_2d() # 9 × 9, eV/ŲAnalytical low frequency adsorbate mode on the fixed LiF cluster
The host displacement is zero. This partial Hessian excludes substrate response and host–adsorbate vibrational coupling. The nine adsorbate coordinates include frustrated translations and rotations; they are not six removable rigid-body modes of the isolated water molecule.
| Mode | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
|---|---|---|---|---|---|---|---|---|---|
| Frequency (cm⁻¹) | 33.8 | 129.9 | 262.5 | 356.5 | 459.9 | 896.4 | 1596.5 | 3245.1 | 3763.1 |
Use the fully relaxed adsorbate under FixAtoms for this Cartesian partial-Hessian
analysis. Additional bond, line, or plane constraints require treatment of their
independent coordinate subspace.
Analytical Hessian and eigenvectors · Vibration and mode analysis · Adsorption density