Trieste tutorial: Using restraints

Aims

The aim of this tutorial is to introduce the users to the use of constant biases in PLUMED.

Objectives

  • Apply a restraint on a simulations over one or more collective variables
  • Understand the effect of a restraint on the acquired statistics
  • Perform a simple un-biasing of a restrained simulation
  • Add an external potential in the form of an analytical or numerical function

Resources

The TARBALL for this tutorial contains the following files:

  • wdimer.pdb: a PDB file for two molecules of water in vacuo
  • wdimer.tpr: a GROMACS run file to perform MD of two water molecules
  • diala.pdb: a PDB file for alanine dipeptide in vacuo
  • diala.tpr: a GROMACS run file to perform MD of alanine dipeptide
  • do_block_histo.py: the python script from Trieste tutorial: Averaging, histograms and block analysis to perform block averaging over histograms

This tutorial has been tested on a pre-release version of version 2.4. However, it should not take advantage of 2.4-only features, thus should also work with version 2.3.

Introduction

PLUMED can calculate conformational properties of a system a posteriori as well as on-the-fly. This information can be use to manipulate a simulation on-the-fly. This means adding energy terms in addition to those of the original Hamiltonian. This additional energy terms are usually referred as Bias. In the following we will see how to apply a constant bias potential with PLUMED. It is preferable to run each exercise in a separate folder.

To learn more: Summary of theory

We will make use of two toy models: the first is a water dimer, i.e. two molecules of water in vacuo, that we will use to compare the effect of a constant bias on the equilibrium properties of the system that in this case can be readily computed. The second toy model is alanine dipeptide in vacuo. This system is more challenging to characterize with a standard MD simulation and we will see how we can use an interactive approach to to build a constant bias that will help in flattening the underlying free energy surface and thus sped up the sampling.

Note
Create a folder for each exercise and use sub-folders if you want to run the same simulation with multiple choices for the parameters

Exercise 1: converged histogram of the water dimer relative distance

A water dimer

First of all let's start to learn something about the water dimer system by running a first simulations. You can start by creating a folder with the dimer.tpr file and run a simulation.

> gmx mdrun -s dimer.tpr  

In this way we have a 25ns long trajectory that we can use to have a first look at the behavior of the system. Is the sampling of the relative distance between the two water molecules converged?

Use plumed driver to analyze the trajectory and evaluate the quality of the sampling.

Here you can find a sample plumed.dat file that you can use as a template. Whenever you see an highlighted FILL string, this is a string that you should replace.

Click on the labels of the actions for more information on what each action computes
tested on v2.7
# vim:ft=plumed
#compute the distance between the two oxygens
d: DISTANCE 
ATOMS
the pair of atom that we are calculating the distance between.
=1,4 #accumulate block histograms hh: HISTOGRAM
ARG
the input for this action is the scalar output from one or more other actions.
=d
STRIDE
compulsory keyword ( default=1 ) the frequency with which the data should be collected and added to the quantity being averaged
=10
GRID_MIN
compulsory keyword the lower bounds for the grid
=0
GRID_MAX
compulsory keyword the upper bounds for the grid
=4.0
GRID_BIN
the number of bins for the grid
=200
KERNEL
compulsory keyword ( default=gaussian ) the kernel function you are using.
=DISCRETE
CLEAR
compulsory keyword ( default=0 ) the frequency with which to clear all the accumulated data.
=10000 #and dump them DUMPGRID
GRID
compulsory keyword the action that creates the grid you would like to output
=hh
FILE
compulsory keyword ( default=density ) the file on which to write the grid.
=my_histogram.dat
STRIDE
compulsory keyword ( default=0 ) the frequency with which the grid should be output to the file.
=10000 # Print the collective variable. PRINT
ARG
the input for this action is the scalar output from one or more other actions.
=d
STRIDE
compulsory keyword ( default=1 ) the frequency with which the quantities of interest should be output
=10
FILE
the name of the file on which to output these quantities
=distance.dat
> plumed driver --mf_xtc traj_comp.xtc --plumed plumed.dat  
> python3 do_block_histo.py > final-histo-10000.dat

