using if(factor_coul) or _lj to completely skip calculation loops

Dear all,

I am porting a force-field (SAPT non-bonded interactions for use with
polarizable atoms) to LAMMPS, and while looking at the code for existing
pair styles I noticed that in most cases the codes run through the
Coulombic and LJ pair force calculation loops even when a zero
factor_coul (or factor_lj) from special bonds means that the final pair
interaction should simply be zero.

In my modifications, I am including an if(factor_coul) / if(factor_ij)
condition at the beginning of the loop to completely skip the pair
calculation if unnecessary. I will definitely be testing this to make
sure there are no subtle problems, but I am wondering if this has been
looked at / tried before, and if there is some obvious reason not to use
the if(factor)-trigger that I am missing.

(I know sometimes users set the special_bonds weights to a very small
quantity during analysis reruns to activate intramolecular pair
calculations -- under those cases, the if(factor) should correctly
trigger the calculations as required.)

Thanks in advance!



there is no need for this “optimization”. If a pair may be skipped because of both special_bonds factors being (exactly) zero, then it will already be removed from the neighbor list during neighborlist creation when the special_bonds status is encoded into the neighbor list. If it may not be skipped, e.g. in case of a long-range coulomb solver, it will be kept.