# the difference

Hi,

Usually, the lammps code use half neighbor list to calculate the two body interactions. Now if I do not skip half of the j atoms (neighbor list of atomi), and calculate the force between all i and j atoms. Then do the following procedures:
fpair=fpair/2.0;
evdwl=evdwl/2.0;
f[i] += delxfpair;
f[i] += dely
fpair;
f[i] += delyfpair;
f[j] -= delx
fpair;
f[j] -= delyfpair;
f[j] -= delz
fpair;
if (evflag) ev_tally(i,j,nlocal,newton_pair,evdwl,0.0,fpair,delx,dely,delz);

Except the difference of the computing efficiency, does this have the same meaning with the half neighbor list?

Lisa

hi lisa,

Hi,

Usually, the lammps code use half neighbor list to calculate the two body
interactions. Now if I do not skip half of the j atoms (neighbor list of
atomi), and calculate the force between all i and j atoms. Then do the
following procedures:

no, using full neighbor lists works differently.
in init_style() you have to have the following code:

int irequest = neighbor->request(this);
neighbor->requests[irequest]->half = 0;
neighbor->requests[irequest]->full = 1;

``````            fpair=fpair/2\.0;
``````

fpair does not need to be halved only the energy.

``````             evdwl=evdwl/2\.0;
f\[i\]\[0\] \+= delx\*fpair;
f\[i\]\[1\] \+= dely\*fpair;
f\[i\]\[2\] \+= dely\*fpair;
``````

and then you do not need to add forces to "j"-particles.

``````             f\[j\]\[0\] \-= delx\*fpair;
f\[j\]\[1\] \-= dely\*fpair;
f\[j\]\[2\] \-= delz\*fpair;
if \(evflag\)
``````

ev_tally(i,j,nlocal,newton_pair,evdwl,0.0,fpair,delx,dely,delz);

finally, you have to use ev_tally_full(...);

Except the difference of the computing efficiency, does this have the same
meaning with the half neighbor list?

yes, it should give the same results. i would _highly_ recommend
to try this first with pair_lj_cut.cpp and see if you can get this set up
so that both pair styles produce the same forces and energies.

only have you have understood how this works, i would go back
to working on your custom pair style. otherwise, you are likely
to get lost. i followed this path when i was working on adding
multi-threading to pair styles and it worked very well for me.

cheers,
axel.

Sorry for the misunderstanding. Now I am using the full neighbor list, and the structure is similar with the pair_sw.cpp. But I do not skip half of the j atoms as the code does
if (itag > jtag) {
if ((itag+jtag) 2 == 0) continue; } else if (itag < jtag) { if ((itag+jtag) 2 == 1) continue;
} else {
if (x[j] < ztmp) continue;
if (x[j] == ztmp && x[j] < ytmp) continue;
if (x[j] == ztmp && x[j] == ytmp && x[j] < xtmp) continue;
}

I use all of the jatoms, and do the following:
fpair=fpair/2.0;
evdwl=evdwl/2.0;

And the rest are the same with pair_sw.cpp for two body calculations. Does this has the same meaning with the pair_sw.cpp?