Atoms
Atoms stores species, positions, cell, periodicity, per-atom arrays, constraints,
and the attached calculator. Positions use Å. Indices are zero-based and follow
the supplied atom order.
Atom order and molecular geometry
Section titled “Atom order and molecular geometry”from atomli.build import moleculefrom atomli.visualize import view
water = molecule("H2O")print(water.get_chemical_symbols()) # ['O', 'H', 'H'] for this builderv = view(water, tags="index")v.add_distance(0, 1)v.add_angle(1, 0, 2)Water atom indices bond distance and bond angle
The molecular formula does not determine the stored index order. For example,
an explicit Atoms("H2O", ...) constructor follows H,H,O, while this molecule
builder returns O,H,H. Inspect the symbols before assigning constraints or
orbital projections.
from atomli import Atoms
water = Atoms(symbols=["O", "H", "H"], positions=[ [0, 0, 0], [0.96, 0, 0], [-0.24, 0.93, 0],])positions = water.get_positions()positions[1, 0] += 0.05water.set_positions(positions)set_positions applies attached constraints. Use the normal setter during a
constrained workflow; bypass constraint application only for an intentional
change of reference geometry.
Periodic cells
Section titled “Periodic cells”from atomli.build import bulk
silicon = bulk("Si", "diamond", a=5.43)print(silicon.get_cell())print(silicon.get_pbc())Two atom primitive silicon cell
The diamond primitive cell contains two atoms and nonorthogonal cell vectors.
A conventional cubic diamond cell contains eight. pbc accepts a Boolean or
three-axis mask; calculator support for partial periodicity is method-specific.
Per-atom data
Section titled “Per-atom data”water.set_tags([1, 2, 2])water.set_initial_charges([0.0, 0.0, 0.0])water.set_initial_magnetic_moments([0.0, 0.0, 0.0])water.set_masses([15.999, 2.014, 2.014])Tags classify sites; they do not change the electronic Hamiltonian. Masses affect nuclear dynamics and mass-weighted vibrations. Charge and spin inputs must match the intended electronic state. Preserve these arrays and their atom order in saved structures.
Calculations and copies
Section titled “Calculations and copies”from atomli.calculators import QC
water.calc = QC(xc="PBE", basis="def2-svp", device="cpu", scf={"energy_tolerance": 1e-8})energy = water.get_potential_energy() # eVforces = water.get_forces() # eV/Åsnapshot = water.copy()Changes to geometry, composition, charge, or spin invalidate electronic results. A copied structure is useful for trajectory storage; assign the intended calculator before requesting fresh properties. ASE Python calculators can be assigned directly and are adapted internally.