Class to compute replica exchange swaps between neighboring replicas.

class meld.remd.ladder.NearestNeighborLadder(n_trials: int)[source]

Class to compute replica exchange swaps between neighboring replicas.


n_trials – total number of replica exchange swaps to attempt

compute_exchanges(energies, adaptor)[source]

Compute the exchanges given an energy matrix.

  • energies – numpy array of energies (see below for details)

  • adaptor – replica exchange adaptor that is updated every attempted swap


a permutation vector (see below for details)

The energy matrix should be an n_rep x n_rep numpy array. All energies are in dimensionless units (unit of kT). Each column represents a particular structure, while each row represents a particular combination of temperature and Hamiltonian. So, energies[i,j] is the energy of structure j with temperature and hamiltonian i. The diagonal energies[i,i] are the energies that were actually simulated.

This method will attempt self.n_trials swaps between randomly chosen pairs of adjacent replicas. It will return a permutation vector that describes which index each structure should be at after swapping. So, if the output was [2, 0, 1], it would mean that replica 0 should now be at index 2, replica 1 should now be at index 0, and replica 2 should now be at index 1. Output of [0, 1, 2] would mean no change.

The adaptor object is called once for each attempted exchange with the indices of the attempted swap and the success or failure of the swap.