|It would be useful to be able to change the Integrator associated with an OpenMM Context object. |
There are a number of use cases where one would like to do some simulation with integrator A (say, 500 steps of Langevin dynamics) followed by use of another integrator B (say, a few steps of Monte Carlo via CustomIntegrator), and then back to integrator A again (or some other integrator C). Doing this currently requires constantly creating/destroying Context objects---which incurs significant overhead---due to the limitation of having only one integrator associated with the Context at once.
Rather than allowing multiple integrators to be associated with a Context (which would also ameliorate this issue), allowing the current integrator to be swapped might be simpler.
The Context API could be extended with a function like
I don't know how difficult this would be under the hood, but it would have significant speed advantages for us, since we're in exactly the situation described above.