Author Topic: distance between point and atom in simulation with periodic boundaries  (Read 60 times)

mike.franky

  • Newbie
  • *
  • Posts: 6
Hi,

I am trying to calculate the distance between the centre of mass of a particle and its atoms programmatically, in an attempt to characterise its shape. The results are inaccurate in directions where I have periodic boundary conditions. I see that the development version of ovito includes an "UnwrapTrajectoriesModifier" which seems to do the job. Is there some relatively easy way of doing something similar with ovito 2.9?

Thanks in advance for any help.

Cheers
Mike
« Last Edit: August 16, 2019, 04:01:27 PM by mike.franky »

Alexander Stukowski

  • Administrator
  • Hero Member
  • *****
  • Posts: 638
Re: distance between point and atom in simulation with periodic boundaries
« Reply #1 on: August 16, 2019, 09:37:14 PM »
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

mike.franky

  • Newbie
  • *
  • Posts: 6
Re: distance between point and atom in simulation with periodic boundaries
« Reply #2 on: September 02, 2019, 04:14:56 PM »
Hi Alex,

Many thanks for your response. It definitely makes a lot of sense, and it is very useful.

However, the particle is actually a droplet, which means there is a small number of atoms that  diffuses into the solvent. Therefore it is not so clear whether an atom 'far away' has just wrapped around a boundary or if it is just an atom that diffused away from the particle. Nevertheless, these loose atoms occupy a very small fraction of the droplet's total number of atoms so I think that your suggestion might still be accurate.

I guess the only alternative would be to keep track of previous atomic velocities, and check whether an atom's position changed contrary to its velocity.

Thanks again for your help.

Mike