openmm / openmm-plumed

OpenMM plugin to interface with PLUMED
55 stars 23 forks source link

PlumedForce and periodic boundary conditions #83

Open varun-go opened 2 months ago

varun-go commented 2 months ago

I would like to clarify if PlumedForce uses periodic boundary conditions by default.

I noticed that when I created a breakpoint and inspected the PlumedForce instance the only available method is usesPeriodicBoundaryConditions. The returned value from this method is False. Additionally, since the setUsesPeriodicBoundaryConditions method is not available, one cannot change this aspect of the force.

Does this mean that the Plumed script dictates the use of periodic boundary conditions? For example, if one uses the RESTRAINT keyword in Plumed, the default option is that PBCs are used; so does PlumedForce use PBCs even though the usesPeriodicBoundaryConditions returns False?

peastman commented 2 months ago

It looks like the handling is a bit inconsistent. PlumedForce always reports that it does not use periodic boundary conditions:

https://github.com/openmm/openmm-plumed/blob/a3e935bc88ed8771f17f6f4d60588b81789b9c89/openmmapi/include/PlumedForce.h#L78-L80

But when it comes to actually computing the force, it checks system.usesPeriodicBoundaryConditions(), that is, whether any other force in the system applies periodic boundary conditions. If so, it passes the box vectors to Plumed:

https://github.com/openmm/openmm-plumed/blob/a3e935bc88ed8771f17f6f4d60588b81789b9c89/openmmapi/src/PlumedForceImpl.cpp#L132-L136

That means Plumed could potentially make use of periodic boundary conditions, depending on your script.

Ideally it would check whether your script involves periodic boundary conditions, but I'm not sure if there's a way to do that.

varun-go commented 2 months ago

I see, thank you. I have other forces in my OpenMM script that use periodic boundary conditions, so the PlumedForce should get the box vectors from those forces.