[lammps-users] calculate LJ between one pair of particles


I would like to check my calculation. I set up one group consisting of only two particles. I try to calculate the evdwl in this group by compute command. However, LAMMPS always gives me the total evdwl of the system. The relevant commands are as following:

group 1 id 344 345
variable LJ_pair equal evdwl
variable distance equal sqrt(add(mult(sub(x[344],x[345]),sub(x[344],x[345])),mult(sub(y[344],y[345]),sub(y[344],y[345]))))

compute 2 1 variable LJ_pair
compute 4 1 epair/atom
compute 5 1 attribute/atom x

fix 6 1 print 50 " at {stepi} distance = {distance} LJ = ${LJ_pair}"
dump 3 1 custom 50 pairPotential c_4
dump 4 1 custom 50 attributesFile c_5

By the command of “compute 2 …” I assume that LAPPMS should calculate the LJ interaction in group 1, not the whole system. Apparently, it is not. Could anyone tell me how I can get LJ between two particles?

dump 3 and dump 4 only gives me two empty files. I am confused why two files are empty. Please give me a hint.

All the best!


The compute variable command ignores the group; it just evaluates the
variable. The
variable, as you've defined it, will be the interaction between only 2
atoms. The thermo
printed by the system may be normalized by dividing by the number of
atoms (e.g. for
lj units), so it could look like the same value as for 1 interaction.

Your 2 dump commands create valid files in my version of LAMMPS.