"""Cell resizing tools.This script resizes the c vector of all the ``.traj`` files in the currentworking directory to the specified positive number."""frompathlibimportPathfromase.ioimportreadfromnumpy.linalgimportnorm
[docs]defrun(structure:Path,length:float):"""Resize c-vector of structure and centers atoms in cell. Args: structure: A Path leading to the structure whose cell is to be resized. If `structure` points to a file with multiple structures, then the final structure is read. length: A float specifying the new c-vector of the cell. """atoms=read(structure)atoms=atoms[-1]ifisinstance(atoms,list)elseatomsc_vector=atoms.cell[2]c_scale=length/norm(c_vector)atoms.cell[2]=c_vector*c_scaleatoms.center()atoms.write(structure)