# Request for information on reverse_comm_pair and forward_comm_pair

Dear LAMMPS developers,
We (novice to parallel programming) are looking to develop a new pair potential into LAMMPS.
Using the compute method in pair_eam as example, could you please tell me the what do methods “pair_comm_pair” and “forward_comm_pair” do and why are they are required (pair_lj_cut of pair_morse, for example, do not have them) ?
I have pasted the relevant part of the pair_eam.cpp code below.
I thank you very much for your kind consideration of my request and eagerly look forward to your response.
Sincerely,
Kedar.

//code_snippet_begin

for (ii = 0; ii < inum; ii++) {
i = ilist[ii];
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];

delx = xtmp - x[j][0];
dely = ytmp - x[j][1];
delz = ztmp - x[j][2];
rsq = delxdelx + delydely + delz*delz;

if (rsq < cutforcesq) {
jtype = type[j];
p = sqrt(rsq)*rdr + 1.0;
m = static_cast §;
m = MIN(m,nr-1);
p -= m;
p = MIN(p,1.0);
coeff = rhor_spline[type2rhor[jtype][itype]][m];
rho[i] += ((coeff[3]*p + coeff[4])*p + coeff[5])*p + coeff[6];
if (newton_pair || j < nlocal) {
coeff = rhor_spline[type2rhor[itype][jtype]][m];
rho[j] += ((coeff[3]*p + coeff[4])*p + coeff[5])*p + coeff[6];
}
}
}
}

// communicate and sum densities

if (newton_pair) comm->reverse_comm_pair(this);

// fp = derivative of embedding energy at each atom
// phi = embedding energy at each atom

for (ii = 0; ii < inum; ii++) {
i = ilist[ii];
p = rho[i]*rdrho + 1.0;
m = static_cast §;
m = MAX(1,MIN(m,nrho-1));
p -= m;
p = MIN(p,1.0);
coeff = frho_spline[type2frho[type[i]]][m];
fp[i] = (coeff[0]*p + coeff[1])*p + coeff[2];
if (eflag) {
phi = ((coeff[3]*p + coeff[4])*p + coeff[5])*p + coeff[6];
if (eflag_global) eng_vdwl += phi;
if (eflag_atom) eatom[i] += phi;
}
}

// communicate derivative of embedding function

comm->forward_comm_pair(this);

//code_snippet_end

Dear LAMMPS developers,
We (novice to parallel programming) are looking to develop a new pair
potential into LAMMPS.

you obviously also are new mailing lists.

to a previous e-mail, particularly not, when this is a
digest mail and when you quote the entire mail.
this just generates a huge amount of entropy by
forcing electrons to convey a lot of data to every
subscriber that they have already seen and don't
necessarily want to see again.

Using the compute method in pair_eam as example, could you please tell me
the what do methods "pair_comm_pair" and "forward_comm_pair" do and why are
they are required (pair_lj_cut of pair_morse, for example, do not have them)
?

those are required because LAMMPS does domain
decomposition and those routines are required to
exchange information with the copies of atoms that
are located on a different processor.

in the case of eam, the first section of the compute
method computes a per atom property (rho) that is
computed by summing over contributions from all
neighbors. if newton's third law is active for pair potentials,
each pair of atoms where one atom is a local atom
and the second atom is a ghost atom (i.e. local atom
in a neighboring domain) is listed only once. thus
for those atoms, rho will be incomplete. the reverse
communication will send the missing information
around. check out pack_reverse_comm() and
unpack_reverse_comm()
if newton_pair is off, this is not needed. this trades
off more computation (the neighbor list has all
neighbors, so some pairs are processed twice)
for communication.

the forward communication is needed to
communicate per atom properties to the
ghost atoms of the neighbors (in the example
of eam it is the fp array). these are properties
that are computed for local atoms in the first
step but are then for both indices i and j when
looping over the neighbor list in the force compute.

hope that helps,
axel.

Thank you Axel for your detailed response.

Best,
Kedar.