How to get bond atoms id and special bond coefficient

Dear all,

Recently, I encountered some problems with bond atoms.

  1. How could I know the id of a atom’s bond atoms? I found in fix_shake.cpp, atom->special is used to get tags of bond atoms first and then atom->map function is used to get atom id. In bond_harmonic.cpp, neighbor->bondlist provides the information of bonds. But it couldn’t directly provide the bond atoms’ id of an atom. (curious why the neighbor class is used here) Is there any other way better than the first method?

  2. How could I fetch special_coul if I know the id of a pair of atoms? In pair_coul_cut.cpp, there exists the following code:

for (ii = 0; ii < inum; ii++) {
i = ilist[ii];
qtmp = q[i];
xtmp = x[i][0];
ytmp = x[i][1];
ztmp = x[i][2];
itype = type[i];
jlist = firstneigh[i];
jnum = numneigh[i];
for (jj = 0; jj < jnum; jj++) {
j = jlist[jj];
factor_coul = special_coul[sbmask(j)];
j &= NEIGHMASK;

I check the sbmask function in pair.h and find it is only bitwise operation on j. So does it mean that the special_bond information (whether a pair of atom is 1-2 1-3 or 1-4 pair) has been created and stored in the neighbor-list when neighbor list is created?(I’m sorry that I didn’t check in detail how the neighbor list is created in LAMMPS.) Is the j &=NEIGHMASK used to remove such information and retrieve atom id?

Thanks in advance.

Han

Dear all,

Recently, I encountered some problems with bond atoms.

1. How could I know the id of a atom's bond atoms? I found in
fix_shake.cpp, atom->special is used to get tags of bond atoms first and
then atom->map function is used to get atom id. In bond_harmonic.cpp,
neighbor->bondlist provides the information of bonds. But it couldn't
directly provide the bond atoms' id of an atom. (curious why the neighbor
class is used here) Is there any other way better than the first method?

​the two different methods serve different purposes. please note that the
contents of the bond list depend on the state of the force->newton_bond
flag, which decides how bonds straddling sub-domains are handled and
computed.

2. How could I fetch special_coul if I know the id of a pair of atoms? In
pair_coul_cut.cpp, there exists the following code:

​what is "the id of a pair of atoms"?​

​please also note that "atom id" in the context of LAMMPS usually refers to
it "global id", i.e. the value of atom->tag[].​

for (ii = 0; ii < inum; ii++) {

    i = ilist[ii];
    qtmp = q[i];
    xtmp = x[i][0];
    ytmp = x[i][1];
    ztmp = x[i][2];
    itype = type[i];
    jlist = firstneigh[i];
    jnum = numneigh[i];
    for (jj = 0; jj < jnum; jj++) {
      j = jlist[jj];
      factor_coul = special_coul[sbmask(j)];
      j &= NEIGHMASK;

I check the sbmask function in pair.h and find it is only bitwise
operation on j. So does it mean that the special_bond information (whether
a pair of atom is 1-2 1-3 or 1-4 pair) has been created and stored in the
neighbor-list when neighbor list is created?(I'm sorry that I didn't check
in detail how the neighbor list is created in LAMMPS.) Is the j &=NEIGHMASK
used to remove such information and retrieve atom id?

​yes, and yes. ​