Compute pairwise

Dear Lammps users

Could you please guide me on how I can compute pairwise distances and forces between a certain particle and the others?

https://docs.lammps.org/compute_pair_local.html

Really thank you for your kind help.

To compute the pairwise quantities between the certain particle (let’s say particle C) and the others, I defined a sphere region with cutoff type and centered at the position of particle C moving along with it. Although this region determines the particles interacting with particles C, it also takes into account the other pairwise particles inside the region.
I used property/local to find out which interactions related to particle C and its neighbor.

compute 1 group1 property/local natom1 natom2
compute 2 group1 pair/local dist eng force

dump 1 group1 local 1 pairwise1.dump index c_1[1] c_1[2]
dump 2 group1 local 1 pairwise2.dump index c_2[1] c_2[2] c_2[3]

The problem is that the number of pairwise cases listed in c_1 in each time step is not equal to the number of cases listed in c_2.
(I get " [Dump local count is not consistent across input fields]" error if I use
dump 0 group1 local 1 pairwise0.dump index c_1[1] c_1[2] c_2[1] c_2[2] c_2[3])

could you please let me know why the cases listed in property/local are not the same as the cases given by pair/local? and could you please help me with how I can label the interaction between particle C and its neighbor?
or maybe there is a more direct and convenient way/command to calculate the pairwise quantities between particle C and its neighbor.

Your description is all to vague and you only have very limited information about what you did and how and why. To comment further, however, it is necessary to reproduce your issue.

Thus please create a minimal simulation input deck that is sufficient to just reproduce your issue and does not contain anything unrelated to that and provide it here with a detailed description.

Thank you very much for your reply.

I am sorry because of the inconvenience. I try to explain my problem as simply and clearly that it is possible.
I have a bath of particles interacting with each other and a single particle traveling through this bath. I am going to compute the pairwise distances and forces between the traveling particle and each particle in the bath.
As far as I learn from LAMMPS manual I must use “property/local” along with “pair/local” as mentioned in compute pair/local command — LAMMPS documentation :
"
compute 1 all property/local patom1 patom2
compute 2 all pair/local dist eng force
dump 1 all local 1000 tmp.dump index c_1[1] c_1[2] c_2[1] c_2[2] c_2[3]
"
But when I run this code, the number of rows of the output of "compute property/local "is not equal to the number of rows of the output of “compute pair/local”. So the two outputs can not be dumped in a single file and Lammps gives the error: “Dump local count is not consistent across input fields”.

of course, it is possible to dump each output in a single file but this can not help me. I need to know which force is related to which pair particle so I have to know the IDs or types corresponding to each pair particle.

This is a very simplified version of my code:

echo both
units lj
dimension 3
boundary p p p

atom_style atomic

region simbox block 0 15.0 0 15.0 0 15.0
create_box 2 simbox
create_atoms 1 random 3999 257349 NULL
create_atoms 2 single 7.5 14.0 14.0

mass * 1

group bath type 1
group particle_C type 2

velocity all create 0.15 492859 dist gaussian rot yes
velocity particle_C set 0.0 0.006 0.0

pair_style hybrid lj/expand 3.1 lj/cut 2.5
pair_coeff * 2 lj/expand 1.0 1.0 0.1 3.1
pair_modify shift yes
pair_coeff 1 1 lj/cut 1.0 1.0 2.5

minimize 10e-7 10e-7 100000 100000

thermo_style custom step time
thermo 100

fix 1 bath nvt temp 0.15 0.15 1
fix 2 particle_C move linear 0 0.006 0 units box
fix 3 bath momentum 1 linear 1 1 1

compute 1 all property/local natom1 natom2
compute 2 all pair/local dist eng force

dump 0 all local 1 pair0.dump index c_1[1] c_1[2] c_2[1] c_2[2] c_2[3]
#dump 1 all local 1 pair1.dump index c_1[1] c_1[2]
#dump 2 all local 1 pair2.dump index c_2[1] c_2[2] c_2[3]

run 5000

undump 0
#undump 1
#undump 2

unfix 1
unfix 2
unfix 3

I should mention that a similar problem has been asked previously on “missing neighbors in the neighbor list... - #9 by _Mahaguruge_N” but I could not find the answer.

Hope this explanation would be clear.
I would appreciate it if you could help me with how I can solve this problem so that I can compute the pairwise force between the traveling particle and its neighbor.

That is a very old message from the mailing list. Any corrections that this exchange is referring to are included in the LAMMPS code so there is nothing that you can do in addition.

Yes, this is something that I can work with.

This requires some careful debugging. The behavior that you are observing is unexpected, since you have done exactly what the documentation suggests, so it can take some effort to identify the cause.

Thank you so much for your consideration and attention to this matter.

Actually, I was wondering if you could estimate how much time it requires to identify the reason that causes the problem? And also, if you could guide me on whether there is any other way to compute pairwise quantities between a certain particle and its neighbors?
Thank you.

There is a small but significant difference between documentation and your code.
You use:
compute 1 all property/local natom1 natom2
where it should be:
compute 1 all property/local patom1 patom2

Exchange the lines and your example works.

1 Like

thank you for your precious reply.
It works well.