Calculating distance between two group of atoms

Hi all,
I am trying to calculate the distance at the interface of Graphene and polymer.
Is there a direct way to calculate the distance between two groups of atoms?
Right now I am thinking of using property/local ptype1 ptype2 to get the distance between pairs of atoms and then take the average. However, as it includes all distances the file becomes very large.

Thanks

You first have to decide what you consider to be the “location” of a group. Is it the geometric center or the center of mass or the “middle of the extent”. Then you also need to decide whether you want the direct distance between multiple centers of mass, or only the difference of a single component, e.g. the z-axis distance.

Assuming that you would pick the center of mass, then you can get access to its component through equal style variables. See the “xcm()” group function in variable command — LAMMPS documentation
That allows you to determine the x, y, z distance and from that easily the total distance.

You can also use compute reduce ave to get the geometric center in each dimension.

Thanks for the suggestions. It helped me to figure out my problem.