If there is something you don't remember about this procedure go back and check in Trieste tutorial: Averaging, histograms and block analysis . There you can also find a python script to perform block averaging of the histograms and assess the error. The result should be comparable with the following:

A histogram of the relative distance (in nm) with errors

Notice the peak at 0.9 nm, this is the effect of using cut-off for the calculation of the interactions in the simulation (check the run-dimer.mdp file for the properties of the run)

Exercise 2: Apply a linear restraint on the same collective variable

Now we will try to apply a linear restraint on the relative distance and compare the resulting distribution. The new sampling will reflect the effect of the bias. Be careful about the statistics: in the simulation of exercise 1 you were post processing a trajectory of 125000 frames accumulating one frame every ten in an histogram and clearing the histogram after 10000 steps. As a result you had 12 blocks in the form of 11 analysis.* files and a final block named my_histogram.dat. In the following try to accumulate on the fly the same amount of statistics. Look into the .mdp file to see how often frames are written in a trajectory. If you write too many analysis.* files (i.e. 100 files plumed will fail with an error).

Click on the labels of the actions for more information on what each action computes
tested on v2.7
# vim:ft=plumed
#compute the distance between the two oxygens
d: DISTANCE __FILL__
#accumulate block histograms
hh: HISTOGRAM 
ARG
the input for this action is the scalar output from one or more other actions.
=d
KERNEL
compulsory keyword ( default=gaussian ) the kernel function you are using.
=DISCRETE
STRIDE
compulsory keyword ( default=1 ) the frequency with which the data should be collected and added to the quantity being averaged
=500
CLEAR
compulsory keyword ( default=0 ) the frequency with which to clear all the accumulated data.
=500000
GRID_MIN
compulsory keyword the lower bounds for the grid
=0
GRID_MAX
compulsory keyword the upper bounds for the grid
=4.0
GRID_BIN
the number of bins for the grid
=200 #and dump them DUMPGRID __FILL__ #apply a linear restraint lr: RESTRAINT
ARG
the input for this action is the scalar output from one or more other actions.
=d
KAPPA
compulsory keyword ( default=0.0 ) specifies that the restraint is harmonic and what the values of the force constants on each of the variables are
=0
AT
compulsory keyword the position of the restraint
=0
SLOPE
compulsory keyword ( default=0.0 ) specifies that the restraint is linear and what the values of the force constants on each of the variables are
=2.5 # Print the collective variable and the bias. PRINT __FILL__

In a new folder we can run this new simulation this time biasing and analyzing the simulation on-the-fly.

> gmx mdrun -s dimer.tpr -plumed plumed.dat 

The histogram should look different.

The effect of a constant bias is that of systematically changing the probability of each conformation by a factor \( \exp(+V_{bias}/k_{B}T) \). This means that it is easily possible to recover the un-biased distribution at least in the regions of the conformational space that have been thoroughly sampled. In practice the statistical weight of each frame is not 1 anymore but is given by the exponential of the bias.

In order to recover the unbiased distribution we can post process the simulation using plumed driver to recalculate the bias felt by each frame and store this information to analyze any property. Furthermore plumed can also automatically use the bias to reweight the accumulated histogram.

Click on the labels of the actions for more information on what each action computes
tested on v2.7
# vim:ft=plumed
d: DISTANCE __FILL__
lr: RESTRAINT __FILL__
as: REWEIGHT_BIAS 
TEMP
the system temperature.
=298 HISTOGRAM ...
LOGWEIGHTS
list of actions that calculates log weights that should be used to weight configurations when calculating averages
=as
ARG
the input for this action is the scalar output from one or more other actions.
=d
STRIDE
compulsory keyword ( default=1 ) the frequency with which the data should be collected and added to the quantity being averaged
=10
GRID_MIN
compulsory keyword the lower bounds for the grid
=0
GRID_MAX
compulsory keyword the upper bounds for the grid
=4.0
GRID_BIN
the number of bins for the grid
=200
KERNEL
compulsory keyword ( default=gaussian ) the kernel function you are using.
=DISCRETE
CLEAR
compulsory keyword ( default=0 ) the frequency with which to clear all the accumulated data.
=10000 ... DUMPGRID __FILL__ PRINT
ARG
the input for this action is the scalar output from one or more other actions.
=*.*
FILE
the name of the file on which to output these quantities
=COLVAR
STRIDE
compulsory keyword ( default=1 ) the frequency with which the quantities of interest should be output
=1

