Dear All,

I want to write a script that compares data of two consecutive time step for each atom ID in a group.
The main aim of the script is to track the position of those atoms which crosses a plane.
For example:
In a box of dimension 40 x 40 x 40, lets take a plane z = 10 and if I want to store only those atom ID’s
and their attributes that crosses the specified plane to a file, how can I do so?
The problems that I’m facing are the following:
I cannot store the previous time-step’s (z-position) data to compare with the next time-step data
so that I can print only those atom IDs that crosses the defined plane.
I tried with the following logic:

  1. My first Approach:

variable a atom z

fix pos_z He store/state 1 v_a ## to store the previous time step z positions

label loopb

variable p loop 2

run 1

label loopa

variable i loop 3921 4420 ## variable to loop the different atom id’s

variable zold equal f_pos_z[$i]
variable znew equal z[$i]

if " ({znew} != {zold}) " then & ### under this if condition values for both the variables are same
"print ‘Atom_Id = {i}' " &** **"print 'Distold = {zold}’ " &
"print ‘Distnew = ${znew}’ "

next i
jump SELF loopa
next p

jump SELF loopb

The new & old values are printing the same, which is not what I want.

  1. My second approach:

region cutoff_plane plane 0.0 0.0 -40.5 0.0 0.0 -1.0
variable inregion atom rmask(cutoff_plane)
dump myDump He custom 1 output/minimized_xyz.comp id type x y z vz

dump_modify myDump thresh v_position |^ LAST

In the second approach, even though the code runs, if I check the dump file there is 0 written below ITEM, signifying there is no atom that crosses the plane. But if I check the general dump file into OVITO I can clearly see the atom crossing the plane even though it doesn’t print in the file. Please help in resolving these issues or any suggestion that can help solve my problem.