REWEIGHT_TEMP_PRESS
This is part of the bias module

Calculate weights for ensemble averages at temperatures and/or pressures different than those used in your original simulation.

We can use our knowledge of the probability distribution in the canonical (N \(\mathcal{V}\)T) or the isothermal-isobaric ensemble (NPT) to reweight the data contained in trajectories and obtain ensemble averages at different temperatures and/or pressures.

Consider the ensemble average of an observable \(O(\mathbf{R},\mathcal{V})\) that depends on the atomic coordinates \(\mathbf{R}\) and the volume \(\mathcal{V}\). This observable is in practice any collective variable (CV) calculated by Plumed. The ensemble average of the observable in an ensemble \( \xi' \) can be calculated from a simulation performed in an ensemble \( \xi \) using:

\[ \langle O(\mathbf{R},\mathcal{V}) \rangle_{\xi'} = \frac{\langle O(\mathbf{R},\mathcal{V}) w(\mathbf{R},\mathcal{V}) \rangle_{\xi}} {\langle w(\mathbf{R},\mathcal{V}) \rangle_{\xi}} \]

where \(\langle \cdot \rangle_{\xi}\) and \(\langle \cdot \rangle_{\xi'}\) are mean values in the simulated and targeted ensemble, respectively, \( E(\mathbf{R}) \) is the potential energy of the system, and \( w (\mathbf{R},\mathcal{V}) \) are the appropriate weights to take from \( \xi \) to \( \xi' \). This action calculates the weights \( w (\mathbf{R},\mathcal{V}) \) and handles 4 different cases:

  1. Change of temperature from T to T' at constant volume. That is to say, from a simulation performed in the N \(\mathcal{V}\)T (canonical) ensemble, obtain an ensemble average in the N \(\mathcal{V}\)T' ensemble. The weights in this case are \( w(\mathbf{R},\mathcal{V}) = e^{(\beta-\beta')E(\mathbf{R})} \) with \( \beta \) and \( \beta' \) the inverse temperatures.
  2. Change of temperature from T to T' at constant pressure. That is to say, from a simulation performed in the NPT (isothermal-isobaric) ensemble, obtain an ensemble average in the NPT' ensemble. The weights in this case are \( w(\mathbf{R},\mathcal{V}) = e^{(\beta-\beta')(E(\mathbf{R}) + P\mathcal{V}) } \).
  3. Change of pressure from P to P' at constant temperature. That is to say, from a simulation performed in the NPT (isothermal-isobaric) ensemble, obtain an ensemble average in the NP'T ensemble. The weights in this case are \( w(\mathbf{R},\mathcal{V}) = e^{\beta (P - P') \mathcal{V}} \).
  4. Change of temperature and pressure from T,P to T',P'. That is to say, from a simulation performed in the NPT (isothermal-isobaric) ensemble, obtain an ensemble average in the NP'T' ensemble. The weights in this case are \( w(\mathbf{R},\mathcal{V}) = e^{(\beta-\beta')E(\mathbf{R}) + (\beta P - \beta' P') \mathcal{V}} \).

These weights can be used in any action that computes ensemble averages. For example this action can be used in tandem with HISTOGRAM or AVERAGE.

The above equation is often impractical since the overlap between the distributions of energy and volume at different temperatures and pressures is only significant for neighboring temperatures and pressures. For this reason an unbiased simulation is of little use to reweight at different temperatures and/or pressures. A successful approach has been altering the probability of observing a configuration in order to increase this overlap [120]. This is done through a bias potential \( V(\mathbf{s}) \) where \( \mathbf{s} \) is a set of CVs, that often is the energy (and possibly the volume). In order to calculate ensemble averages, also the effect of this bias must be taken into account. The ensemble average of the observable in the ensemble \( \xi' \) can be calculated from a biased simulation performed in the ensemble \(\xi\) with bias \( V(\mathbf{s}) \) using:

\[ \langle O(\mathbf{R},\mathcal{V}) \rangle_{\xi'} = \frac{\langle O(\mathbf{R},\mathcal{V}) w (\mathbf{R},\mathcal{V}) e^{\beta V(\mathbf{s})} \rangle_{\xi,V}} {\langle w (\mathbf{R},\mathcal{V}) e^{\beta V(\mathbf{s})} \rangle_{\xi,V}} \]

where \(\langle \cdot \rangle_{\xi,V}\) is a mean value in the biased ensemble with static bias \( V(\mathbf{s}) \). Therefore in order to reweight the trajectory at different temperatures and/or pressures one must use the weights calculated by this action \( w (\mathbf{R},\mathcal{V}) \) together with the weights of REWEIGHT_BIAS (see the examples below).

The bias potential \( V(\mathbf{s}) \) can be constructed with METAD using ENERGY as a CV [79]. More specialized tools are available, for instance using bespoke target distributions such as TD_MULTICANONICAL and TD_MULTITHERMAL_MULTIBARIC [90] [91] within Variationally Enhanced Sampling (VES code). In the latter algorithms the interval of temperatures and pressures in which the trajectory can be reweighted is chosen explicitly.

Examples

We consider the 4 cases described above.

The following input can be used to postprocess a molecular dynamics trajectory of a system of 1000 particles run at 500 K and constant volume using a static bias potential.

Click on the labels of the actions for more information on what each action computes
tested on v2.7
energy: READ 
FILE
compulsory keyword the name of the file from which to read these quantities
=COLVAR
VALUES
compulsory keyword the values to read from the file
=energy
IGNORE_TIME
( default=off ) ignore the time in the colvar file.
distance: READ
FILE
compulsory keyword the name of the file from which to read these quantities
=COLVAR
VALUES
compulsory keyword the values to read from the file
=distance
IGNORE_TIME
( default=off ) ignore the time in the colvar file.
mybias: READ
FILE
compulsory keyword the name of the file from which to read these quantities
=COLVAR
VALUES
compulsory keyword the values to read from the file
=mybias.bias
IGNORE_TIME
( default=off ) ignore the time in the colvar file.
# Shift energy (to avoid numerical issues) renergy: COMBINE
ARG
the input for this action is the scalar output from one or more other actions.
=energy
PARAMETERS
compulsory keyword ( default=0.0 ) the parameters of the arguments in your function
=-13250
PERIODIC
compulsory keyword if the output of your function is periodic then you should specify the periodicity of the function.
=NO # Weights bias_weights: REWEIGHT_BIAS
TEMP
the system temperature.
=500
ARG
compulsory keyword ( default=*.bias ) the biases that must be taken into account when reweighting
=mybias.bias temp_press_weights: REWEIGHT_TEMP_PRESS
TEMP
the system temperature.
=500
REWEIGHT_TEMP
Reweighting temperature
=300
ENERGY
Energy
=renergy # Ensemble average of the distance at 300 K avg_dist: AVERAGE
ARG
the input for this action is the scalar output from one or more other actions.
=distance
LOGWEIGHTS
list of actions that calculates log weights that should be used to weight configurations when calculating averages
=bias_weights,temp_press_weights PRINT
ARG
the input for this action is the scalar output from one or more other actions.
=avg_dist
FILE
the name of the file on which to output these quantities
=COLVAR_REWEIGHT
STRIDE
compulsory keyword ( default=1 ) the frequency with which the quantities of interest should be output
=1

Clearly, in performing the analysis above we would read from the potential energy, a distance, and the value of the bias potential from a COLVAR file like the one shown below. We would then be able to calculate the ensemble average of the distance at 300 K.

#! FIELDS time energy volume mybias.bias distance
 10000.000000 -13133.769283 7.488921 63.740530 0.10293
 10001.000000 -13200.239722 7.116548 36.691988 0.16253
 10002.000000 -13165.108850 7.202273 44.408815 0.17625

The next three inputs can be used to postprocess a molecular dynamics trajectory of a system of 1000 particles run at 500 K and 1 bar using a static bias potential.

We read from a file COLVAR the potential energy, the volume, and the value of the bias potential and calculate the ensemble average of the (particle) density at 300 K and 1 bar (the simulation temperature was 500 K).

Click on the labels of the actions for more information on what each action computes
tested on v2.7
energy: READ 
FILE
compulsory keyword the name of the file from which to read these quantities
=COLVAR
VALUES
compulsory keyword the values to read from the file
=energy
IGNORE_TIME
( default=off ) ignore the time in the colvar file.
volume: READ
FILE
compulsory keyword the name of the file from which to read these quantities
=COLVAR
VALUES
compulsory keyword the values to read from the file
=volume
IGNORE_TIME
( default=off ) ignore the time in the colvar file.
mybias: READ
FILE
compulsory keyword the name of the file from which to read these quantities
=COLVAR
VALUES
compulsory keyword the values to read from the file
=mybias.bias
IGNORE_TIME
( default=off ) ignore the time in the colvar file.
# Shift energy and volume (to avoid numerical issues) rvol: COMBINE
ARG
the input for this action is the scalar output from one or more other actions.
=volume
PARAMETERS
compulsory keyword ( default=0.0 ) the parameters of the arguments in your function
=7.8
PERIODIC
compulsory keyword if the output of your function is periodic then you should specify the periodicity of the function.
=NO renergy: COMBINE
ARG
the input for this action is the scalar output from one or more other actions.
=energy
PARAMETERS
compulsory keyword ( default=0.0 ) the parameters of the arguments in your function
=-13250
PERIODIC
compulsory keyword if the output of your function is periodic then you should specify the periodicity of the function.
=NO # Weights bias_weights: REWEIGHT_BIAS
TEMP
the system temperature.
=500
ARG
compulsory keyword ( default=*.bias ) the biases that must be taken into account when reweighting
=mybias.bias temp_press_weights: REWEIGHT_TEMP_PRESS
TEMP
the system temperature.
=500
REWEIGHT_TEMP
Reweighting temperature
=300
PRESSURE
The system pressure
=0.06022140857
ENERGY
Energy
=renergy
VOLUME
Volume
=rvol # Ensemble average of the volume at 300 K avg_vol: AVERAGE
ARG
the input for this action is the scalar output from one or more other actions.
=volume
LOGWEIGHTS
list of actions that calculates log weights that should be used to weight configurations when calculating averages
=bias_weights,temp_press_weights # Ensemble average of the density at 300 K avg_density: CUSTOM
ARG
the input for this action is the scalar output from one or more other actions.
=avg_vol
FUNC
compulsory keyword the function you wish to evaluate
=1000/x
PERIODIC
compulsory keyword if the output of your function is periodic then you should specify the periodicity of the function.
=NO PRINT
ARG
the input for this action is the scalar output from one or more other actions.
=avg_density
FILE
the name of the file on which to output these quantities
=COLVAR_REWEIGHT
STRIDE
compulsory keyword ( default=1 ) the frequency with which the quantities of interest should be output
=1

In the next example we calculate the ensemble average of the (particle) density at 500 K and 300 MPa (the simulation pressure was 1 bar).

Click on the labels of the actions for more information on what each action computes
tested on v2.7
volume: READ 
FILE
compulsory keyword the name of the file from which to read these quantities
=COLVAR
VALUES
compulsory keyword the values to read from the file
=volume
IGNORE_TIME
( default=off ) ignore the time in the colvar file.
mybias: READ
FILE
compulsory keyword the name of the file from which to read these quantities
=COLVAR
VALUES
compulsory keyword the values to read from the file
=mybias.bias
IGNORE_TIME
( default=off ) ignore the time in the colvar file.
# Shift volume (to avoid numerical issues) rvol: COMBINE
ARG
the input for this action is the scalar output from one or more other actions.
=volume
PARAMETERS
compulsory keyword ( default=0.0 ) the parameters of the arguments in your function
=7.8
PERIODIC
compulsory keyword if the output of your function is periodic then you should specify the periodicity of the function.
=NO # Weights bias_weights: REWEIGHT_BIAS
TEMP
the system temperature.
=500
ARG
compulsory keyword ( default=*.bias ) the biases that must be taken into account when reweighting
=mybias.bias temp_press_weights: REWEIGHT_TEMP_PRESS
TEMP
the system temperature.
=500
PRESSURE
The system pressure
=0.06022140857
REWEIGHT_PRESSURE
Reweighting pressure
=180.66422571
VOLUME
Volume
=volume # Ensemble average of the volume at 300 K and 300 MPa avg_vol: AVERAGE
ARG
the input for this action is the scalar output from one or more other actions.
=volume
LOGWEIGHTS
list of actions that calculates log weights that should be used to weight configurations when calculating averages
=bias_weights,temp_press_weights # Ensemble average of the density at 300 K and 300 MPa avg_density: CUSTOM
ARG
the input for this action is the scalar output from one or more other actions.
=avg_vol
FUNC
compulsory keyword the function you wish to evaluate
=1000/x
PERIODIC
compulsory keyword if the output of your function is periodic then you should specify the periodicity of the function.
=NO PRINT
ARG
the input for this action is the scalar output from one or more other actions.
=avg_density
FILE
the name of the file on which to output these quantities
=COLVAR_REWEIGHT
STRIDE
compulsory keyword ( default=1 ) the frequency with which the quantities of interest should be output
=1

In this final example we calculate the ensemble average of the (particle) density at 300 K and 300 MPa (the simulation temperature and pressure were 500 K and 1 bar).

Click on the labels of the actions for more information on what each action computes
tested on v2.7
energy: READ 
FILE
compulsory keyword the name of the file from which to read these quantities
=COLVAR
VALUES
compulsory keyword the values to read from the file
=energy
IGNORE_TIME
( default=off ) ignore the time in the colvar file.
volume: READ
FILE
compulsory keyword the name of the file from which to read these quantities
=COLVAR
VALUES
compulsory keyword the values to read from the file
=volume
IGNORE_TIME
( default=off ) ignore the time in the colvar file.
mybias: READ
FILE
compulsory keyword the name of the file from which to read these quantities
=COLVAR
VALUES
compulsory keyword the values to read from the file
=mybias.bias
IGNORE_TIME
( default=off ) ignore the time in the colvar file.
# Shift energy and volume (to avoid numerical issues) rvol: COMBINE
ARG
the input for this action is the scalar output from one or more other actions.
=volume
PARAMETERS
compulsory keyword ( default=0.0 ) the parameters of the arguments in your function
=7.8
PERIODIC
compulsory keyword if the output of your function is periodic then you should specify the periodicity of the function.
=NO renergy: COMBINE
ARG
the input for this action is the scalar output from one or more other actions.
=energy
PARAMETERS
compulsory keyword ( default=0.0 ) the parameters of the arguments in your function
=-13250
PERIODIC
compulsory keyword if the output of your function is periodic then you should specify the periodicity of the function.
=NO # Weights bias_weights: REWEIGHT_BIAS
TEMP
the system temperature.
=500
ARG
compulsory keyword ( default=*.bias ) the biases that must be taken into account when reweighting
=mybias.bias temp_press_weights: REWEIGHT_TEMP_PRESS
TEMP
the system temperature.
=500
REWEIGHT_TEMP
Reweighting temperature
=300
PRESSURE
The system pressure
=0.06022140857
REWEIGHT_PRESSURE
Reweighting pressure
=180.66422571
ENERGY
Energy
=renergy
VOLUME
Volume
=rvol # Ensemble average of the volume at 300 K and 300 MPa avg_vol: AVERAGE
ARG
the input for this action is the scalar output from one or more other actions.
=volume
LOGWEIGHTS
list of actions that calculates log weights that should be used to weight configurations when calculating averages
=bias_weights,temp_press_weights # Ensemble average of the density at 300 K and 300 MPa avg_density: CUSTOM
ARG
the input for this action is the scalar output from one or more other actions.
=avg_vol
FUNC
compulsory keyword the function you wish to evaluate
=1000/x
PERIODIC
compulsory keyword if the output of your function is periodic then you should specify the periodicity of the function.
=NO PRINT
ARG
the input for this action is the scalar output from one or more other actions.
=avg_density
FILE
the name of the file on which to output these quantities
=COLVAR_REWEIGHT
STRIDE
compulsory keyword ( default=1 ) the frequency with which the quantities of interest should be output
=1
Glossary of keywords and components
Options
TEMP the system temperature. This is not required if your MD code passes this quantity to PLUMED
ENERGY Energy
VOLUME Volume
REWEIGHT_PRESSURE Reweighting pressure
PRESSURE The system pressure
REWEIGHT_TEMP Reweighting temperature