Be careful again about the difference in the way statistics is accumulated on-the-fly or for post processing. This is not critical for the result but is important in order to have comparable histograms, that is histograms with comparable noise. Remember to give different names to the new histogram otherwise the one obtained before will be overwritten.

> plumed driver --mf_xtc traj_comp.xtc --plumed plumed.dat  
Note
To run block analysis of both sets of histograms you need to edit the python script because the file name is hard coded.
> python3 do_block_histo.py > histo-biased.dat 
> python3 do_block_histo.py > histo-reweighted.dat 

Now the resulting histogram should be comparable to the reference one.

Exercise 3: Apply a quadratic restraint on the same collective variable

Do you expect a different behavior? This time we can write the plumed input file in such a way to compare directly the biased and unbiased histograms.

Click on the labels of the actions for more information on what each action computes
tested on v2.7
# vim:ft=plumed
#calculate the distance
d: DISTANCE 
ATOMS
the pair of atom that we are calculating the distance between.
=1,4 #apply the quadratic restraint centered at a distance of 0.5 nm lr: RESTRAINT
ARG
the input for this action is the scalar output from one or more other actions.
=d
KAPPA
compulsory keyword ( default=0.0 ) specifies that the restraint is harmonic and what the values of the force constants on each of the variables are
=10
AT
compulsory keyword the position of the restraint
=0.5 #accumulate the biased histogram hh: HISTOGRAM
ARG
the input for this action is the scalar output from one or more other actions.
=d
STRIDE
compulsory keyword ( default=1 ) the frequency with which the data should be collected and added to the quantity being averaged
=500
GRID_MIN
compulsory keyword the lower bounds for the grid
=0
GRID_MAX
compulsory keyword the upper bounds for the grid
=4.0
GRID_BIN
the number of bins for the grid
=200
KERNEL
compulsory keyword ( default=gaussian ) the kernel function you are using.
=DISCRETE
CLEAR
compulsory keyword ( default=0 ) the frequency with which to clear all the accumulated data.
=500000 #dumpit DUMPGRID
GRID
compulsory keyword the action that creates the grid you would like to output
=hh
FILE
compulsory keyword ( default=density ) the file on which to write the grid.
=my_histogram.dat
STRIDE
compulsory keyword ( default=0 ) the frequency with which the grid should be output to the file.
=500000 #calculate the weights from the constant bias as: REWEIGHT_BIAS
TEMP
the system temperature.
=298 #accumulate the unbiased histogram hhu: HISTOGRAM
ARG
the input for this action is the scalar output from one or more other actions.
=d
STRIDE
compulsory keyword ( default=1 ) the frequency with which the data should be collected and added to the quantity being averaged
=500
GRID_MIN
compulsory keyword the lower bounds for the grid
=0
GRID_MAX
compulsory keyword the upper bounds for the grid
=4.0
GRID_BIN
the number of bins for the grid
=200
KERNEL
compulsory keyword ( default=gaussian ) the kernel function you are using.
=DISCRETE
CLEAR
compulsory keyword ( default=0 ) the frequency with which to clear all the accumulated data.
=500000
LOGWEIGHTS
list of actions that calculates log weights that should be used to weight configurations when calculating averages
=as #dumpit DUMPGRID
GRID
compulsory keyword the action that creates the grid you would like to output
=hhu
FILE
compulsory keyword ( default=density ) the file on which to write the grid.
=myhistu.dat
STRIDE
compulsory keyword ( default=0 ) the frequency with which the grid should be output to the file.
=500000 #print distance and bias PRINT
ARG
the input for this action is the scalar output from one or more other actions.
=d,lr.bias
FILE
the name of the file on which to output these quantities
=distance.dat
STRIDE
compulsory keyword ( default=1 ) the frequency with which the quantities of interest should be output
=50

