Skip to content

Action: REPLEX_BIASVALUE

Module replex_biasvalue
Description Usage
In a multi-simulation context, takes the values of variables and uses them as used in 0 tutorialsused in 0 eggs

Details and examples

In a multi-simulation context, takes the values of variables and uses them as exchangeable biases between replicas.

This is analogous to multiple BIASVALUE where biases are periodically exchanged using the Metropolis algorithm. The design is consistent with replica exchange in GROMACS, except that the replicas exchange biases instead of system coordinates. As a result, output trajectories are time-continuous and must be sorted ("multiplexed") to recover the correct biased ensembles (as opposed to the usual "demultiplexing", or "demuxing", which recovers continuous trajectories from discontinuous ones).

The exchange scheme matches the GROMACS one, where exchanges between neighboring biases are attempted alternating odd pairs (, , …) and even pairs (, …). Exchanges happen at every step that is a multiple of PACE, except at step 0. Multiple attempts can be made on the same exchange step (NEX keyword), alternating odd and even pairs, to approximate independence sampling in state space. This incurs little additional cost since replicas already compute all biases on exchange steps. Using NEX=2 ensures all neighboring pairs are attempted once per exchange step.

By default the number of variables provided with ARG should match the number of replicas in the multi-simulation, and will correspond to a different bias each. Alternatively, the bias ladder can be constructed as any linear combination of the input variables. In that case, the COEFFICIENTS keyword should specify the appropriate matrix (see examples below) and biases will be computed as

One can also perform multidimensional replica exchange on a grid. In this case one must provide a SHAPE keyword specifying the size of each of the dimensions. The product of SHAPE should match the number of replicas . As for the 1D case, COEFFICIENTS for each bias should be given as an matrix, with one row per bias. Biases are numbered with C-style, row-major ordering on the grid (last dimension is the fastest-varying index), see examples below. For each exchange attempt (odd or even), all dimensions are attempted in order starting from the last one.

Warning

All replicas are assumed to share the same PLUMED biases, forcefield topologies and temperatures. REPLEX_BIASVALUE is unaware of differences outside its own biases and thus cannot include them in the Metropolis acceptance. Keywords ARG, COEFFICIENTS, SHAPE, PACE, NEX, SEED, and TEMP must be identical in all replicas and will be checked. We recommend using a single common PLUMED input file and avoiding the @replicas: syntax.

Note

Only one REPLEX_BIASVALUE action is allowed in each PLUMED input. Combine all the bias terms in its ARG list and COEFFICIENTS matrix.

Note

This action cannot be combined with replica exchange provided by the MD code. For example, when running with GROMACS, use

mdrun -multidir … -plumed …
without -replex.

Examples

One use case is the interpolation between two biases:

Click on the labels of the actions for more information on what each action computes
tested on2.11
#SETTINGS NREPLICAS=4
# --- Click here to reveal hidden parts of input file ---- 
# 4 replicas switching from cv1 to cv2
bias: REPLEX_BIASVALUEIn a multi-simulation context, takes the values of variables and uses them as This action has hidden defaults. More details ...
  ARGthe labels of the scalars combined to define the biases=cv1,cv2
  COEFFICIENTS the coefficients of the arguments in each bias, one row per bias or one value per bias (see examples)={
    {1.0 0.0}
    {0.7 0.3}
    {0.1 0.9}
    {0.0 1.0}
  }
  PACEthe frequency of the exchange attempts=100
  NEX the number of sweeps over the pairs of neighbors on each exchange step, alternating odd and even pairs=10
  SEED the seed of the random numbers used to accept or reject the exchanges, the same on all replicas=42
...

If , a vector can be given to imply different scalings of the same bias function:

Click on the labels of the actions for more information on what each action computes
tested on2.11
#SETTINGS NREPLICAS=6
# --- Click here to reveal hidden parts of input file ---- 
bias: REPLEX_BIASVALUEIn a multi-simulation context, takes the values of variables and uses them as This action has hidden defaults. More details ARGthe labels of the scalars combined to define the biases=cv COEFFICIENTS the coefficients of the arguments in each bias, one row per bias or one value per bias (see examples)=0.0,0.2,0.4,0.6,0.8,1.0 PACEthe frequency of the exchange attempts=100
# equivalent to COEFFICIENTS={{0.0} {0.2} {0.4} {0.6} {0.8} {1.0}}

If both ARG and COEFFICIENTS are vectors of elements, a diagonal matrix is implied:

Click on the labels of the actions for more information on what each action computes
tested on2.11
#SETTINGS NREPLICAS=5
# --- Click here to reveal hidden parts of input file ---- 
bias: REPLEX_BIASVALUEIn a multi-simulation context, takes the values of variables and uses them as This action has hidden defaults. More details ...
  ARGthe labels of the scalars combined to define the biases=cv1,cv2,cv3,cv4,cv5
  COEFFICIENTS the coefficients of the arguments in each bias, one row per bias or one value per bias (see examples)=0.8,1.2,0.5,0.9,1.0
  # equivalent to COEFFICIENTS={
  #   {0.8    0    0    0    0}
  #   {  0  1.2    0    0    0}
  #   {  0    0  0.5    0    0}
  #   {  0    0    0  0.9    0}
  #   {  0    0    0    0  1.0}
  # }
  PACEthe frequency of the exchange attempts=100
  NEX the number of sweeps over the pairs of neighbors on each exchange step, alternating odd and even pairs=100
  SEED the seed of the random numbers used to accept or reject the exchanges, the same on all replicas=1312
