meld.remd.ladder.NearestNeighborLadder

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

Bases: object

Class to compute replica exchange swaps between neighboring replicas.

__init__(n_trials)[source]

Initialize a NearestNeighborLadder

Parameters

n_trials (int) – number of swaps to attempt

Methods

__init__(n_trials)

Initialize a NearestNeighborLadder

compute_exchanges(energies, adaptor)

Compute the exchanges from a given energy matrix.

compute_exchanges(energies, adaptor)[source]

Compute the exchanges from a given energy matrix.

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

  • adaptor (Union[NullAdaptor, EqualAcceptanceAdaptor]) – replica exchange adaptor that is updated every attempted swap

Return type

List[int]

Returns

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.