Today we are going to go through how to calculate the radial distribution function (RDF) in Gromacs of MOL1 with a lithium ion as a reference. For this, both the .tpr and .trr files obtained from a npt run are required to create a .xtc file. After the .xtc is obtained, one can calculate the RDF of this system:

 
#!/bin/bash
#SBATCH -J test # Job name
#SBATCH -n 1 # Number of total cores
#SBATCH -N 1 # Number of nodes
#SBATCH -A name
#SBATCH -p cpu
#SBATCH -t 2-00:00:00
#SBATCH --mem-per-cpu=6000 # Memory pool for all cores in MB
#SBATCH -e test_%j.err
#SBATCH -o test_%j.out # File to which STDOUT will be written %j is the job #
echo "Job started on `hostname` at `date`"
module load openmpi
spack load gromacs
set -e

echo "0" |srun --mpi=pmix gmx_mpi trjconv -s nptrun.tpr -f nptrun.trr -o nptrun.xtc
echo " "
srun --mpi=pmix gmx_mpi rdf -s nptrun.tpr -f nptrun.xtc -o rdf_Li-MOL1.xvg -ref 'Li' -sel 'MOL1'
echo " "
echo "Job Ended at `date`"

Here -ref is the reference atom that correspond to the zero of the x-axis of the RDF. Then, -sel is the molecule of interest. To create the RDF, the .tpr and .xtc files are required and a .xvg is the output. The .xvg output can be read using a text editor. In that file, we first have lines that start with # then with @. Those line are not required to graph the result. After those line, two columns are present which represent the x-axis and the y-axis of the RDF. Those column can then be used to graph the results.