Quickstart Tutorial#

Learn the basics of airsspy by performing a simple random structure search.

Prerequisites#

  • airsspy installed (Installation Guide)

  • AIRSS buildcell executable in PATH

  • Basic familiarity with Python and ASE

Complete Example Code#

Here’s the full working example:

from airsspy import SeedAtoms
from ase.calculators.lj import LennardJones
from ase.optimize import BFGS
from ase.constraints import UnitCellFilter

# Create seed
seed = SeedAtoms('Al', cell=[2, 2, 2], pbc=True)
seed.gentags.minsep = 1.5
seed[0].num = 8

# Set up calculator
calc = LennardJones()

# Run search (using 5 for faster execution, typically use 20+)
results = []
for i in range(5):
    atoms = seed.build_random_atoms()
    if atoms is None:
        continue
    atoms.set_calculator(calc)
    opt = BFGS(UnitCellFilter(atoms), logfile=None)
    opt.run(fmax=0.05)
    results.append(atoms)

# Find best
energies = [atoms.get_potential_energy() for atoms in results]
best_idx = energies.index(min(energies))
print(f"Found {len(results)} structures")
print(f"Best energy: {energies[best_idx]:.4f} eV")

Understanding buildcell Behavior#

When you call build_random_atoms():

  1. Cell volume: The initial cell volume (8 ų) is multiplied by the number of atoms per formula unit

  2. Volume variation: buildcell randomly varies the volume (typically by ±50%)

  3. Random positions: Atoms are placed randomly, respecting minsep constraints

  4. Random cell shape: The cell shape is randomized (within constraints)

  5. Symmetry: Random symmetry operations may be applied (controlled by symmops)

Common Parameters#

Here are some commonly used seed generation tags:

seed.gentags.minsep = 2.0        # Minimum separation (Å)
seed.gentags.varvol = 20         # Volume variation (%)
seed.gentags.symmops = (2, 4)    # Number of symmetry operations
seed.gentags.compact = True      # Apply Niggli reduction
seed.gentags.nform = 1           # Number of formula units

Next Steps#

Now that you understand the basics, explore:

Troubleshooting#

buildcell not found#

If you get an error about buildcell:

  • Verify AIRSS is installed: which buildcell

  • Check PATH includes AIRSS bin directory

  • See Installation Guide

build_random_atoms() returns None#

This happens when buildcell times out or fails:

  • Increase the timeout: seed.build_random_atoms(timeout=30)

  • Check your minsep constraints aren’t too tight

  • Verify your seed file is valid

Structures too similar#

If all structures converge to the same result:

  • Increase volume variation: seed.gentags.varvol = 50

  • Generate more structures

  • Try different starting cell sizes

  • Add symmetry operations: seed.gentags.symmops = (1, 4)