Getting Started with PLUMED
Installation:
Not gonna lie, this gets a little annoying, it needs to be patched into your MD engine. If you’re not interested in GROMACS as your MD engine, here’s a link to the plumed main page because you’re on your own regarding installation:
Otherwise, here’s how to install them both and properly patch them. Follow all of these commands if you have neither but ignore the GROMACS installation if you already have it installed and working. These commands should be executed 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 I’ve picked an older version of gromacs; this is just to give us a better chance that there are no unforseen bugs moving through these articles, you’re more than welcome to use a more recent version at your discretion, just make sure that it’s PLUMED-compatible.
Basic Configuration:
- Create a PLUMED input file to define the collective variables (CVs) that describe the system’s important degrees of freedom.
Here’s an example file. I’ll go into more detail on some fancier options in Part 3 of this article series, but for now we’ll start by looking at the conformational state of a set of atoms by 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 code block should be extensive enough for a basic understanding of everything going on, but I’ll get to all of this in article 3, and we’ll even delve beyond into complex functions!
Anyway, once you have this input file (typically named plumed.dat) and the .tpr file required for an MD run using GROMACS (look at gmx grompp documentation for generating that file), you can run the metadynamics simulation by going to the working directory and typing into the command line:
gmx mdrun -s topol.tpr -plumed plumed.dat
Both PLUMED and GROMACS accept extra arguments. I’ll go over some of the more useful ones for both in Part 3 of this series of articles along with some of the scripts I’ve written for more advanced runs, and you can look at the documentation for any others.
After the simulation, use PLUMED’s analysis tools to reconstruct the free energy surface and identify relevant metastable states and transition pathways. Most ubiquitous is the use of PLUMED’s sum_hills
tool to reconstruct 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 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 output should look similar to the topographical graph I posted earlier on (I can’t give you what your FESwill look like because you had the freedom of choosing your own system).
You should also visualize the results using popular visualization software like VMD to gain insights into the 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 can’t be achieved through traditional MD due to computational constraints.
Whether you are a novice or an experienced researcher, mastering PLUMED can significantly enhance your computational chemistry toolkit, so don’t forget to check out my upcoming two articles to help you go from beginner to expert!
Article 2 will unveil the mathematical concepts behind adding metadynamics components to an MD engine, and Article 3 will expose you to advanced techniques in metadynamics such as multiple walker metadynamics, condensing more than 2 variables into a readable format, utilizing metadynamics on high-performance clusters, and more in-depth analytical techniques to visualize and quantitatively analyze your system results (with plenty of sample code).