The comparison of the two histograms with the former will show the effect of the weak quadratic bias on the simulation.

Note
To run block analysis of both sets of histograms you need to edit the python script because the file name is hard coded.
> python3 do_block_histo.py > histo-biased.dat 
> python3 do_block_histo.py > histo-reweighted.dat 

Exercise 4: Apply an upper wall on the distance.

In the above cases we have always applied weak biases. Sometimes biases are useful to prevent the system in reaching some region of the conformational space. In this case instead of using RESTRAINT , we can make use of lower or upper restraints, e.g. LOWER_WALLS and UPPER_WALLS.

What happen to the histogram when we use walls?

Click on the labels of the actions for more information on what each action computes
tested on v2.7
# vim:ft=plumed
d: DISTANCE 
ATOMS
the pair of atom that we are calculating the distance between.
=1,4 uw: UPPER_WALLS
ARG
the input for this action is the scalar output from one or more other actions.
=d
KAPPA
compulsory keyword the force constant for the wall.
=1000
AT
compulsory keyword the positions of the wall.
=2.5 # accumulate the biased histogram __FILL__ #dumpit __FILL__ # calculate the weights from the constant bias __FILL__ #accumulate the unbiased histogram __FILL__ #dumpit __FILL__ #print distance and bias __FILL__

Run it.

> gmx mdrun -s dimer.tpr -plumed plumed.dat 

If we have not sampled a region thoroughly enough it is not possible to estimate the histogram in that region even using reweighting (reweighting is not magic!).

Exercise 5: Evaluate the free energy and use it as an external restraint

The main issue in sampling rare events is that importance sampling algorithms spend more time in low energy regions and if two low energy regions are separated by a high energy one is unlikely for the sampling algorithm to cross the high energy region and reach the other low energy one. From this point of view an algorithm based on random sampling will work better in crossing the barrier. A particularly efficient sampling can be obtained if one would know the underlying free energy and thus use that to bias the sampling and make the sampling probability uniform in the regions of relevant interest. In this exercise we will make use of the free-energy estimate along the distance collective variable to bias the sampling of the same collective variable in the dimer simulation. To do so we will make use of a table potential applied using the Bias EXTERNAL. We first need to get a smooth estimate of the free-energy from our fist reference simulations, we will do this by accumulating a histogram with kernel functions, that is continuous function centered at the value of the accumulated point and added accumulated on the discrete representation of the histogram, see Kernel density estimation .

Click on the labels of the actions for more information on what each action computes
tested on v2.7
# vim:ft=plumed
#calculate the distance
d: DISTANCE 
ATOMS
the pair of atom that we are calculating the distance between.
=1,4 #accumulate the histogram using a gaussian kernel with 0.05 nm width hh2: HISTOGRAM
ARG
the input for this action is the scalar output from one or more other actions.
=d
STRIDE
compulsory keyword ( default=1 ) the frequency with which the data should be collected and added to the quantity being averaged
=10
GRID_MIN
compulsory keyword the lower bounds for the grid
=0
GRID_MAX
compulsory keyword the upper bounds for the grid
=4.0
GRID_BIN
the number of bins for the grid
=400
BANDWIDTH
compulsory keyword the bandwidths for kernel density estimation
=0.05 #convert to a free energy ff: CONVERT_TO_FES
GRID
compulsory keyword the action that creates the input grid you would like to use
=__FILL__
TEMP
the temperature at which you are operating
=__FILL__ #dump the free energy DUMPGRID
GRID
compulsory keyword the action that creates the grid you would like to output
=__FILL__
FILE
compulsory keyword ( default=density ) the file on which to write the grid.
=__FILL__

