Shortcut: HISTOGRAM
Module | gridtools |
---|---|
Description | Usage |
Accumulate the average probability density along a few CVs from a trajectory. | |
output value | type |
the estimate of the histogram as a function of the argument that was obtained | grid |
Details and examples
Accumulate the average probability density along a few CVs from a trajectory.
When using this shortcut it is supposed that you have some collective variable that gives a reasonable description of some physical or chemical phenomenon. As an example of what we mean by this suppose you wish to examine the following SN2 reaction:
The distance between the chlorine atom and the carbon is an excellent collective variable, , in this case because this distance is short for the reactant, , because the carbon and chlorine are chemically bonded, and because it is long for the product state when these two atoms are not chemically bonded. We thus might want to accumulate the probability density, , as a function of this distance as this will provide us with information about the overall likelihood of the reaction. Furthermore, the free energy, , is related to this probability density via:
Accumulating these probability densities is precisely what this shortcut can be used to do. Furthermore, the conversion of the histogram to the free energy can be achieved by using the method CONVERT_TO_FES.
We calculate histograms within PLUMED using a method known as kernel density estimation. This shortcut action thus uses the KDE and ACCUMULATE actions to build up the time average of the histogram.
In PLUMED the value of at each discrete instant in time in the trajectory is accumulated. A kernel, , centered at the current value, , of this quantity is generated with a bandwidth , which is set by the user. These kernels are then used to accumulate the ensemble average for the probability density:
Here the sums run over a portion of the trajectory specified by the user. The final quantity evaluated is a weighted average as the weights, , allow us to negate the effect any bias might have on the region of phase space sampled by the system.
A discrete analogue of kernel density estimation can also be used. In this analogue the kernels in the above formula are replaced by Dirac delta functions. When this method is used the final function calculated is no longer a probability density - it is instead a probability mass function as each element of the function tells you the value of an integral between two points on your grid rather than the value of a (continuous) function on a grid.
Additional material and examples can be also found in this tutorial, which also introduces the technique known as block averaging.
Examples
The following input monitors two torsional angles during a simulation and outputs a continuous histogram as a function of them at the end of the simulation.
r1TORSIONCalculate one or multiple torsional angles. More details ATOMSthe four atoms involved in the torsional angle=1,2,3,4 r2 : TORSIONCalculate one or multiple torsional angles. More details ATOMSthe four atoms involved in the torsional angle=2,3,4,5 hhHISTOGRAMAccumulate the average probability density along a few CVs from a trajectory. This action is a shortcut and it has hidden defaults. More details ... ARGthe quantities that are being used to construct the histogram=r1,r2 GRID_MIN the lower bounds for the grid=-pi,-pi GRID_MAX the upper bounds for the grid=pi,pi GRID_BINthe number of bins for the grid=200,200 BANDWIDTHthe bandwidths for kernel density esimtation=0.05,0.05 ... ::
DUMPGRIDOutput the function on the grid to a file with the PLUMED grid format. More details ARGthe label for the grid that you would like to output=hh FILE the file on which to write the grid=histo
Instead of the number of bins to use when constructing your histogram you can specify the grid spacing to be used as shown below:
r1TORSIONCalculate one or multiple torsional angles. More details ATOMSthe four atoms involved in the torsional angle=1,2,3,4 r2 : TORSIONCalculate one or multiple torsional angles. More details ATOMSthe four atoms involved in the torsional angle=2,3,4,5 hhHISTOGRAMAccumulate the average probability density along a few CVs from a trajectory. This action is a shortcut and it has hidden defaults. More details ... ARGthe quantities that are being used to construct the histogram=r1,r2 GRID_MIN the lower bounds for the grid=-pi,-pi GRID_MAX the upper bounds for the grid=pi,pi GRID_SPACINGthe approximate grid spacing (to be used as an alternative or together with GRID_BIN)=0.01,0.01 BANDWIDTHthe bandwidths for kernel density esimtation=0.05,0.05 ... ::
DUMPGRIDOutput the function on the grid to a file with the PLUMED grid format. More details ARGthe label for the grid that you would like to output=hh FILE the file on which to write the grid=histo
The following input monitors two torsional angles during a simulation and outputs a discrete histogram as a function of them at the end of the simulation.
r1TORSIONCalculate one or multiple torsional angles. More details ATOMSthe four atoms involved in the torsional angle=1,2,3,4 r2 : TORSIONCalculate one or multiple torsional angles. More details ATOMSthe four atoms involved in the torsional angle=2,3,4,5 hhHISTOGRAMAccumulate the average probability density along a few CVs from a trajectory. This action is a shortcut and it has hidden defaults. More details ... ARGthe quantities that are being used to construct the histogram=r1,r2 KERNEL the kernel function you are using=DISCRETE GRID_MIN the lower bounds for the grid=-pi,-pi GRID_MAX the upper bounds for the grid=pi,pi GRID_BINthe number of bins for the grid=200,200 ... ::
DUMPGRIDOutput the function on the grid to a file with the PLUMED grid format. More details ARGthe label for the grid that you would like to output=hh FILE the file on which to write the grid=histo
The following input monitors two torsional angles during a simulation and outputs the histogram accumulated thus far every 100000 steps.
r1TORSIONCalculate one or multiple torsional angles. More details ATOMSthe four atoms involved in the torsional angle=1,2,3,4 r2 : TORSIONCalculate one or multiple torsional angles. More details ATOMSthe four atoms involved in the torsional angle=2,3,4,5 hhHISTOGRAMAccumulate the average probability density along a few CVs from a trajectory. This action is a shortcut and it has hidden defaults. More details ... ARGthe quantities that are being used to construct the histogram=r1,r2 GRID_MIN the lower bounds for the grid=-pi,-pi GRID_MAX the upper bounds for the grid=pi,pi GRID_BINthe number of bins for the grid=200,200 BANDWIDTHthe bandwidths for kernel density esimtation=0.05,0.05 ... ::
DUMPGRIDOutput the function on the grid to a file with the PLUMED grid format. More details ARGthe label for the grid that you would like to output=hh FILE the file on which to write the grid=histo STRIDE the frequency with which the grid should be output to the file=100000
The following input monitors two torsional angles during a simulation and outputs a separate histogram for each 100000 steps worth of trajectory. Notice how the CLEAR keyword is used here and how it is not used in the previous example.
r1TORSIONCalculate one or multiple torsional angles. More details ATOMSthe four atoms involved in the torsional angle=1,2,3,4 r2 : TORSIONCalculate one or multiple torsional angles. More details ATOMSthe four atoms involved in the torsional angle=2,3,4,5 hhHISTOGRAMAccumulate the average probability density along a few CVs from a trajectory. This action is a shortcut and it has hidden defaults. More details ... ARGthe quantities that are being used to construct the histogram=r1,r2 CLEAR the frequency with whihc to clear the data that is being averaged=100000 GRID_MIN the lower bounds for the grid=-pi,-pi GRID_MAX the upper bounds for the grid=pi,pi GRID_BINthe number of bins for the grid=200,200 BANDWIDTHthe bandwidths for kernel density esimtation=0.05,0.05 ... ::
DUMPGRIDOutput the function on the grid to a file with the PLUMED grid format. More details ARGthe label for the grid that you would like to output=hh FILE the file on which to write the grid=histo STRIDE the frequency with which the grid should be output to the file=100000
The following input accumulates a histogram using a subset of the data in this trajectory. When you use this input the first 10 ps of simulation time is discarded. Data is then collected in the 190 ps after that first 10 ps. The remainder of the trajectory is not used to update the histogram.
r1TORSIONCalculate one or multiple torsional angles. More details ATOMSthe four atoms involved in the torsional angle=1,2,3,4 r2 : TORSIONCalculate one or multiple torsional angles. More details ATOMSthe four atoms involved in the torsional angle=2,3,4,5 hhHISTOGRAMAccumulate the average probability density along a few CVs from a trajectory. This action is a shortcut and it has hidden defaults. More details ... ARGthe quantities that are being used to construct the histogram=r1,r2 GRID_MIN the lower bounds for the grid=-pi,-pi GRID_MAX the upper bounds for the grid=pi,pi GRID_BINthe number of bins for the grid=200,200 BANDWIDTHthe bandwidths for kernel density esimtation=0.05,0.05 UPDATE_FROMOnly update this action from this time=10 UPDATE_UNTILOnly update this action until this time=200 ... ::
DUMPGRIDOutput the function on the grid to a file with the PLUMED grid format. More details ARGthe label for the grid that you would like to output=hh FILE the file on which to write the grid=histo STRIDE the frequency with which the grid should be output to the file=0
In this final example there is a fixed restraint on the distance between atoms 1 and 2. Clearly, this restraint will have an effect on the region of phase space that will be sampled when an MD simulation is run using this variable. Consequently, when the histogram as a function of the distance, , is accumulated, we use reweighting into order to discount the effect of the bias from our final histogram.
xDISTANCECalculate the distance/s between pairs of atoms. More details ATOMSthe pair of atom that we are calculating the distance between=1,2 RESTRAINTAdds harmonic and/or linear restraints on one or more variables. More details ARGthe values the harmonic restraint acts upon=x SLOPE specifies that the restraint is linear and what the values of the force constants on each of the variables are=1.0 ATthe position of the restraint=0.0 REWEIGHT_BIASCalculate weights for ensemble averages that negate the effect the bias has on the region of phase space explored This action has hidden defaults. More details TEMPthe system temperature=300 bias ::
hBHISTOGRAMAccumulate the average probability density along a few CVs from a trajectory. This action is a shortcut and it has hidden defaults. More details ... ARGthe quantities that are being used to construct the histogram=x GRID_MIN the lower bounds for the grid=0.0 GRID_MAX the upper bounds for the grid=3.0 GRID_BINthe number of bins for the grid=100 BANDWIDTHthe bandwidths for kernel density esimtation=0.1 LOGWEIGHTSthe logarithm of the quantity to use as the weights when calculating averages=bias ... :
DUMPGRIDOutput the function on the grid to a file with the PLUMED grid format. More details ARGthe label for the grid that you would like to output=hB FILE the file on which to write the grid=histoB STRIDE the frequency with which the grid should be output to the file=1
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/vector/matrix | the quantities that are being used to construct the histogram |
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 quantities that are being used to construct the histogram |
NORMALIZATION | compulsory | ndata | This controls how the data is normalized it can be set equal to true, false or ndata |
GRID_MIN | compulsory | auto | the lower bounds for the grid |
GRID_MAX | compulsory | auto | the upper bounds for the grid |
KERNEL | compulsory | GAUSSIAN | the kernel function you are using |
STRIDE | compulsory | 1 | the frequency with which to store data for averaging |
CLEAR | compulsory | 0 | the frequency with whihc to clear the data that is being averaged |
UPDATE_FROM | optional | not used | Only update this action from this time |
UPDATE_UNTIL | optional | not used | Only update this action until this time |
BANDWIDTH | optional | not used | the bandwidths for kernel density esimtation |
GRID_BIN | optional | not used | the number of bins for the grid |
GRID_SPACING | optional | not used | the approximate grid spacing (to be used as an alternative or together with GRID_BIN) |
LOGWEIGHTS | optional | not used | the logarithm of the quantity to use as the weights when calculating averages |
deprecated keywords
The keywords in the following table can still be used with this action but have been deprecated
Keyword | Description |
---|---|
DATA | You should use ARG instead of this keyword which was used in older versions of PLUMED and is provided for back compatibility only |