...

Two-dimensional ladder—the coefficients are given for each bias in row-major ordering:

Click on the labels of the actions for more information on what each action computes
tested on2.11
#SETTINGS NREPLICAS=6
# --- Click here to reveal hidden parts of input file ---- 
bias: REPLEX_BIASVALUEIn a multi-simulation context, takes the values of variables and uses them as This action has hidden defaults. More details ...
  ARGthe labels of the scalars combined to define the biases=cv1,cv2
  SHAPEthe shape of the grid of the biases, for multidimensional replica exchange=2,3
  COEFFICIENTS the coefficients of the arguments in each bias, one row per bias or one value per bias (see examples)={
    {0   0}
    {0 0.5}
    {0   1}
    {1   0}
    {1 0.5}
    {1   1}
  }
  # row-major ordering:
  # bias[0,0]
  # bias[0,1]
  # bias[0,2]
  # bias[1,0]
  # bias[1,1]
  # bias[1,2]
  PACEthe frequency of the exchange attempts=100
...

Output files

The first replica (index 0) keeps track of the position of the biases in the output FILE (bias_index.xvg by default). Column replica-i is the index of the bias on replica .

The bias indices can be used to "multiplex" the continuous trajectories (with variable biases) into discontinuous trajectories (with fixed biases). Please note that exchanges are attempted after calculating forces: this means that the PLUMED outputs at time correspond to bias indices strictly before in the bias_index.xvg file. This is consistent with the output of the demux.pl script provided with GROMACS and can be seamlessly used for multiplexing:

gmx trjcat -f rep?/traj.xtc -demux rep0/bias_index.xvg -o rep?/muxed.xtc

Warning

For long simulations the time reported in bias_index.xvg might be inexact due to floating point precision and may be inconsistent with GROMACS trajectories.

For convenience, it is also possible to output the replica indices in bias space by setting REPINDEX_FILE (note that going from replica indices to bias indices and vice versa corresponds to finding the inverse permutation, that is the permutation that sorts the indices, e.g. np.argsort).

# This should be the inverse operation to the previous one
gmx trjcat -f rep?/muxed.xtc -demux rep0/replica_index.xvg -o rep?/traj.xtc

Log output

Each exchange step logs the new indices. At the end of the run, per-pair statistics are given (accepted/attempted, acceptance ratio, average acceptance probability), counted over this run only. The VERBOSE flag can be used to output statistics after each exchange step (average over NEX attempts).

Restart

When restarting a simulation (as indicated internally by the MD engine or enforced with RESTART=YES) the content of FILE is automatically read to recover the state at a time consistent with the checkpoint. The random numbers used to accept or reject the exchanges depend only on SEED and on the step, so the restarted simulation makes the same decisions as an uninterrupted one would (assuming deterministic and bit-identical energies). This also holds when restarting from a PLUMED CHECKPOINT, which needs nothing specific to this action.

If needed one can run a "fresh" simulation starting from a state provided by BIASINDEX_RFILE, in which case the time consistency check is ignored and the very last line is used.

Input

The arguments that serve as the input for this action are specified using one or more of the keywords in the following table.

Keyword Type Description
ARG scalar the labels of the scalars combined to define the biases

Output components

This action calculates the values in the following table. These values can be referenced elsewhere in the input by using this Action's label followed by a dot and the name of the value required from the list below.

Name Type Description
bias scalar the instantaneous value of the bias potential
_bias scalar the contribution of each argument to the bias, scaled by the coefficient, named after the argument
index scalar the index of the bias currently applied on this replica

Full list of keywords

The following table describes the keywords and options that can be used with this action

Keyword Type Default Description
ARG input none the labels of the scalars combined to define the biases
COEFFICIENTS compulsory 1.0 the coefficients of the arguments in each bias, one row per bias or one value per bias (see examples)
PACE compulsory none the frequency of the exchange attempts
NEX compulsory 1 the number of sweeps over the pairs of neighbors on each exchange step, alternating odd and even pairs
SEED compulsory 0 the seed of the random numbers used to accept or reject the exchanges, the same on all replicas
FILE compulsory bias_index.xvg the output file of the bias indices
NUMERICAL_DERIVATIVESThis keyword do not have examples optional false calculate the derivatives for these quantities numerically
SHAPE optional not used the shape of the grid of the biases, for multidimensional replica exchange
TEMPThis keyword do not have examples optional not used the temperature, if not given by the MD code
BIASINDEX_RFILEThis keyword do not have examples optional not used a file of bias indices to start from, if different from FILE: its last line is used, without checking the time
REPINDEX_FILEThis keyword do not have examples optional not used an output file of the replica indices
VERBOSEThis keyword do not have examples optional false write in the log the statistics of every exchange step
RESTARTThis keyword do not have examples optional not used allows per-action setting of restart (YES/NO/AUTO)
NO_TRIMThis keyword do not have examples optional false at a restart from a step given by the MD engine, append to the files of this action as they are, without removing the lines written at or after that step (see RESTART)

References

More information about how this action can be used is available in the following articles: