how to compute the number of crossings through a plane?

Hi all,

I would like to compute the number of atoms that cross the plane z=0 of my simulation box. I think I could do a loop over all the atoms of a group, and accumulate the number of crossings in a variable if the z-coordinate of the atoms change its sign in two consecutive steps.

But I don't know how to do this in LAMMPS. Anyone can help me?

Thanks,

Alfonso

Hi all,

I would like to compute the number of atoms that cross the plane z=0 of
my simulation box. I think I could do a loop over all the atoms of a
group, and accumulate the number of crossings in a variable if the
z-coordinate of the atoms change its sign in two consecutive steps.

But I don't know how to do this in LAMMPS. Anyone can help me?

it is not clear from your description of what you want to count
exactly and what you need it for. it most certainly is not as trivial
as you seem to think.

how do you plan to handle the case of an atom oscillating around z=0?
or in other words, what exactly constitutes a crossing. typically,
there is a minimum residence time required before a crossing is
counted as such.

how do you plan to count atoms that are "recrossing", i.e. pass from
negative z to positive z, stay there a while and then return. is this
supposed to count as two crossings or zero (1x +1 and 1x -1)
crossings?

unless you need very high-resolution, you may be best off to do this
analysis in postprocessing a recorded analysis. please note that
unless you program your analysis as custom c++ style in LAMMPS, the
analysis will likely be very inefficient and not parallelized.

axel.

I suppose you can create a compute that passes the plane coordinate as an arg and create an array that stores a flag for every atom, you can access the atom positions through the atom->x array. You then test the atom position and assign a flag (-1 or 1). One measure of crossing might be to have a flag array b_0 for the initial configuration with which to compare any crossing that is permanent and not oscillatory. Make sure the array b_0 is only set up in the initial timestep and then have an array b that you do repopulate with flags every time step and return the number of crossings through the compute scalar method. Since every process stores its own (N/P) flags and atoms the compute should be parallel if you just use MPI_Allreduce for the crossing counts in each processor.