LAMMPS WWW Site - LAMMPS Documentation - LAMMPS Mailing List Archives
Re: [lammps-users] Issue with keeping track of a pair distance, mismatched compute

# Re: [lammps-users] Issue with keeping track of a pair distance, mismatched compute

 From: Vũ Hoàng Nguyễn Date: Thu, 22 Jun 2017 12:00:29 -0600

​Hi all,

Regarding to my question on keeping track of one atom pair's distance. I tried using the xcm() func​tion as below:

group           9      id 9

group           19     id 19

variable        9_19   equal sqrt((xcm(9,x)-xcm(19,x))^2+(xcm(9,y)-xcm(19,y))^2+(xcm(9,z)-xcm(19,z))^2)

print           \${Nstep} \${9_19}

The result is that the 9_19 distance increases and surpasses the value corrsponding to a boz size of ~120 angstrom as following. Such reported distance is unexpected thus cannot be used in an if command.

100 14.8919674850164

100000 103.713384457798

120000 144.331595676238

200000 178.699195701745

400000 194.973058071275

4000000   303.640648137181

40000000  2338.88145203497

Can you help me explain how the xcm() works relating to unwrapped coordinates and will using the xcm() function result in the correct pair distance, in which the Nearest Image Conention is taken into account?

Thank you so much,

Vu H. Nguyen

On Tue, Jun 20, 2017 at 3:31 PM, Axel Kohlmeyer wrote:

On Tue, Jun 20, 2017 at 5:25 PM, Vũ Hoàng Nguyễn wrote:
Hi all,

Thanks to Alex's suggestion, the job is on the run for now, I'll keep you posted with the result. I have side question on equal-style varibale, why cannot a local property, for example, a pair/local distance be assigned as a variable in case it's a single value?

​LAMMPS doesn't know that and must not assume it.

equal style variables​ require data that is globally uniquely identifiable. this is obvious for global system properties and for per-atom data, that is easily possible with the atom id. for local data such a global identifier does not exist.

axel.

Best,

Vu H. Nguyen

Vu H. Nguyen

On Tue, Jun 20, 2017 at 1:25 PM, Axel Kohlmeyer wrote:

On Tue, Jun 20, 2017 at 3:14 PM, Vũ Hoàng Nguyễn wrote:
Hi all,

My purpose is to first, calculate (or to keep track) the distance between atom ID #9 and #19 and then, assign the distance as a variable to use as a condition in a following if command.

What I did was:

variable        9_19   equal sqrt((x[9]-x[19])^2+(y[9]-y[19])^2+(z[9]-z[19])^2)

run             1000000 every 100 "if '\${9_19} < 1.0' then 'print \${Nstep}=0=1 append record.dat'"

This works until I notice that LAMMPS reports the 9_19 pair distance regardless of the Nearest Image Covention. So the distance sometimes get bigger than [(box_side)*sqrt(3)]/2, which is not expected.

My other thought is that,

group           test_pair id 9 19

compute         distance test_pair pair/local dist

variable        9_19 equal c_distance

run             1000000 every 100 "if '\${9_19} < 1.0' then 'print \${Nstep}=0=1 append record.dat'"

The latter solution results in an error of "ERROR: Mismatched compute in variable formula (../variable.cpp:1548)".

I have found that local properties cannot be assigned to equal-style variables.

So is there any way to go about this issue or, how to extract a pair distance and use it internally as a variable in an 'if command' condition?

​i think what you need is are unwrapped coordinates. x[] and y[] and z[] are wrapped coordinates, so if one of them has a "jump" because the atom is passing through a periodic boundary, you have the jumps in your distance. now unwrapped coordinates are not available (yet) in variable expressions, but if this concerns only two specific atoms there might be a workaround: you can define a group for each of them, and then use the xcm() function to get the center of mass (which is computed using unwrapped coordinates and with only one atom in the group is equivalent to the position) and then use that for computing your distance.

axel.

I am looking forward to hearing from you. Thanks in advance.

Vu H. Nguyen

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
_______________________________________________
lammps-users mailing list
lammps-users@...655....net
https://lists.sourceforge.net/lists/listinfo/lammps-users

--
Dr. Axel Kohlmeyer  akohlmey@...24...  http://goo.gl/1wk0
College of Science & Technology, Temple University, Philadelphia PA, USA
International Centre for Theoretical Physics, Trieste. Italy.

--
Dr. Axel Kohlmeyer  akohlmey@...24...  http://goo.gl/1wk0
College of Science & Technology, Temple University, Philadelphia PA, USA
International Centre for Theoretical Physics, Trieste. Italy.