choderalab / openmmtools

A batteries-included toolkit for the GPU-accelerated OpenMM molecular simulation engine.
http://openmmtools.readthedocs.io
MIT License
244 stars 76 forks source link

Minimization in ReplicaExchangeSampler #477

Open djhuggins opened 4 years ago

djhuggins commented 4 years ago

Hello,

I have been using the minimize function in ReplicaExchangeSampler to minimize a set of replicas in different alchemical states like this:

_lsd_move = openmmtools.mcmc.LangevinSplittingDynamicsMove(options) repex_simulation = ReplicaExchangeSampler(mcmc_moves=lsd_move) repexsimulation.minimize()

I am finding a lot of the replicas NaN when the initial structure contains a clash. I tried changing the minimize options but it always NaNs. I then tried the following which fixes the problem.

_for k in range(nstates): sampler_state = sampler_states[k] thermodynamic_state = thermodynamic_states[k] integrator=LangevinIntegrator() context = thermodynamic_state.create_context(integrator) sampler_state.apply_to_context(context) mm.LocalEnergyMinimizer.minimize(context) sampler_state.update_fromcontext(context)

As far as I can see ReplicaExchangeSampler uses the FIREMinimizationIntegrator. Could the minimize function be set to use LocalEnergyMinimizer as an option? It seems more effective in this case.

Cheers,

Dave

jchodera commented 4 years ago

@hannahbrucemacdonald @dominicrufa @jaimergp : Didn't you find a way to change this default behavior? I was under the impression that was backported to openmmtools.

hannahbrucemacdonald commented 4 years ago

Hi,

The Fire minimizer has been problematic, I wasn't aware that it was still the default and I can change it back to LocalEnergyMinimizer (Linking to issue #394 ) . Thanks for spotting this Dave - I will change it now

hannahbrucemacdonald commented 4 years ago

Sorry I spoke too soon -- it looks like if the Fire integrator nans, then it should fall back to openmm's LocalEnergyMinimizer anyway. What version of openmmtools are you using?

djhuggins commented 4 years ago

Hi Hannah,

I should have been clearer in my initial message. The (FIRE) minimizer completes without NANs. Its the equilibration that then NANs immediately. Looking at the initial and minimized energies for FIRE vs LocalEnergyMinimizer I can see that LocalEnergyMinimizer reduces the energy a LOT more.

Dave