Generic Weighted Ensemble Dynamics Driver

The Weighted Ensemble Dynamics algorithm (Huber and Kim, Biophys. J, 1996) is useful for finding rates of rare events. It maintains several copies of the system of interest, and divides and merges copies to enhance sampling over free energy barriers along the reaction coordinate. It makes use of divisions of configuration space usually called bins, and approximately enforces the condition of having equal number of system copies in each bin.

This code can run several threads on any machine that has pthreads, which is standard on most architectures. Upon the first call to step_objects_forward, the threads are created and used to independently call step_forward on the objects. The threads are kept waiting between calls to step_objects_forward, and are sychronized so that the main thread does not return until all the threads are finished.

In addition to the simulation, this code can also generate sequential bins along a user-defined reaction coordinate. The user starts the system copies at one end of the coordinate, and the bins are generated by stepping the copies forward and forcing the ensemble along the coordinate.

The algorithm is wrapped in a generic class Sampler< Interface>, which sits in the namespace Weighted_Ensemble_Dynamics::Multithreaded. (I still have a single-threaded version which does not use pthreads at all; the multithreaded version sits on top of it.) The header file we_multithread.hh is included (which then pulls in other header files in the same directory), and the code must also be linked to the compiled result of barrier.cc. Both of these files are in the src directory. The Interface class, provided by the user, must have the following members:

The Sampler class itself has the following member functions:

Normally, after initializing everything, most of the work will take place in a loop such as this:

for( int i = 0; i < n_moves; i++){
  sampler.step_objects_forward();
  sampler.renormalize_objects();
}