Question about modifying pair potential, what's PairLJCut::single for?


I want to modify the lj potential in 'pair_lj_cut.cpp', everything is
fine, except the 'PairLJCut::single' part makes me really confused.

In the manual, it says 'PairLJCut::single' is for 'force and energy
of a single pairwise interaction between 2 atoms', what does this
mean? Since all the pair interactions have already been calculated in
the compute part, right?

In this part of code:

double PairLJCut::single(int i, int j, int itype, int jtype, double rsq,
                         double factor_coul, double factor_lj,
                         double &fforce)
  double r2inv,r6inv,forcelj,philj;

  r2inv = 1.0/rsq;
  r6inv = r2inv*r2inv*r2inv;
  forcelj = r6inv * (lj1[itype][jtype]*r6inv - lj2[itype][jtype]);
  fforce = factor_lj*forcelj*r2inv;

  philj = r6inv*(lj3[itype][jtype]*r6inv-lj4[itype][jtype]) -
  return factor_lj*philj;

'fforce' and 'philj' are exactly the same as 'fpair' and 'evdwl'
functions in 'PairLJCut::compute' part, so why calculate them again
outside the loop? What are those two functions used for in lammps
If I want to change the lj potential, how do I modify this part?

I appreciate your help very much.

What are those two functions used for in lammps

You could answer this yourself if you grep for calls
to pair->single.

It's used in some other classes, like compute group/group.

If you want a fully functional new pair style, then you
have to implement both compute() and single() correctly.