Skip to content

Energy bug in PlumedForce #91

@stefdoerr

Description

@stefdoerr

Getting PLUMED energies a second time in the same step gives wrong results.

context = simulation.context
for i in range(10):
    simulation.step(100)
    ene1 = context.getState(getEnergy=True, groups={21}).getPotentialEnergy()
    ene2 = context.getState(getEnergy=True, groups={21}).getPotentialEnergy()
    assert ene1 == ene2, "Energy has changed!!!"

0.0 kJ/mol
10.0 kJ/mol
Traceback (most recent call last):
  File "/home/sdoerr/Work/pyacemd/debug_plumed/test.py", line 63, in <module>
    assert ene1 == ene2, "Energy has changed!!!"
AssertionError: Energy has changed!!!

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions