Necklace Enum lists the symmetrically distinct derivative superstructures of a parent lattice — the ways of decorating it with several kinds of atom — by generating each one directly instead of filtering out duplicates. The quotient group of a superlattice is a discrete torus. Reading its sites column by column along the largest cyclic factor turns every decoration into a word on which translations act as rotations combined with one permutation applied to every letter, so the distinct structures are Lyndon words and can be produced with a necklace algorithm. Nothing about earlier structures is stored, so memory does not grow with the number of structures: counting 9.2 billion structures stays within 10 MB of the interpreter's baseline, and listing stays below 0.22 GB on problems where enumlib needs gigabytes or runs out of memory. The package reproduces all published counts and lists structures ~2–90× faster than the fastest of enumlib, Enumlib.jl and dsenum on each benchmark problem, for cells larger than 14 sites. Each structure comes with its degeneracy, its weight in a partition function, at fixed composition as well, taken from the generator's own symmetry comparisons.
Install with pip install necklace-enum (Python 3.10 or later; NumPy and Numba are installed
automatically). The tests, the checks against the published counts and an independent brute-force code, and the
benchmark scripts with their raw logs are in the repository. In Python:
import necklace_enum as te
P = te.fcc(["Cu", "Au"])
# number of structures for each cell size
te.count_structures(P, range(1, 13))
# every Cu6Au2 structure with 8 atoms per cell, as ASE Atoms, with its weight g
for s in te.enumerate_structures(P, 8, composition={"Cu": 6, "Au": 2}):
atoms = s.to_ase()
g = s.total_degeneracy
Other parents are te.bcc, te.sc and te.hcp, or te.Parent
for any lattice and basis, with optional site restrictions. Exporting to ASE needs pip install ase.
The README describes all options and the necklace-enum command-line tool.