choderalab / openmmtools

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

Missing feature for Replica Exchange ? #300

Closed OleinikovasV closed 5 years ago

OleinikovasV commented 7 years ago

I cannot seem to find any utilities here that would be supporting OpenMM replica-exchange simulations.

Features include: ...

  • enhanced sampling methods, including replica-exchange (REMD) and self-adjusted mixture sampling (SAMS)

I would like to use replica-exchange metadynamics with OpenMM. This would need a general way of evaluating the states at different hamiltonians (should be supported?) and reading their corresponding bias potential (needs to be added). There is an OpenMM Plumed plugin (https://github.com/peastman/openmm-plumed) that we have successfully tested with metadynamics. I also find replica-exchange routines that seem a bit abandoned (last edit is from 3 years ago: https://github.com/choderalab/repex)? Is it still compatible with the newest versions? Why is it not part of OpenMMTools package? Is there a newer replacement? . In addition, I also find some more recent versions implemented for YANK, but not as a separate utility.

Thanks for your help!

andrrizzi commented 7 years ago

Hi! You're absolutely right. The repex facilities currently in use is the one in YANK. We plan to port it to openmmtools shortly, but for now, you could just use that one. It's based on the openmmtools framework, and it's pretty much independent from the other YANK modules.

kyleabeauchamp commented 7 years ago

If we've already migrated all the code and issues into yank, we could consider deleting the Repex repo from github to reduce future confusion.

kyleabeauchamp commented 7 years ago

Alternatively, if you have worries about losing the git history, you could make the repo private.

jchodera commented 7 years ago

@kyleabeauchamp : Great idea! I've made choderalab/repex private to avoid causing future confusion.

@OleinikovasV : Apologies for the delay! We're hoping to get repex and sams into openmmtools in the next month or so!

OleinikovasV commented 7 years ago

Great! Will be looking forward to it. Thanks for the clarification

jy634 commented 6 years ago

Hi, I was also wondering whethere the YANK's repex feature has been imported to openmoltools yet. Should I just use the YANK for REMD?

jchodera commented 6 years ago

We're in the midst of refactoring all of the multistate samplers in YANK in preparation to moving the to openmmtools:

https://github.com/choderalab/yank/pull/863

However, the storage layer is not as general as we would like. Our current plan is to merge the PR this week, at which point you should be able to use the replica exchange facility in YANK by importing it directly, e.g.:

import math
from simtk import unit
from openmmtools import testsystems, states, mcmc
from yank.samplers import ReplicaExchangeSampler
testsystem = testsystems.AlanineDipeptideImplicit()
system, positions = testsystem.system, testsystem.positions
# Create thermodynamic states for parallel tempering with exponentially-spaced schedule.
n_replicas = 3  # Number of temperature replicas.
T_min = 298.0 * unit.kelvin  # Minimum temperature.
T_max = 600.0 * unit.kelvin  # Maximum temperature.
temperatures = [T_min + (T_max - T_min) * (math.exp(float(i) / float(nreplicas-1)) - 1.0) / (math.e - 1.0)  for i in range(n_replicas)]
thermodynamic_states = [states.ThermodynamicState(system=system, temperature=T) for T in temperatures]
# Initialize simulation object with options. Run with a GHMC integrator.
move = mcmc.GHMCMove(timestep=2.0*unit.femtoseconds, n_steps=50)
simulation = ReplicaExchangeSampler(mcmc_moves=move, number_of_iterations=2)
# Create simulation with its storage file (in a temporary directory) and run.
storage_path = 'repex.nc'
reporter = MultiStateReporter(storage_path, checkpoint_interval=10)
simulation.create(thermodynamic_states=thermodynamic_states,
                   sampler_states=states.SamplerState(positions),
                   storage=reporter)
simulation.run()  # This runs for a maximum of 2 iterations.

Once we have figured out a way to make the storage layer more general and more performant, we will move all of the multistate samplers from yank toopenmmtools. We're currently looking into simple performant key-value database schemes that make it easier to store and analyze Python objects, since the single-file-based storage becomes a bottleneck when scaling this up to many replicas.

andrrizzi commented 5 years ago

repex was imported from YANK in #397 and #398.