Action: ACCUMULATE
Module | generic |
---|---|
Description | Usage |
Sum the elements of this value over the course of the trajectory | |
output value | type |
a sum calculated from the time series of the input quantity | scalar/grid |
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/grid | the label of the argument that is being added to on each timestep |
Further details and examples
Sum the elements of this value over the course of the trajectory
This action is used to sum the outputs from another action over the course of the trajectory. This is useful if you want to calculate the average value that a CV took over the course of a simulation. As an example, the following input can be used to calculate the average distance between atom 1 and atom 2.
cCONSTANTCreate a constant value that can be passed to actions This action has hidden defaults. More details VALUEthe single number that you would like to store=1 : d : DISTANCECalculate the distance/s between pairs of atoms. More details ATOMSthe pair of atom that we are calculating the distance between=1,2 # This adds together the value of the distance on every step sACCUMULATESum the elements of this value over the course of the trajectory This action has hidden defaults. More details ARGthe label of the argument that is being added to on each timestep=d STRIDE the frequency with which the data should be collected and added to the quantity being averaged=1 : # This adds one every time we add a new distance to the value s nACCUMULATESum the elements of this value over the course of the trajectory This action has hidden defaults. More details ARGthe label of the argument that is being added to on each timestep=c STRIDE the frequency with which the data should be collected and added to the quantity being averaged=1 : # This is thus the average distance a : CUSTOMCalculate a combination of variables using a custom expression. More details ARGthe values input to this function=s,n FUNCthe function you wish to evaluate=x/y PERIODICif the output of your function is periodic then you should specify the periodicity of the function=NO # This prints out the average over the whole trajectory (STRIDE=0 means print at end only) PRINTPrint quantities to a file. More details ARGthe labels of the values that you would like to print to the file=a FILEthe name of the file on which to output these quantities=average.dat STRIDE the frequency with which the quantities of interest should be output=0
You can use this action for block averaging by using the CLEAR
keyword as shown below:
cCONSTANTCreate a constant value that can be passed to actions This action has hidden defaults. More details VALUEthe single number that you would like to store=1 : d : DISTANCECalculate the distance/s between pairs of atoms. More details ATOMSthe pair of atom that we are calculating the distance between=1,2 # This adds together the value of the distance on every step s : ACCUMULATESum the elements of this value over the course of the trajectory More details ARGthe label of the argument that is being added to on each timestep=d STRIDE the frequency with which the data should be collected and added to the quantity being averaged=1 CLEAR the frequency with which to clear all the accumulated data=1000 # This adds one every time we add a new distance to the value s n : ACCUMULATESum the elements of this value over the course of the trajectory More details ARGthe label of the argument that is being added to on each timestep=c STRIDE the frequency with which the data should be collected and added to the quantity being averaged=1 CLEAR the frequency with which to clear all the accumulated data=1000 # This is thus the average distance a : CUSTOMCalculate a combination of variables using a custom expression. More details ARGthe values input to this function=s,n FUNCthe function you wish to evaluate=x/y PERIODICif the output of your function is periodic then you should specify the periodicity of the function=NO # This prints out the average over the whole trajectory (STRIDE=0 means print at end only) PRINTPrint quantities to a file. More details ARGthe labels of the values that you would like to print to the file=a FILEthe name of the file on which to output these quantities=average.dat STRIDE the frequency with which the quantities of interest should be output=1000
The instructions CLEAR=1000
in the above input tells PLUMED to set the values s
and n
back to
zero after 1000 new steps have been performed. The PRINT action will thus print a block average that
is taken from the first 1000 steps of the trajectory, a second block average from the second 1000 steps
of the trajectory and so on.
Estimating histograms
We can also use this action to construct histograms. The example below shows how you can estimate the distribution of distances between atoms 1 and 2 that are sampled over the course of the trajectory.
cCONSTANTCreate a constant value that can be passed to actions This action has hidden defaults. More details VALUEthe single number that you would like to store=1 : d : DISTANCECalculate the distance/s between pairs of atoms. More details ATOMSthe pair of atom that we are calculating the distance between=1,2 # Construct the instantaneous histogram from the instantaneous value of the distance kdeKDECreate a histogram from the input scalar/vector/matrix using KDE This action has hidden defaults. More details ARGthe label for the value that should be used to construct the histogram=d BANDWIDTHthe bandwidths for kernel density esimtation=0.05 GRID_MIN the lower bounds for the grid=0 GRID_MAX the upper bounds for the grid=5 GRID_BINthe number of bins for the grid=250 : # Now add together all the instantaneous histograms histACCUMULATESum the elements of this value over the course of the trajectory This action has hidden defaults. More details ARGthe label of the argument that is being added to on each timestep=kde STRIDE the frequency with which the data should be collected and added to the quantity being averaged=1 : # And normalise the histogram nACCUMULATESum the elements of this value over the course of the trajectory This action has hidden defaults. More details ARGthe label of the argument that is being added to on each timestep=c STRIDE the frequency with which the data should be collected and added to the quantity being averaged=1 : a : CUSTOMCalculate a combination of variables using a custom expression. More details ARGthe values input to this function=hist,n FUNCthe function you wish to evaluate=x/y PERIODICif the output of your function is periodic then you should specify the periodicity of the function=NO # And print out the final histogram 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=a FILE the file on which to write the grid=histo.grid
At first glance the fact that we use a KDE action to construct an instaneous histogram from a single distance may appear odd. The reason for doing this, however, is to introduce a clear distinction between the syntaxes that are used for spatial and temporal averaging. To see what I mean consider the following input:
cCONSTANTCreate a constant value that can be passed to actions This action has hidden defaults. More details VALUEthe single number that you would like to store=5 : d : DISTANCECalculate the distance/s between pairs of atoms. More details ATOMS1the pair of atom that we are calculating the distance between=1,2 ATOMS2the pair of atom that we are calculating the distance between=3,4 ATOMS3the pair of atom that we are calculating the distance between=5,6 ATOMS4the pair of atom that we are calculating the distance between=7,8 ATOMS5the pair of atom that we are calculating the distance between=9,10 # Construct the instantaneous histogram from the instantaneous value of the distance kdeKDECreate a histogram from the input scalar/vector/matrix using KDE This action has hidden defaults. More details ARGthe label for the value that should be used to construct the histogram=d BANDWIDTHthe bandwidths for kernel density esimtation=0.05 GRID_MIN the lower bounds for the grid=0 GRID_MAX the upper bounds for the grid=5 GRID_BINthe number of bins for the grid=250 : # Now add together all the instantaneous histograms histACCUMULATESum the elements of this value over the course of the trajectory This action has hidden defaults. More details ARGthe label of the argument that is being added to on each timestep=kde STRIDE the frequency with which the data should be collected and added to the quantity being averaged=1 : # And normalise the histogram nACCUMULATESum the elements of this value over the course of the trajectory This action has hidden defaults. More details ARGthe label of the argument that is being added to on each timestep=c STRIDE the frequency with which the data should be collected and added to the quantity being averaged=1 : a : CUSTOMCalculate a combination of variables using a custom expression. More details ARGthe values input to this function=hist,n FUNCthe function you wish to evaluate=x/y PERIODICif the output of your function is periodic then you should specify the periodicity of the function=NO # And print out the final histogram 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=a FILE the file on which to write the grid=histo.grid
This input computes 5 distances. Kernels correpsonding to all five of these distances are added to the instaneous
histogram that is constructed using the KDE action. When we call the accumulate action here we are thus
not simply adding a single kernel to the accumulated grid when we add the the elements from kde
.
Syntax
The following table describes the keywords and options that can be used with this action
Keyword | Type | Default | Description |
---|---|---|---|
ARG | input | none | the label of the argument that is being added to on each timestep |
STRIDE | compulsory | 1 | the frequency with which the data should be collected and added to the quantity being averaged |
CLEAR | compulsory | 0 | the frequency with which to clear all the accumulated data |
NUMERICAL_DERIVATIVES | optional | false | calculate the derivatives for these quantities numerically |
UPDATE_FROM | optional | not used | Only update this action from this time |
UPDATE_UNTIL | optional | not used | Only update this action until this time |