by running plumed driver on the reference trajectory we obtain a free energy estimate.

> plumed driver --mf_xtc traj_comp.xtc --plumed plumed.dat  

The resulting file for the free energy should be edited in order to:

  • Invert the sign of the free-energy and of its derivative
  • Remove some unused flag and regions with infinite potential at the boundaries

The file looks like:

#! FIELDS d ff dff_d
#! SET min_d 0
#! SET max_d 4.0
#! SET nbins_d  400
#! SET periodic_d false
0.060000 -34.9754 185.606
0.070000 -26.0117 184.362
0.080000 -20.8195 181.39
0.090000 -17.5773 176.718

where the first column is the grid spacing, the second the free energy and the third the derivative of the free energy. You can edit the file as you want, for example using the following bash lines:

grep \# ff.dat | grep -v normalisation > external.dat
grep -v \# ff.dat | awk '{print $1, -$2, -$3}' | grep -v inf >> external.dat 

Furthermore edit the first line of external.dat from

#! FIELDS d ff dff_d

to

#! FIELDS d ff.bias der_d

Now we have an external potential that is the opposite of the free energy and we can use it in a new folder to bias a simulation:

Click on the labels of the actions for more information on what each action computes
tested on v2.7
# vim:ft=plumed
d: DISTANCE 
ATOMS
the pair of atom that we are calculating the distance between.
=1,4 ff: EXTERNAL
ARG
the input for this action is the scalar output from one or more other actions.
=d
FILE
compulsory keyword the name of the file containing the external potential.
=__FILL__ # accumulate the biased histogram __FILL__ #dumpit __FILL__ # calculate the weights from the constant bias __FILL__ #accumulate the unbiased histogram __FILL__ #dumpit __FILL__ #print distance and bias __FILL__

Run it.

> gmx mdrun -s dimer.tpr -plumed plumed.dat 

How do the biased and unbiased histograms look like? In the following we will apply this concept to sample the conformational space of a more complex system.

Exercise 6: Preliminary run with Alanine dipeptide

Alanine dipeptide is characterized by multiple minima separated by relatively high free energy barriers. Here we will explore the conformational space of alanine dipeptide using a standard MD simulation, then instead of using the free energy as an external potential we will try to fit the potential using gnuplot and add a bias using an analytical function of a collective variable with MATHEVAL and BIASVALUE .

As a first test lets run an MD and generate on-the-fly the free energy as a function of the phi and psi collective variables separately.

Click on the labels of the actions for more information on what each action computes
tested on v2.7
#SETTINGS MOLFILE=user-doc/tutorials/old_tutorials/trieste-3/aladip/aladip.pdb
# vim:ft=plumed
MOLINFO 
STRUCTURE
compulsory keyword a file in pdb format containing a reference structure.
=aladip.pdb phi: TORSION
ATOMS
the four atoms involved in the torsional angle
=@phi-2 psi: TORSION
ATOMS
the four atoms involved in the torsional angle
=@psi-2 hhphi: HISTOGRAM
ARG
the input for this action is the scalar output from one or more other actions.
=phi
STRIDE
compulsory keyword ( default=1 ) the frequency with which the data should be collected and added to the quantity being averaged
=10
GRID_MIN
compulsory keyword the lower bounds for the grid
=-pi
GRID_MAX
compulsory keyword the upper bounds for the grid
=pi
GRID_BIN
the number of bins for the grid
=600
BANDWIDTH
compulsory keyword the bandwidths for kernel density estimation
=0.05 hhpsi: HISTOGRAM
ARG
the input for this action is the scalar output from one or more other actions.
=psi
STRIDE
compulsory keyword ( default=1 ) the frequency with which the data should be collected and added to the quantity being averaged
=10
GRID_MIN
compulsory keyword the lower bounds for the grid
=-pi
GRID_MAX
compulsory keyword the upper bounds for the grid
=pi
GRID_BIN
the number of bins for the grid
=600
BANDWIDTH
compulsory keyword the bandwidths for kernel density estimation
=0.05 ffphi: CONVERT_TO_FES
GRID
compulsory keyword the action that creates the input grid you would like to use
=hhphi
TEMP
the temperature at which you are operating
=298 ffpsi: CONVERT_TO_FES
GRID
compulsory keyword the action that creates the input grid you would like to use
=hhpsi
TEMP
the temperature at which you are operating
=298 DUMPGRID
GRID
compulsory keyword the action that creates the grid you would like to output
=ffphi
FILE
compulsory keyword ( default=density ) the file on which to write the grid.
=ffphi.dat DUMPGRID
GRID
compulsory keyword the action that creates the grid you would like to output
=ffpsi
FILE
compulsory keyword ( default=density ) the file on which to write the grid.
=ffpsi.dat PRINT
ARG
the input for this action is the scalar output from one or more other actions.
=phi,psi
FILE
the name of the file on which to output these quantities
=colvar.dat
STRIDE
compulsory keyword ( default=1 ) the frequency with which the quantities of interest should be output
=10

