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:
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:
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.
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}) } \).
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}} \).
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 [111]. 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 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
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.
The READ action with label energy calculates a single scalar valuedistance: 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.
The READ action with label distance calculates a single scalar valuemybias: 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.
The READ action with label mybias calculates a single scalar value# Shift energy (to avoid numerical issues)renergy: COMBINE
ARG
the input to this function.
=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 The COMBINE action with label renergy calculates a single scalar value# Weightsbias_weights: REWEIGHT_BIAS
TEMP
the system temperature.
=500
ARG
compulsory keyword ( default=*.bias )
the biases that must be taken into account when reweighting
=mybias.biasThe REWEIGHT_BIAS action with label bias_weights calculates a single scalar valuetemp_press_weights: REWEIGHT_TEMP_PRESS
TEMP
the system temperature.
=500
REWEIGHT_TEMP
Reweighting temperature
=300
ENERGY
Energy
=renergyThe REWEIGHT_TEMP_PRESS action with label temp_press_weights calculates a single scalar value# Ensemble average of the distance at 300 Kavg_dist: AVERAGE
ARG
compulsory keyword
the quantity that is being averaged
=distance
LOGWEIGHTS
the logarithm of the quantity to use as the weights when calculating averages
=bias_weights,temp_press_weightsThe AVERAGE action with label avg_dist calculates a single scalar value
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.
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
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.
The READ action with label energy calculates a single scalar valuevolume: 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.
The READ action with label volume calculates a single scalar valuemybias: 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.
The READ action with label mybias calculates a single scalar value# Shift energy and volume (to avoid numerical issues)rvol: COMBINE
ARG
the input to this function.
=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 The COMBINE action with label rvol calculates a single scalar valuerenergy: COMBINE
ARG
the input to this function.
=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 The COMBINE action with label renergy calculates a single scalar value# Weightsbias_weights: REWEIGHT_BIAS
TEMP
the system temperature.
=500
ARG
compulsory keyword ( default=*.bias )
the biases that must be taken into account when reweighting
=mybias.biasThe REWEIGHT_BIAS action with label bias_weights calculates a single scalar valuetemp_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
=rvolThe REWEIGHT_TEMP_PRESS action with label temp_press_weights calculates a single scalar value# Ensemble average of the volume at 300 Kavg_vol: AVERAGE
ARG
compulsory keyword
the quantity that is being averaged
=volume
LOGWEIGHTS
the logarithm of the quantity to use as the weights when calculating averages
=bias_weights,temp_press_weightsThe AVERAGE action with label avg_vol calculates a single scalar value# Ensemble average of the density at 300 Kavg_density: CUSTOM
ARG
the input to this function.
=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 The CUSTOM action with label avg_density calculates a single scalar value
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
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.
The READ action with label volume calculates a single scalar valuemybias: 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.
The READ action with label mybias calculates a single scalar value# Shift volume (to avoid numerical issues)rvol: COMBINE
ARG
the input to this function.
=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 The COMBINE action with label rvol calculates a single scalar value# Weightsbias_weights: REWEIGHT_BIAS
TEMP
the system temperature.
=500
ARG
compulsory keyword ( default=*.bias )
the biases that must be taken into account when reweighting
=mybias.biasThe REWEIGHT_BIAS action with label bias_weights calculates a single scalar valuetemp_press_weights: REWEIGHT_TEMP_PRESS
TEMP
the system temperature.
=500
PRESSURE
The system pressure
=0.06022140857
REWEIGHT_PRESSURE
Reweighting pressure
=180.66422571
VOLUME
Volume
=volumeThe REWEIGHT_TEMP_PRESS action with label temp_press_weights calculates a single scalar value# Ensemble average of the volume at 300 K and 300 MPaavg_vol: AVERAGE
ARG
compulsory keyword
the quantity that is being averaged
=volume
LOGWEIGHTS
the logarithm of the quantity to use as the weights when calculating averages
=bias_weights,temp_press_weightsThe AVERAGE action with label avg_vol calculates a single scalar value# Ensemble average of the density at 300 K and 300 MPaavg_density: CUSTOM
ARG
the input to this function.
=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 The CUSTOM action with label avg_density calculates a single scalar value
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
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.
The READ action with label energy calculates a single scalar valuevolume: 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.
The READ action with label volume calculates a single scalar valuemybias: 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.
The READ action with label mybias calculates a single scalar value# Shift energy and volume (to avoid numerical issues)rvol: COMBINE
ARG
the input to this function.
=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 The COMBINE action with label rvol calculates a single scalar valuerenergy: COMBINE
ARG
the input to this function.
=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 The COMBINE action with label renergy calculates a single scalar value# Weightsbias_weights: REWEIGHT_BIAS
TEMP
the system temperature.
=500
ARG
compulsory keyword ( default=*.bias )
the biases that must be taken into account when reweighting
=mybias.biasThe REWEIGHT_BIAS action with label bias_weights calculates a single scalar valuetemp_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
=rvolThe REWEIGHT_TEMP_PRESS action with label temp_press_weights calculates a single scalar value# Ensemble average of the volume at 300 K and 300 MPaavg_vol: AVERAGE
ARG
compulsory keyword
the quantity that is being averaged
=volume
LOGWEIGHTS
the logarithm of the quantity to use as the weights when calculating averages
=bias_weights,temp_press_weightsThe AVERAGE action with label avg_vol calculates a single scalar value# Ensemble average of the density at 300 K and 300 MPaavg_density: CUSTOM
ARG
the input to this function.
=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 The CUSTOM action with label avg_density calculates a single scalar value
Glossary of keywords and components
Options
TEMP
the system temperature. This is not required if your MD code passes this quantity to PLUMED