Using energy groups in Gromacs
Computing energies of groups within a simulation is useful for measuring energies of a specific molecule or testing changes in forcefield parameters. In this tutorial, we will go through computing Lennard-Jones (LJ) energies of a particular group in a simulation from Gromacs, summarized below:
Goals of this tutorial
At the end of this tutorial, you should be able to:
Visualize the system using visual molecular dynamics (VMD) studio
Generate energy groups from molecular dynamics parameter (mdp) files
Using the energy groups, compute Lennard-Jones energies using "gmx -rerun" command
Software required for this tutorial
Bash terminal: Main language used to run code
On Mac: Command + space, type in "Terminal" and hit enter
On Windows 10:
Install gitbash: https://gitforwindows.org/
Alternatively, use the ubuntu add-on: https://www.omgubuntu.co.uk/2016/08/enable-bash-windows-10-anniversary-update
Gromacs: Simulation package [Link for installation] (Version 2016)
Visual molecular dynamics studio (VMD, optional) [Link]: Used to visualize simulations
Files for this tutorial
All input/output files are downloadable through GitLab [Link]. To download, click the "Download" button and select "Download this directory".
P_in_S-PET_trimer-acetone-300_K: Simulation folder containing trajectories.
"poly_solv_prod*" prefix contains 10 ns production trajectories in the NPT ensemble
poly_solv.top: topology file for the system
prod.mdp: mdp file for production run
images: Contains images used for this tutorial
Description of system
Simulation trajectories contain a poly(ethylene terephthalate) (PET) trimer in acetone. PET is a common moiety in multilayer plastics that affords rigidity and would be useful to recycle as described in this link. Simulations of PET could capture different configurations that could be analyzed for solubility in different solvents using the COSMO-RS software package.
Visualizing the system (Optional)
To visualize the system, open VMD and run the command:
(Note, your path may be different, marked in blue)
The image on the right shows the PET trimer in acetone; each monomer is colored in red, black, and blue. We would like to compute the LJ interactions for PET with itself and PET-acetone.
The image shows the output of "gmx energy" outputted in a typical Gromacs energy file (denoted as *.edr).
By default, Gromacs does not output energies of specific groups. The procedure below will show you how to define energy groups, then compute energies between energy groups.
Step 1: Defining energy groups using gmx make_ndx
Run the following command in terminal to generate an index file containing PET trimer:
The command will create an index file with PET trimer (i.e. PT3) and acetone (ACE) as separate groups.
Step 2: Edit MDP file to include energy groups
The following function edits the production mdp file (prod.mdp) and adds specific energy groups; copy and paste this into terminal or include this as part of your ~/.bashrc
Then, add PET and ACE as an energy group by running:
This function copies prod.mdp into a new file called prod_energy_groups.mdp and adds energy groups to the bottom:
Step 3: Create a new *.tpr file with the new *.mdp file and rerun Gromacs
Gromacs needs a new *.tpr file with the energy groups, so create it using grompp:
This should create a new file called "poly_solv_prod_energy_groups.tpr". Then, perform mdrun again using the "-rerun" flag:
Step 4: Re-run "gmx energy" to get output of energy groups
Now, you have new energy groups:
"LJ-SR:PT3-PT3" - Lennard-Jones short-ranged interactions for PT3-PT3
"LJ-14:PT3-PT3" - Lennard-Jones 1,4-interactions for PT3-PT3
Ditto for ACE-ACE and PT3-ACE interactions. There are also coulomb terms (e.g. "Coul-SR"), but since the simulation was performed with Particle Mesh Ewald (PME) summation to quantify coulombic interactions, they cannot be decoupled as described in this Link.
Selecting "LJ-SR:PT3-PT3" will output LJ energies as a function of time, which might be useful to quantify things like solute-solvent interactions or quantify changes to LJ energies when modifying forcefields.
Now, you should be able to generate energy groups and re-compute energies with the "-rerun" command in Gromacs. This tool is useful for computing energies between solute-solvents and for checking changes in energies when modifying forcefield parameters.
Best of luck computing energies in Gromacs!