Hi Mike,

If your particle's largest diameter is smaller than half of the simulation box size, then you can apply the minimum image convention and do the following:

In a first step, you determine the current center of mass of the particle. Instead of simply calculating the sum of all atom position vectors (and dividing by the number of atoms), you need to calculate the sum of all vectors from some reference atom in the particle (it doesn't matter which one) to every atom of the particle. Each of these vectors needs to be wrapped around if it is longer than half the box size. Thus, you need to extend your Python script accordingly.

In the second, once you have the center of mass, you are going to calculate the vectors from the center of mass to each of the atoms. Here, again, you need to wrap around the computed vectors in case the span more than half the box size (which indicates that the atom is on the opposite side of the box from the center of mass).

Does that make sense? If not, let me know.

-Alex