[lammps-users] sorting atoms


are there some functions already embedded in Lammps which can do such jobs, for instance, sorting/rearranging the atoms according to their z-coordinate values from low to high, or similar things?

Thanks and regards.

Xiang Gu

I am not sure if LAMMPS has this (did not check the whole manual,
perhaps you can do so). However, if you are working on a Linux/Unix
OS, you can use the sort command to sort atoms according to thier
x/y/z coordinate values. For example, if "file.xyz" has the x, y, and
z co-ordinates in the 1st, 2nd and 3rd columns respectively, the
following script will sort the "z" co-ordinates of the atoms in
increasing order:
cat file.xyz | gawk '{print $3}' | sort -g
If you want to sort it in decreasing order use also the -r option in
sort, as follows:
cat file.xyz | gawk '{print $3}' | sort -r -g

Institute for Plasma Research, BHAT,
Gandhinagar, Gujarat, India - 382428

You can bin atoms in 1d spatially via the fix ave/spatial
command, for the purpose of accumulating stats on them.

But there is no global sort in LAMMPS. Not a very parallel
operation. Since processors own spatial domains, what
does it even mean to sort the atoms, when they are
spread across procs. Why do you want to do it?