[ANN] Enumlib.jl: a package for derivative structure enumeration

Most users of my original enumlib will go on calling it (this new code) from inside Python, obliviously—so this probably appeals only to a handful of computational materials scientists here. But it is the culmination of a couple of years of careful work, and I would rather it be findable than not.

Enumlib.jl generates the symmetry-distinct supercells and atomic decorations of a parent lattice—the building blocks for cluster-expansion fits and configuration sampling in alloy theory. It is a from-scratch Julia reimplementation of the Fortran enumlib (which I also wrote, years ago), and it is now registered: Pkg.add("Enumlib").

The public API is a few composable functions rather than a file-driven program:

using Enumlib
parent = ParentLattice([0.5 0.5 0.0; 0.5 0.0 0.5; 0.0 0.5 0.5])
sites  = Sites([Site([0.0, 0.0, 0.0], [0, 1])])

count_inequivalent(parent, sites; supercells = VolumeRange(1:6))   # how many, without enumerating
e = enumerate_structures(parent, sites; supercells = VolumeRange(1:4))

count_inequivalent is the part I would point a Julia audience at: it answers “how big is this going to be” by Pólya/Burnside counting, without generating anything. estimate_cost turns that into a memory prediction and refuses an enumeration that could never finish—a gotcha the original code had no defence against, and one I have walked into myself.

Algorithms: HNF/SNF enumeration and Pólya counting (Hart & Forcade 2008), multilattices (2009), fixed concentration via multinomial hashing (2012), and the recursive-stabilizer tree (Morgan, Hart & Forcade 2017). Multilattices, site-restricted sublattices and per-sublattice concentrations are all supported.

Two things that did not exist in the Fortran and may be the reason to care: per-site allowed_labels with per-sublattice concentrations, so zinc-blende, Heusler and perovskite problems are stated directly rather than encoded around; and a POSCAR round trip—write_enumeration_archive out, read_results / attach_results back—for assembling cluster-expansion training sets without hand-rolling the bookkeeping.

For interoperability there are also standalone enum.x / polya.x / makestr.x executables built with PackageCompiler, so Python workflows (pymatgen’s EnumlibAdaptor) can use it without a Julia installation.

Docs: https://glwhart.github.io/Enumlib.jl
Source: GitHub - glwhart/Enumlib.jl: Julia successor to the Fortran enumlib: derivative-structure / superlattice enumeration with colorings and symmetry reduction. · GitHub

An update since the announcement. Enumlib.jl is now at v0.5.0, and most of the work since September has gone into speed. Compared with v0.4.2, enumerations run 1.5 to 5 times faster. The main gains are in the symmetry reduction of supercells (5–370× faster), the recursive-stabilizer tree (1.3–1.6×), the estimate_cost check before an enumeration (about 2×) and the struct_enum.out writer (about 4×).

Here is how it compares with the Fortran enumlib on the same inputs and the same machine. The Julia column is a call from a running session (enumerate and write struct_enum.out). The standalone column is the compiled enum.x, including its start-up.

Case (supercell volumes) Structures Fortran enum.x standalone enum.x Enumlib.jl from Julia
fcc binary (1–12) 10,850 1.8 s 1.4 s 0.17 s
fcc binary (1–16) 163,373 6.4 s 2.6 s 1.6 s
fcc ternary (1–10) 79,260 1.1 s 1.6 s 0.25 s
hcp ternary (1–6) 584,531 4.5 s 3.2 s 1.3 s

From Julia, Enumlib.jl is 3 to 12 times faster than the Fortran on every case we timed, and the two codes produced the same structures, checked one by one up to symmetry.

The standalone executables changed too. Earlier builds compiled the enumeration code every time they ran, which took 7 to 9 s even for small inputs. From v0.5.0 the code is compiled ahead of time (PackageCompiler with an example run), so a run takes about 1 to 3 s, of which about 0.85 s is starting the Julia runtime. They are also on conda-forge for Linux (x86_64) and Intel macOS, so Python users can get them without installing Julia:

conda install -c conda-forge enumlib.jl

For Apple silicon and Windows, the binaries are on the releases page. The changelog has the details.