Per-atom Coul and Vdwl energies

Dear LAMMPS Users,

I am creating a new fix that requires per-atom Coulombic and van-der-Waals energy contributions separately on-the-fly. Currently, pair.h/cpp has the per-atom pairwise energy eatom[i] that is maintained (i.e. memory creation/destruction) as well as tallied (ev_tally()) in those two files. It seems like the most efficient hack to obtain a breakdown of eatom[i] is to modify pair.h/cpp to create create ecoulatom[i] and evdwlatom[i] per-atom variables and modify the ev_tally() function to tally the two quantities.

The three questions are as follows:

  1. Is this a solved question?

  2. Is there any reason this won’t work?

  3. Is there a better way to go about this hack?

This issue was previously touched upon here: https://sourceforge.net/p/lammps/mailman/message/30020222/

Any insight would be appreciated.

Thanks,

Ketan

If you use pair hybrid, e.g. with pair lj/cut and pair coul,
then each of those sub-styles will tally the per-atom LJ
eng and Coulombic energy separately, which your
fix could then access.

Steve

If you use pair hybrid, e.g. with pair lj/cut and pair coul,
then each of those sub-styles will tally the per-atom LJ
eng and Coulombic energy separately, which your
fix could then access.

one has to add, that there is currently no specific API to access
these individual values (how about adding it to pair::extract() with a
"eatom:<substyle>" tag or similar?), so you would either have to add
it, or make sure that you have a hybrid pair style and then cast Pair
*pair to PairHybrid *mypair.

axel.

Dear LAMMPS Users,

I am creating a new fix that requires per-atom Coulombic and van-der-Waals
energy contributions separately on-the-fly. Currently, pair.h/cpp has the
per-atom pairwise energy eatom[i] that is maintained (i.e. memory
creation/destruction) as well as tallied (ev_tally()) in those two files.
It seems like the most efficient hack to obtain a breakdown of eatom[i] is
to modify pair.h/cpp to create create ecoulatom[i] and evdwlatom[i] per-atom
variables and modify the ev_tally() function to tally the two quantities.

before commenting on your questions, i have a question on my own: why?
in other words, what is your fix going to do that requires this
information and that cannot be obtained differently.

The three questions are as follows:

1. Is this a solved question?

only partially. a general API from the LAMMPS script level would
require significant changes to multiple parts of the code, and it thus
not likely. you had steve's suggestion, which is quite elegantly
addressing the problem, but requires some programming and
understanding of LAMMPS.

2. Is there any reason this won’t work?

i strongly advise against changing pair.cpp/.h. your proposal would
require changes to quite a few parts of the code that are dependent on
the current behavior and also would significantly increase memory use
for no benefit for most users. both are good reasons to not doing it
this way. better follow steve's suggestion. the memory use in
pair_hybrid already happens and only when you use it, so it doesn't
not penalize everybody that does not use your fix.

3. Is there a better way to go about this hack?

again, see steve's suggestion.

axel.