IRL2 / nanover-protocol

https://irl2.github.io/nanover/
Other
0 stars 1 forks source link

Incorrect potential energy from OpenMM/Nanover simulations (incorrect analytic form and signs) #155

Open hjstroud opened 1 week ago

hjstroud commented 1 week ago

This issue arises due to the way that the potential energy associated with the forces being passed to OpenMM by NanoVer is defined, specifically the expression IMD_FORCE_EXPRESSION = "-fx * x - fy * y - fz * z". This expression defines the potential energy that OpenMM associates with the user interaction, which yields the correct force when taking the derivative with respect to the position of the atom (and therefore produced the correct dynamics in OpenMM), but calculates the incorrect potential energy for the specific forces applied to the simulation.

The form of this expression also explains why we have been experiencing direction-dependent potential energies, as the expression above accounts only for the xyz coordinates of the atoms, rather than the distance vector between the position of the user interaction and the atom to which it is applied. This means that the sign of the potential energy calculated from this expression changes (and can do so discontinuously) when the force is applied to an atom from the opposite direction. Were this the only issue, the fix would be to replace the expression with -fx * (x - x0) - fy * (y - y0) - fz * (z - z0), where x0,y0,z0 defines the position of the user interaction.

Ragzouken commented 1 week ago

From a conversation this morning: