-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Energy bug in PlumedForce #91
Comments
This seems to not happen with This here will wrongly change energies the second time you retrieve them:
While this one here works fine:
|
I forgot to mention that to test this with my python script you need to compile #90 since it requires the temperature to be set. |
What version are you using? This sounds like the bug that was fixed in #82. The fix is in the current release (2.0.1). |
Possibly related? #64 |
I'm using the latest #90 build with the python fixes
…On Wed, Nov 13, 2024, 19:50 Toni G ***@***.***> wrote:
Possibly related? #64 <#64>
—
Reply to this email directly, view it on GitHub
<#91 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AB4RLAVQJUTVXG5LZBMJBKL2AOGPJAVCNFSM6AAAAABRWQCAP6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINZUGMZTGNZRGE>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
I think this is inherent in your PLUMED script? You tell it to do metadynamics. When it evaluates the energy, it updates the bias so that future evaluations will produce different results. |
#64 is definitely the same issue, thanks Toni.
If what you are saying Peter is correct, if I never called |
I found a (probably old) implementation of PLUMED in ASE https://wiki.fysik.dtu.dk/ase/_modules/ase/calculators/plumed.html |
Thank you for the work you are doing on this interface. <3
|
This seems to be an impedance mismatch. Here is how OpenMM expects integration to work.
PlumedForce is a Force. Everything happens inside But PLUMED does update state. Here is the relevant code from the plugin. openmm-plumed/openmmapi/src/PlumedForceImpl.cpp Lines 143 to 148 in 95bfd46
We call The correct solution, as far as OpenMM is concerned, is for PlumedForceImpl to implement |
Interesting! Thanks so much for looking into it! I am curious though. I imagine the for i in range(10):
simulation.step(1) # Implicit computeForce call. Wrong energy
ene1 = context.getState(getEnergy=True, groups={21}).getPotentialEnergy() # Correct energy
ene2 = context.getState(getEnergy=True, groups={21}).getPotentialEnergy() # Wrong energy |
None of the energies are wrong. They're all the correct energy at various points. The unexpected thing is when PLUMED updates the biases. simulation.step(1) This computes the forces, updates the positions based on them, and increments the step index. ene1 = context.getState(getEnergy=True, groups={21}).getPotentialEnergy() This computes the energy and returns it. In addition, it sees that the step index has changed since the last call, so it calls PLUMED with ene2 = context.getState(getEnergy=True, groups={21}).getPotentialEnergy() This computes the energy again and returns it. The energy has changed, because PLUMED modified the biases after the last calculation. The step index has not changed, so it does not call |
Getting PLUMED energies a second time in the same step gives wrong results.
Only the first energy matches the one reported by PLUMED itself if you dump out the bias of the force directly.
I attach a self-contained example which you can run: plumed_energy_bug.zip
This complicates things a lot if you add an energy reporter to the simulation, which is how it happened in my case, since I was requesting the energy once to get the total potential energy of the system and another time to get the PLUMED energy only and was thus getting wrong energies back.
The text was updated successfully, but these errors were encountered: