Introduction to PLUMED
Facility:
I'm not going to lie, this gets a bit annoying, you need to connect it to your MD engine. If you're not interested in GROMACS as an MD engine, here's a link to Plumed's main page, because the installation is up to you:
Otherwise, here's how to install and patch them accordingly. Follow all of these commands if you don't have any, but skip installing GROMACS if you already have it installed and running. These commands need to be run one by one in your terminal/command line.
#Download GROMACS
wget http://ftp.gromacs.org/pub/gromacs/gromacs-2021.2.tar.gz
tar xfz gromacs-2021.2.tar.gz
cd gromacs-2021.2#Install and source GROMACS
mkdir build
cd build
cmake .. -DGMX_BUILD_OWN_FFTW=ON -DREGRESSIONTEST_DOWNLOAD=ON
make
sudo make install
source /usr/local/gromacs/bin/GMXRC
#Download PLUMED
wget https://github.com/plumed/plumed2/releases/download/v2.7.1/plumed-2.7.1.tgz
tar xfz plumed-2.7.1.tgz
cd plumed-2.7.1
#install PLUMED
./configure --prefix=/usr/local/plumed
make
sudo make install
#Patch GROMACS
cd gromacs-2021.2
plumed patch -p
#rebuilld GROMACS
cd build
cmake .. -DGMX_BUILD_OWN_FFTW=ON -DREGRESSIONTEST_DOWNLOAD=ON -DGMX_PLUMED=on
make
sudo make install
#Check installation
gmx mdrun -plumed
You'll notice that I've chosen an older version of gromacs – this is just to give us a better chance of not having any unforeseen errors in these articles, you're more than welcome to use a newer version at your discretion, just make sure it's compatible with PLUMED.
Basic configuration:
- Create a PLUMED input file to define the collective variables (CV) that describe the important degrees of freedom of the system.
Here is an example file. I will go into more detail about some more sophisticated options in Part 3 of this article series, but for now we will start by looking at the conformational state of a set of atoms using distance and torsion as our CVs. Other potential CVs include distances between atoms, angles, dihedrals, or more complex functions.
# Define collective variables
# Distance between atoms 1 and 10
DISTANCE ATOMS=1,10 LABEL=d1# Dihedral angle involving atoms 4, 6, 8, and 10
TORSION ATOMS=4,6,8,10 LABEL=t1
# Print collective variables to a file
PRINT ARG=d1,t1 FILE=COLVAR STRIDE=100
# Apply metadynamics bias
METAD ...
ARG=d1,t1 # The collective variables to bias
PACE=500 # Add a Gaussian hill every 500 steps
HEIGHT=0.3 # Height of the Gaussian hill
SIGMA=0.1,0.1 # Width of the Gaussian hill for each CV
FILE=HILLS # File to store the hills
BIASFACTOR=10 # Bias factor for well-tempered metadynamics
TEMP=300 # Temperature in Kelvin
... METAD
# Print the bias potential to a file
PRINT ARG=d1,t1,bias FILE=BIAS STRIDE=500
The comments in that block of code should be extensive enough for a basic understanding of everything that's going on, but I'll cover all of this in article 3, and we'll even dive into complex functions!
Anyway, once you have this input file (usually called plumed.dat) and the .tpr file needed for an MD run using GROMACS (see the gmx grompp documentation to generate that file), you can run the metadynamics simulation by going to the working directory and typing on the command line:
gmx mdrun -s topol.tpr -plumed plumed.dat
Both PLUMED and GROMACS accept additional arguments. I'll go over some of the most useful ones for both in Part 3 of this article series, along with some of the scripts I've written for more advanced executions. You can check out the documentation for others.
After the simulation, use PLUMED's analysis tools to reconstruct the free energy surface and identify the relevant metastable states and transition pathways. The most commonly used tool is PLUMED. sum_hills
tool for reconstructing the free energy surface.
You can take a look at the free energy surface (FES) after that command using this Python code which will tell you how the values of one CV relate to the other.
import matplotlib.pyplot as plt
import numpy as np
import plumed
from matplotlib import cm, ticker# Configure font
plt.rc('font', weight='normal', size=14)
# Read data from PLUMED output
data = plumed.read_as_pandas("/path/to/COLVAR")
# Extract and reshape data for contour plot
# Adjust the reshape parameters as needed, They should multiply to the
# number of bins and be as close to each other as possible
d1 = data("d1").values.reshape(-1, 100)
t1 = data("t1").values.reshape(-1, 100)
bias = data("bias").values.reshape(-1, 100)
# Plot contour lines
plt.contour(d1, t1, bias, levels=np.arange(np.min(bias), np.max(bias), 10), linewidths=0.3, colors='k')
# Plot filled contour
cntr = plt.contourf(d1, t1, bias, levels=np.arange(0, 100), cmap=cm.jet)
# Add colorbar
plt.colorbar(cntr, label="\u0394G (kJ/mol)")
# Set plot limits and labels
plt.xlim(np.min(d1), np.max(d1))
plt.ylim(np.min(t1), np.max(t1))
plt.xlabel("Distance between atoms 1 and 10 (d1) (nm)")
plt.ylabel("Dihedral angle involving atoms 4, 6, 8, and 10 (t1) (degrees)")
# Show plot
plt.show()
The result should look similar to the topographical chart I posted above (I can't tell you what your FES will look like because you were free to choose your own system).
You should also visualize the results using popular visualization software such as VMD to gain insight into molecular behavior in low-energy and metastable states.
Conclusion
Metadynamics, powered by PLUMED, offers a robust framework for exploring complex molecular systems. By efficiently sampling the free energy landscape, we can uncover hidden mechanisms in molecular systems that cannot be achieved through traditional molecular dynamics due to computational limitations.
Whether you are a novice or an experienced researcher, mastering PLUMED can significantly improve your computational chemistry toolset, so be sure to check out my next two articles to help you go from beginner to expert.
Article 2 will reveal the mathematical concepts behind adding metadynamics components to an MD engine, and Article 3 will expose you to advanced techniques in metadynamics such as multi-walker metadynamics, condensing more than 2 variables into a readable format, utilizing metadynamics on high-performance clusters, and deeper analytical techniques to quantitatively visualize and analyze your system's results (with plenty of sample code).