How to define an unwrapped atom coordinate as a variable

Is it poosible to define a variable equal to unwrapped coordinates of an atom? Something along the lines- “variable x1 equal xu[100]”?

Details(Please skip if unnecessary): Lets say that I have 100 particles in a certain section, with some external field. My problem is that I need to run Langevin dynamics sumulation only until x coordinates of the bunch of particles cross the section. Currently I add following to my input script to do this-

label loopa

variable i loop 10
variable x1 equal x[1] # coordinates of first atom

variable x2 equal x[100] # coordinates of last atom

if ‘$x1 < -1’ then ‘jump infile break1’ # section is -1<x<1

if ‘$x2 > 1’ then ‘jump infile break1’
run 1000 pre no post no

next i
jump infile loopa
label break1

This mostly works welll, but since I need to use periodic boundary conditions, sometimes first atom crosses the right boundary before last atom crosses the section. Since its image enters from the left, the first “if” condition is satisfied and the loop breaks prematurely. Can I define unwrapped coordinates in some way instead, to overcome this problem?


You can do it indirectly. Use compute property/atom
to assign xu to a compute. Then reference the compute
value in a per-atom variable.