from the colvar file it is clear that we can quickly explore two minima but that the region for positive phi is not accessible. Instead of using the opposite of the free energy as a table potential here we introduce the function MATHEVAL that allows defining complex analytical functions of collective variables, and the bias BIASVALUE that allows using any continuous function of the positions as a bias.

So first we need to fit the opposite of the free energy as a function of phi in the region explored with a periodic function, because of the gaussian like look of the minima we can fit it using the von Mises distribution. In gnuplot

>gnuplot
gnuplot>plot 'ffphi.dat' u 1:(-$2+31) w l
gnuplot>f(x)=exp(k1*cos(x-a1))+exp(k2*cos(x-a2))
gnuplot>fit [-3.:-0.6] f(x) 'ffphi.dat' u 1:(-$2+31) via k1,a1,k2,a2
gnuplot>rep f(x)

The function and the resulting parameters can be used to run a new biased simulation:

Exercise 7: First biased run with Alanine dipeptide

Click on the labels of the actions for more information on what each action computes
tested on v2.7
#SETTINGS MOLFILE=user-doc/tutorials/trieste-3/aladip/aladip.pdb
# vim:ft=plumed
MOLINFO 
STRUCTURE
compulsory keyword a file in pdb format containing a reference structure.
=aladip.pdb phi: TORSION
ATOMS
the four atoms involved in the torsional angle
=@phi-2 __FILL__ doubleg: MATHEVAL ...
ARG
the input for this action is the scalar output from one or more other actions.
=phi
FUNC
compulsory keyword the function you wish to evaluate
=exp(__FILL)+__FILL__
PERIODIC
compulsory keyword if the output of your function is periodic then you should specify the periodicity of the function.
=NO ... b: BIASVALUE
ARG
the input for this action is the scalar output from one or more other actions.
=__FILL__ PRINT __FILL__

It is now possible to run a second simulation and observe the new behavior. The system quickly explores a new minimum. While a quantitative estimate of the free energy difference of the old and new regions is out of the scope of the current exercise what we can do is to add a new von Mises function centered in the new minimum with a comparable height, in this way we can hope to facilitate a back and forth transition along the phi collective variable.

>gnuplot
gnuplot> ...

We can now run a third simulation where both regions are biased.

Exercise 8: Second biased run with Alanine dipeptide

Click on the labels of the actions for more information on what each action computes
tested on v2.7
#SETTINGS MOLFILE=user-doc/tutorials/trieste-3/aladip/aladip.pdb
# vim:ft=plumed
MOLINFO 
STRUCTURE
compulsory keyword a file in pdb format containing a reference structure.
=aladip.pdb phi: TORSION
ATOMS
the four atoms involved in the torsional angle
=@phi-2 psi: TORSION
ATOMS
the four atoms involved in the torsional angle
=@psi-2 tripleg: MATHEVAL ...
ARG
the input for this action is the scalar output from one or more other actions.
=phi
FUNC
compulsory keyword the function you wish to evaluate
=exp(k1*cos(x-a1))+exp(k2*cos(x-a2))+exp(k3*cos(x+a3))
PERIODIC
compulsory keyword if the output of your function is periodic then you should specify the periodicity of the function.
=NO ... b: BIASVALUE
ARG
the input for this action is the scalar output from one or more other actions.
=tripleg __FILL__ ENDPLUMED

