Does the neighbor list update when setPositions is called using C++ API?
Posted: Thu Nov 14, 2024 7:00 pm
I need to use OpenMM to calculate forces and energies but not to propagate as this is done by an external routine. (I understand this does not make use of many of the advantages of OpenMM, but I require this for now.)
Specifically, after the external code has updated the positions I want to know whether the following is sufficient to correctly calculate forces at the new positions:
// setting positions in OpenMM
context.setPositions(posInNm);
// followed by getting forces at the updated positions
OpenMM::State state = context.getState(OpenMM::State::Forces);
const std::vector<OpenMM::Vec3>& forceMM = state.getForces();
I want to be sure that by doing this OpenMM will still correctly manage the neighbor list etc. Searching the documentation I could not determine:
1) Whether calling setPositions will automatically cause the neighbor list to update (or if one needs to do something else to force this such as manually advancing the time step)?
and
2) If this does force neighbor list update if it is completely reconstructed or if it is updated as normal? If the latter case then, for platforms such as OpenCL that may internally swap the positions and velocities of identical solvent molecules, does this swap also affect the forces. i.e. would one also need to call getPositions and monitor if molecules had been swapped by OpenMM?
Specifically, after the external code has updated the positions I want to know whether the following is sufficient to correctly calculate forces at the new positions:
// setting positions in OpenMM
context.setPositions(posInNm);
// followed by getting forces at the updated positions
OpenMM::State state = context.getState(OpenMM::State::Forces);
const std::vector<OpenMM::Vec3>& forceMM = state.getForces();
I want to be sure that by doing this OpenMM will still correctly manage the neighbor list etc. Searching the documentation I could not determine:
1) Whether calling setPositions will automatically cause the neighbor list to update (or if one needs to do something else to force this such as manually advancing the time step)?
and
2) If this does force neighbor list update if it is completely reconstructed or if it is updated as normal? If the latter case then, for platforms such as OpenCL that may internally swap the positions and velocities of identical solvent molecules, does this swap also affect the forces. i.e. would one also need to call getPositions and monitor if molecules had been swapped by OpenMM?