LAMMPS WWW Site - LAMMPS Documentation - LAMMPS Mailing List Archives
[lammps-users] Issue with keeping track of a pair distance, mismatched compute
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Vũ Hoàng Nguyễn <nguyenhoangvu3010@...24...>
Date: Tue, 20 Jun 2017 13:14:00 -0600

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 am looking forward to hearing from you. Thanks in advance.

Vu H. Nguyen