Skip to content

Building structures

The atomli.build module follows ASE’s structure-building vocabulary. Names, default cells, and geometries match ase.build, so a script keeps its atom count and its energy when the import changes.

from atomli.build import molecule
water = molecule("H2O")
benzene = molecule("C6H6")
ethanol = molecule("CH3CH2OH")

Geometries come from the G2/97 set, the same data ASE ships, so molecule("H2O") is the same structure in both packages. Every G2 name works, along with ASE’s extras (Be2, C7NH5, BDA, biphenyl, C60) and a few plain-English aliases such as water, ethanol, and benzene. Call molecule_names() for the full list; an unknown name raises with that list in the message.

vacuum= centers the molecule in a padded cell, as in ASE:

water = molecule("H2O", vacuum=5.0)
from atomli.build import bulk
silicon = bulk("Si", "diamond", a=5.43) # 2 atoms, primitive
copper = bulk("Cu", "fcc", a=3.6) # 1 atom, primitive
copper_cubic = bulk("Cu", "fcc", a=3.6, cubic=True) # 4 atoms

bulk returns the primitive cell by default, exactly as ASE does. Pass cubic=True for the conventional cubic cell or orthorhombic=True for the orthorhombic one. A prototype that has no such cell (a cubic hcp, for instance) raises rather than quietly returning a different shape.

Prototypes: sc, fcc, bcc, hcp, diamond, rocksalt, zincblende, cesiumchloride, fluorite, wurtzite, plus rutile and perovskite, which ASE does not carry. hcp and wurtzite take covera= or c=, and wurtzite takes u=. With no crystalstructure and no a, the element’s reference phase and lattice constant are used, again matching ASE.

The structures ASE builds from a basis or from extra lattice constants (tetragonal, bct, rhombohedral, orthorhombic, mcl) raise NotImplementedError.

from atomli.build import add_adsorbate, fcc111, molecule
slab = fcc111("Pt", size=(2, 2, 3), vacuum=8.0)
co = molecule("CO")
add_adsorbate(slab, co, height=1.8, position="ontop")

Inspect the resulting cell, periodicity, composition, and minimum image distances before starting a calculation.