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:
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 [132]. 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 [87]. More specialized tools are available, for instance using bespoke target distributions such as TD_MULTICANONICAL and TD_MULTITHERMAL_MULTIBARIC [101] [102] 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.
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.
energy: READFILE=COLVARcompulsory keyword the name of the file from which to read these quantitiesVALUES=energycompulsory keyword the values to read from the fileIGNORE_TIMEdistance: READ( default=off ) ignore the time in the colvar file.FILE=COLVARcompulsory keyword the name of the file from which to read these quantitiesVALUES=distancecompulsory keyword the values to read from the fileIGNORE_TIMEmybias: READ( default=off ) ignore the time in the colvar file.FILE=COLVARcompulsory keyword the name of the file from which to read these quantitiesVALUES=mybias.biascompulsory keyword the values to read from the fileIGNORE_TIME# Shift energy (to avoid numerical issues) renergy: COMBINE( default=off ) ignore the time in the colvar file.ARG=energythe input for this action is the scalar output from one or more other actions.PARAMETERS=-13250compulsory keyword ( default=0.0 ) the parameters of the arguments in your functionPERIODIC=NO # Weights bias_weights: REWEIGHT_BIAScompulsory keyword if the output of your function is periodic then you should specify the periodicity of the function.TEMP=500the system temperature.ARG=mybias.bias temp_press_weights: REWEIGHT_TEMP_PRESScompulsory keyword ( default=*.bias ) the biases that must be taken into account when reweightingTEMP=500the system temperature.REWEIGHT_TEMP=300Reweighting temperatureENERGY=renergy # Ensemble average of the distance at 300 K avg_dist: AVERAGEEnergyARG=distancethe input for this action is the scalar output from one or more other actions.LOGWEIGHTS=bias_weights,temp_press_weights PRINTlist of actions that calculates log weights that should be used to weight configurations when calculating averagesARG=avg_distthe input for this action is the scalar output from one or more other actions.FILE=COLVAR_REWEIGHTthe name of the file on which to output these quantitiesSTRIDE=1compulsory keyword ( default=1 ) the frequency with which the quantities of interest should be output
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).
energy: READFILE=COLVARcompulsory keyword the name of the file from which to read these quantitiesVALUES=energycompulsory keyword the values to read from the fileIGNORE_TIMEvolume: READ( default=off ) ignore the time in the colvar file.FILE=COLVARcompulsory keyword the name of the file from which to read these quantitiesVALUES=volumecompulsory keyword the values to read from the fileIGNORE_TIMEmybias: READ( default=off ) ignore the time in the colvar file.FILE=COLVARcompulsory keyword the name of the file from which to read these quantitiesVALUES=mybias.biascompulsory keyword the values to read from the fileIGNORE_TIME# Shift energy and volume (to avoid numerical issues) rvol: COMBINE( default=off ) ignore the time in the colvar file.ARG=volumethe input for this action is the scalar output from one or more other actions.PARAMETERS=7.8compulsory keyword ( default=0.0 ) the parameters of the arguments in your functionPERIODIC=NO renergy: COMBINEcompulsory keyword if the output of your function is periodic then you should specify the periodicity of the function.ARG=energythe input for this action is the scalar output from one or more other actions.PARAMETERS=-13250compulsory keyword ( default=0.0 ) the parameters of the arguments in your functionPERIODIC=NO # Weights bias_weights: REWEIGHT_BIAScompulsory keyword if the output of your function is periodic then you should specify the periodicity of the function.TEMP=500the system temperature.ARG=mybias.bias temp_press_weights: REWEIGHT_TEMP_PRESScompulsory keyword ( default=*.bias ) the biases that must be taken into account when reweightingTEMP=500the system temperature.REWEIGHT_TEMP=300Reweighting temperaturePRESSURE=0.06022140857The system pressureENERGY=renergyEnergyVOLUME=rvol # Ensemble average of the volume at 300 K avg_vol: AVERAGEVolumeARG=volumethe input for this action is the scalar output from one or more other actions.LOGWEIGHTS=bias_weights,temp_press_weights # Ensemble average of the density at 300 K avg_density: CUSTOMlist of actions that calculates log weights that should be used to weight configurations when calculating averagesARG=avg_volthe input for this action is the scalar output from one or more other actions.FUNC=1000/xcompulsory keyword the function you wish to evaluatePERIODIC=NO PRINTcompulsory keyword if the output of your function is periodic then you should specify the periodicity of the function.ARG=avg_densitythe input for this action is the scalar output from one or more other actions.FILE=COLVAR_REWEIGHTthe name of the file on which to output these quantitiesSTRIDE=1compulsory keyword ( default=1 ) the frequency with which the quantities of interest should be output
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).
volume: READFILE=COLVARcompulsory keyword the name of the file from which to read these quantitiesVALUES=volumecompulsory keyword the values to read from the fileIGNORE_TIMEmybias: READ( default=off ) ignore the time in the colvar file.FILE=COLVARcompulsory keyword the name of the file from which to read these quantitiesVALUES=mybias.biascompulsory keyword the values to read from the fileIGNORE_TIME# Shift volume (to avoid numerical issues) rvol: COMBINE( default=off ) ignore the time in the colvar file.ARG=volumethe input for this action is the scalar output from one or more other actions.PARAMETERS=7.8compulsory keyword ( default=0.0 ) the parameters of the arguments in your functionPERIODIC=NO # Weights bias_weights: REWEIGHT_BIAScompulsory keyword if the output of your function is periodic then you should specify the periodicity of the function.TEMP=500the system temperature.ARG=mybias.bias temp_press_weights: REWEIGHT_TEMP_PRESScompulsory keyword ( default=*.bias ) the biases that must be taken into account when reweightingTEMP=500the system temperature.PRESSURE=0.06022140857The system pressureREWEIGHT_PRESSURE=180.66422571Reweighting pressureVOLUME=volume # Ensemble average of the volume at 300 K and 300 MPa avg_vol: AVERAGEVolumeARG=volumethe input for this action is the scalar output from one or more other actions.LOGWEIGHTS=bias_weights,temp_press_weights # Ensemble average of the density at 300 K and 300 MPa avg_density: CUSTOMlist of actions that calculates log weights that should be used to weight configurations when calculating averagesARG=avg_volthe input for this action is the scalar output from one or more other actions.FUNC=1000/xcompulsory keyword the function you wish to evaluatePERIODIC=NO PRINTcompulsory keyword if the output of your function is periodic then you should specify the periodicity of the function.ARG=avg_densitythe input for this action is the scalar output from one or more other actions.FILE=COLVAR_REWEIGHTthe name of the file on which to output these quantitiesSTRIDE=1compulsory keyword ( default=1 ) the frequency with which the quantities of interest should be output
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).
energy: READFILE=COLVARcompulsory keyword the name of the file from which to read these quantitiesVALUES=energycompulsory keyword the values to read from the fileIGNORE_TIMEvolume: READ( default=off ) ignore the time in the colvar file.FILE=COLVARcompulsory keyword the name of the file from which to read these quantitiesVALUES=volumecompulsory keyword the values to read from the fileIGNORE_TIMEmybias: READ( default=off ) ignore the time in the colvar file.FILE=COLVARcompulsory keyword the name of the file from which to read these quantitiesVALUES=mybias.biascompulsory keyword the values to read from the fileIGNORE_TIME# Shift energy and volume (to avoid numerical issues) rvol: COMBINE( default=off ) ignore the time in the colvar file.ARG=volumethe input for this action is the scalar output from one or more other actions.PARAMETERS=7.8compulsory keyword ( default=0.0 ) the parameters of the arguments in your functionPERIODIC=NO renergy: COMBINEcompulsory keyword if the output of your function is periodic then you should specify the periodicity of the function.ARG=energythe input for this action is the scalar output from one or more other actions.PARAMETERS=-13250compulsory keyword ( default=0.0 ) the parameters of the arguments in your functionPERIODIC=NO # Weights bias_weights: REWEIGHT_BIAScompulsory keyword if the output of your function is periodic then you should specify the periodicity of the function.TEMP=500the system temperature.ARG=mybias.bias temp_press_weights: REWEIGHT_TEMP_PRESScompulsory keyword ( default=*.bias ) the biases that must be taken into account when reweightingTEMP=500the system temperature.REWEIGHT_TEMP=300Reweighting temperaturePRESSURE=0.06022140857The system pressureREWEIGHT_PRESSURE=180.66422571Reweighting pressureENERGY=renergyEnergyVOLUME=rvol # Ensemble average of the volume at 300 K and 300 MPa avg_vol: AVERAGEVolumeARG=volumethe input for this action is the scalar output from one or more other actions.LOGWEIGHTS=bias_weights,temp_press_weights # Ensemble average of the density at 300 K and 300 MPa avg_density: CUSTOMlist of actions that calculates log weights that should be used to weight configurations when calculating averagesARG=avg_volthe input for this action is the scalar output from one or more other actions.FUNC=1000/xcompulsory keyword the function you wish to evaluatePERIODIC=NO PRINTcompulsory keyword if the output of your function is periodic then you should specify the periodicity of the function.ARG=avg_densitythe input for this action is the scalar output from one or more other actions.FILE=COLVAR_REWEIGHTthe name of the file on which to output these quantitiesSTRIDE=1compulsory keyword ( default=1 ) the frequency with which the quantities of interest should be output
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 |