Page 1 of 1

Energy mismatch when identical particles belong to different types

Posted: Fri Sep 15, 2017 12:50 am
by gpantel
Dear all,

Currently I am trying to do something which involves setting many particles to individual types so that each particle can have unique cross-terms with other particles in a system.

However, there seems to be an issue where if I create a type for each particle, even if the cross-terms for these particles are all equal, the energy is different from if I assigned all particles of equal parameters to one type.

In the files here, OpenMM 7.1 is calculating the energy of an input configuration for the case where there are LJ particles of unique parameters "A", "B", and "C". In 3types.py A, B, and C particles are each assigned to one atom type. In Ntypes.py, A, B, and C particles are each assigned to their own type.

Epsilon and sigma parameters are assigned using a customNonbondedForce with mm.Discrete2DFunction. The initial potential energies and potential energies after minimization are very different.

Am I making some mistake? Is there some issue with how Discrete2DFunctions calculate energy?

Thank you for any insight!

Re: Energy mismatch when identical particles belong to different types

Posted: Mon Sep 18, 2017 1:29 pm
by peastman
Here's your problem:

Code: Select all

for particle in np.arange(nparticles):
    system.addParticle(mass)
    customNonbondedForce.addParticle([i])
That should be addParticle([particle]), not addParticle().

Re: Energy mismatch when identical particles belong to different types

Posted: Mon Sep 18, 2017 7:28 pm
by gpantel
Hi Peter,

What a dumb mistake! Thank you so much for checking the script for me Peter, sorry this was such a dumb question.

Re: Energy mismatch when identical particles belong to different types

Posted: Mon Sep 18, 2017 7:44 pm
by peastman
No problem. Silly mistakes like that are sometimes the hardest ones to notice!