"""Module for functions operating on structure symmetry."""from__future__importannotationsfromaseimportAtomsfromase.spacegroup.symmetrizeimportrefine_symmetryfromspglibimportget_spacegroup
[docs]defspacegroup(struct:Atoms,sym_tolerance:float=0.001,angle_tolerance:float=-1.0)->str:""" Determine the spacegroup for a structure. Parameters ---------- struct : Atoms Structure as an ase Atoms object. sym_tolerance : float Atom displacement tolerance for spglib symmetry determination, in Å. Default is 0.001. angle_tolerance : float Angle precision for spglib symmetry determination, in degrees. Default is -1.0, which means an internally optimized routine is used to judge symmetry. Returns ------- str Spacegroup name. """returnget_spacegroup(cell=(struct.get_cell(),struct.get_scaled_positions(),struct.get_atomic_numbers(),),symprec=sym_tolerance,angle_tolerance=angle_tolerance,)
[docs]defsnap_symmetry(struct:Atoms,sym_tolerance:float=0.001)->None:""" Symmetrize structure's cell vectors and atomic positions. Parameters ---------- struct : Atoms Structure as an ase Atoms object. sym_tolerance : float Atom displacement tolerance for spglib symmetry determination, in Å. Default is 0.001. """refine_symmetry(struct,symprec=sym_tolerance,verbose=False)