With this third simulation it should be possible to visit both regions as a function on the phi torsion. Now it is possible to reweight the sampling and obtain a better free energy estimate along phi.

Click on the labels of the actions for more information on what each action computes
tested on v2.7
#SETTINGS MOLFILE=user-doc/tutorials/trieste-3/aladip/aladip.pdb
# vim:ft=plumed
MOLINFO 
STRUCTURE
compulsory keyword a file in pdb format containing a reference structure.
=aladip.pdb phi: TORSION
ATOMS
the four atoms involved in the torsional angle
=@phi-2 psi: TORSION
ATOMS
the four atoms involved in the torsional angle
=@psi-2 tripleg: MATHEVAL ...
ARG
the input for this action is the scalar output from one or more other actions.
=phi
FUNC
compulsory keyword the function you wish to evaluate
=__FILL__
PERIODIC
compulsory keyword if the output of your function is periodic then you should specify the periodicity of the function.
=NO ... b: BIASVALUE
ARG
the input for this action is the scalar output from one or more other actions.
=tripleg as: REWEIGHT_BIAS
TEMP
the system temperature.
=298 hhphi: HISTOGRAM
ARG
the input for this action is the scalar output from one or more other actions.
=phi
STRIDE
compulsory keyword ( default=1 ) the frequency with which the data should be collected and added to the quantity being averaged
=10
GRID_MIN
compulsory keyword the lower bounds for the grid
=-pi
GRID_MAX
compulsory keyword the upper bounds for the grid
=pi
GRID_BIN
the number of bins for the grid
=600
BANDWIDTH
compulsory keyword the bandwidths for kernel density estimation
=0.05
LOGWEIGHTS
list of actions that calculates log weights that should be used to weight configurations when calculating averages
=as hhpsi: HISTOGRAM
ARG
the input for this action is the scalar output from one or more other actions.
=psi
STRIDE
compulsory keyword ( default=1 ) the frequency with which the data should be collected and added to the quantity being averaged
=10
GRID_MIN
compulsory keyword the lower bounds for the grid
=-pi
GRID_MAX
compulsory keyword the upper bounds for the grid
=pi
GRID_BIN
the number of bins for the grid
=600
BANDWIDTH
compulsory keyword the bandwidths for kernel density estimation
=0.05
LOGWEIGHTS
list of actions that calculates log weights that should be used to weight configurations when calculating averages
=as ffphi: CONVERT_TO_FES
GRID
compulsory keyword the action that creates the input grid you would like to use
=hhphi
TEMP
the temperature at which you are operating
=298 ffpsi: CONVERT_TO_FES
GRID
compulsory keyword the action that creates the input grid you would like to use
=hhpsi
TEMP
the temperature at which you are operating
=298 DUMPGRID
GRID
compulsory keyword the action that creates the grid you would like to output
=ffphi
FILE
compulsory keyword ( default=density ) the file on which to write the grid.
=ffphi.dat DUMPGRID
GRID
compulsory keyword the action that creates the grid you would like to output
=ffpsi
FILE
compulsory keyword ( default=density ) the file on which to write the grid.
=ffpsi.dat PRINT
ARG
the input for this action is the scalar output from one or more other actions.
=phi,psi
FILE
the name of the file on which to output these quantities
=colvar.dat
STRIDE
compulsory keyword ( default=1 ) the frequency with which the quantities of interest should be output
=10

If you have time you can extend this in two-dimensions using at the same time the phi and psi collective variables.