# computre group/group vs pe/atom

OK, here is the explanation why you are getting different numbers: both computations are computing different things!

Or to break this down in more detail:
When you do compute pe/atom, there are per-atom accumulators of potential energy contributions. for each pair, the energy for that pair is split in half and added to each atom participating. same for bonds, and for angles/dihedrals/impropers this energy is correspondingly divided evenly by the participating 3 or 4 atoms.
When you do compute group/group the energy for each pair is accumulated, so the contributions where one atom is inside the principal group, and the other outside the group is summed in full, while with compute pe/atom it is only half. This is best verified by comparing the results when you define your water group to contain just one (water) oxygen atom. then the result of compute group/group should be exactly double of what you would get with compute pe/atom pair as each pair would be with an atom outside the group and thus counted half. if you would define your group to have two water oxygens, within the cutoff, the factor of two is no longer given, since now both halves of the interaction between the two oxygens are included, but everything else is only half. and correspondingly for defining the group with more atoms.

now, it depends on carefully defining what it is that you want to compute and accumulate, and that determines how you need to go about computing it. while superficially, you might think that these two calculations would be the same, they are - in fact - not and I suspect neither is actually computing what you are asking for. the problem here is that your request āthe potential energy of a group of water moleculesā is somewhat ambiguous. you have to be more specific about what it is you want.

axel.

Hi Axel,

Thank you very much for the explanation! Itās very helpful!

What Iām trying to do is monitor the non-bonded (LJ and Coul) potential energy of a group of waters as they are adsorbed to a polymer slab. I would like to be able to compare the energies of water interacting with different polymer substrates. If possible, it would be nice to be able to separate the pair interactions into a water-water potential energy and water-polymer potential energy. Do you have any recommendations?

• Stacey

Hi Axel,

Thank you very much for the explanation! Itās very helpful!

What Iām trying to do is monitor the non-bonded (LJ and Coul) potential energy of a group of waters as they are adsorbed to a polymer slab. I would like to be able to compare the energies of water interacting with different polymer substrates. If possible, it would be nice to be able to separate the pair interactions into a water-water potential energy and water-polymer potential energy. Do you have any recommendations?

this should be doable with compute group/group, but then the second group has to either only include the water or only include the polymer. but please note, that since this is using the Pair::single() function, it can have a significant negative performance impact, so the compute should only be called infrequently or used in post-processing with rerun (where you can then use cutoff coulomb with a suitably long cutoff for faster execution and more accurate partitioning without negatively impacting forces) and also otherwise tailor your force field to only include contributions that you want to account for.

axel.

ā¦and in postprocessing, you could also just change the forcefield, e.g. to use pair style hybrid and define only lj/cut/coul/cut for the pairs of types you want to monitor and none or zero for the others. then simply outputting pe should give you the potential energy you are looking for.

Thanks again!

I was planning to us rerun to compute the potential energies so I didnāt have a performance issue to worry about. I do like the post processing method of setting only the interactions I want.

Thanks for the ideas!