orgdisord.enumerate.align_components_to_reference

orgdisord.enumerate.align_components_to_reference#

orgdisord.enumerate.align_components_to_reference(atoms, reference_centroids, cell, cutoff_scale=1.25, search=1, mass_weighted=False)[source]#

Align connected components (molecules) from atoms to reference_centroids by integer-cell translations. Returns a new ASE Atoms copy.

Each component is matched to a distinct reference centroid by minimising the total nearest-image distance (optimal assignment), then shifted by the whole lattice vector that puts its centroid in the same lattice image as its reference. Components only ever move by whole cell vectors, so the periodic structure is unchanged.

The result deliberately is NOT re-wrapped afterwards: the same physical molecular site must sit in the same lattice image in every config, which is what makes configs safe to mix tile by tile in a supercell.

Components left unmatched (more components than references) are not moved.