# What is 'offset' in PairBuck::single?

Hello, I am new user/developer here.

I am looking at PairBuck::single in the file pair_buck.cpp and I would like to know conceptually what is the purpose of the 2D array ‘offset’. I’ve included the code below:

/* ---------------------------------------------------------------------- */

double PairBuck::single(int i, int j, int itype, int jtype,
double rsq, double factor_coul, double factor_lj,
double &fforce)
{
double r2inv,r6inv,r,rexp,forcebuck,phibuck;

r2inv = 1.0/rsq;
r6inv = r2invr2invr2inv;
r = sqrt(rsq);
rexp = exp(-rrhoinv[itype][jtype]);
forcebuck = buck1[itype][jtype]rrexp - buck2[itype][jtype]r6inv;
fforce = factor_lj
forcebuck
r2inv;

phibuck = a[itype][jtype]*rexp - c[itype][jtype]r6inv -
offset[itype][jtype];
return factor_lj
phibuck;
}

/* ---------------------------------------------------------------------- */

Also it seems that ‘forcebuck’ and ‘fforce’ are unused and could be commented out, correct me if i am wrong.

Thanks again,
-mike waters.

hello mike,

Hello, I am new user/developer here.

I am looking at PairBuck::single in the file pair_buck.cpp and I would like
to know conceptually what is the purpose of the 2D array 'offset'. I've

offset is the potential energy at the cutoff.
by populating offset (activated through pair_modify shift yes)
you shift the potential energy so that there is
no discontinuity in the energy around the
cutoff distance. it has no impact on the
force, but makes a different when the energy
matters, e.g. in minimization calculations.

included the code below:

/* ---------------------------------------------------------------------- */

double PairBuck::single(int i, int j, int itype, int jtype,
double rsq, double factor_coul, double factor_lj,
double &fforce)
{
double r2inv,r6inv,r,rexp,forcebuck,phibuck;

r2inv = 1.0/rsq;
r6inv = r2inv*r2inv*r2inv;
r = sqrt(rsq);
rexp = exp(-r*rhoinv[itype][jtype]);
forcebuck = buck1[itype][jtype]*r*rexp - buck2[itype][jtype]*r6inv;
fforce = factor_lj*forcebuck*r2inv;

phibuck = a[itype][jtype]*rexp - c[itype][jtype]*r6inv -
offset[itype][jtype];
return factor_lj*phibuck;
}

/* ---------------------------------------------------------------------- */

Also it seems that 'forcebuck' and 'fforce' are unused and could be
commented out, correct me if i am wrong.

you _are_ wrong. please note that fforce is passed
to the single method by reference.

please also note, that the single method is only
called when force/energy between explicit pairs
are requested, e.g. through a compute group/group
the usual force/energy computation is done in
the Pair::compute() method of the derived class.

cheers,
axel.

I have some more questions about the same potential,

What are factor_lj, etail, and ptail?

Thanks again,
mike waters

I have some more questions about the same potential,

What are factor_lj, etail, and ptail?

factor_lj is scaling factor for 1-2, 1-3, or 1-4 exclusions
whether one of those exclusions applies is signaled
by a bitmask added to the j index of an i-j pair in the
neighbor list.

etail is the tail correction energy, i.e. the correction
to the total energy from cutting off interactions.

ptail is the same like etail but for pressure.

all of these are actually parameters that are not
potential specific. i suggest you always have a
look at the pair.h and pair.cpp file to see what
happens on top of what an individual pair class does.

when i started using/programming LAMMPS,
i found out the meaning and use of most of
those through using grep and reading through
the "most promising" source files that would
match a grep search.

cheers,
axel.

My mutation of the Buckingham potential into a Rydberg potential compiles now. Once it functions properly, would the developers want to a copy?

-thanks,
mike waters

sure - if its a different functional form than what
LAMMPS currently has - be sure to also write
a doc page with a LaTeX formula, following
the pattern of one of the doc/pair*.txt files

Steve