Skip to content

GROMACS

What is GROMACS?

GROMACS is a high-performance molecular dynamics (MD) simulation package primarily designed for biochemical molecules such as proteins, lipids, and nucleic acids. It is widely used in computational chemistry and biophysics for simulating the physical movements of atoms and molecules.

Base Environment

GROMACS is provided via the environment modules system.

Available Builds

Two builds are available depending on your hardware requirements:

Module Binaries Available On
gromacs/2024.4-cpu gmx, gmx_mpi All nodes (login, CPU, GPU)
gromacs/2024.4-gpu gmx_gpu_mpi GPU nodes only (gpu01–gpu26)
Binary Description
gmx Serial / OpenMP (single node, shared memory)
gmx_mpi MPI + OpenMP (multi-process, CPU only)
gmx_gpu_mpi MPI + CUDA (GPU-accelerated, H200)

gmxapi not included

The Python interface (gmxapi) is not part of the system installation. Users who require it can install it independently via conda.

Loading GROMACS

CPU build (all nodes)

module load gromacs/2024.4-cpu
gmx --version
gmx_mpi --version

GPU build (GPU nodes only)

module load gromacs/2024.4-gpu
gmx_gpu_mpi --version

List available versions

module spider gromacs

Typical Workflow

A standard GROMACS simulation consists of two steps:

  1. Preprocessinggrompp reads your topology, coordinates, and run parameters and produces a binary run input file (.tpr)
  2. Runningmdrun executes the simulation using the .tpr file
# Step 1: Prepare run input
gmx grompp -f run.mdp -c conf.gro -p topol.top -o simulation.tpr

# Step 2: Run simulation
gmx mdrun -s simulation.tpr -deffnm output

CPU Jobs

Serial / OpenMP

Use gmx mdrun with -ntmpi 1 and -ntomp <threads> for single-node shared-memory runs.

gromacs_cpu.sh

Serial/OpenMP job

#!/bin/bash
#SBATCH --job-name=gromacs_cpu
#SBATCH --partition=CPU
#SBATCH --nodes=1
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=8
#SBATCH --time=01:00:00
#SBATCH --output=gromacs_%j.out

module load gromacs/2024.4-cpu

# This example uses the GROMACS water box benchmark.
# For your own simulation, replace the wget/tar/cd steps with your
# own .mdp, .gro, and .top files and update the grompp command accordingly.
wget -q https://ftp.gromacs.org/pub/benchmarks/water_GMX50_bare.tar.gz
tar -xzf water_GMX50_bare.tar.gz
cd water-cut1.0_GMX50_bare/1536

gmx grompp -f pme.mdp -c conf.gro -p topol.top -o simulation.tpr -maxwarn 2

gmx mdrun -ntmpi 1 -ntomp $SLURM_CPUS_PER_TASK \
    -s simulation.tpr -deffnm output

MPI + OpenMP

Use gmx_mpi mdrun via srun for multi-process runs. Each MPI rank gets --cpus-per-task OpenMP threads.

gromacs_mpi.sh

MPI + OpenMP job

#!/bin/bash
#SBATCH --job-name=gromacs_mpi
#SBATCH --partition=CPU
#SBATCH --nodes=1
#SBATCH --ntasks=8
#SBATCH --cpus-per-task=4
#SBATCH --time=01:00:00
#SBATCH --output=gromacs_mpi_%j.out

module load gromacs/2024.4-cpu

# This example uses the GROMACS water box benchmark.
# For your own simulation, replace the wget/tar/cd steps with your
# own .mdp, .gro, and .top files and update the grompp command accordingly.
wget -q https://ftp.gromacs.org/pub/benchmarks/water_GMX50_bare.tar.gz
tar -xzf water_GMX50_bare.tar.gz
cd water-cut1.0_GMX50_bare/1536

gmx grompp -f pme.mdp -c conf.gro -p topol.top -o simulation.tpr -maxwarn 2

srun gmx_mpi mdrun -ntomp $SLURM_CPUS_PER_TASK \
    -s simulation.tpr -deffnm output

MPI layout

Total cores used = --ntasks × --cpus-per-task. Adjust the ratio depending on your system size — more MPI ranks benefit large systems, more OpenMP threads reduce communication overhead.

GPU Jobs

Use gmx_gpu_mpi from the GPU build to offload computation to NVIDIA H200 GPUs.

gromacs_gpu.sh

GPU job (single GPU)

#!/bin/bash
#SBATCH --job-name=gromacs_gpu
#SBATCH --partition=GPU
#SBATCH --nodes=1
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=8
#SBATCH --gres=gpu:1
#SBATCH --time=01:00:00
#SBATCH --output=gromacs_gpu_%j.out

module load gromacs/2024.4-gpu

# This example uses the GROMACS ADH (Alcohol Dehydrogenase) protein benchmark.
# For your own simulation, replace the wget/tar/cd steps with your
# own .mdp, .gro, and .top files and update the grompp command accordingly.
wget -q https://ftp.gromacs.org/pub/benchmarks/ADH_bench_systems.tar.gz
tar -xzf ADH_bench_systems.tar.gz
cd ADH/adh_cubic

gmx_gpu_mpi grompp -f pme_verlet.mdp -c conf.gro -p topol.top \
    -o simulation.tpr -maxwarn 2

srun gmx_gpu_mpi mdrun -ntomp $SLURM_CPUS_PER_TASK \
    -s simulation.tpr -deffnm output \
    -nb gpu -pme gpu -bonded gpu -update gpu

GPU offload flags

Flag Description
-nb gpu Non-bonded interactions on GPU
-pme gpu PME electrostatics on GPU
-bonded gpu Bonded interactions on GPU (requires suitable force field)
-update gpu Coordinate update and constraints on GPU

Multi-rank GPU PME

When using multiple MPI ranks with -pme gpu, you must explicitly specify the number of PME ranks:

srun gmx_gpu_mpi mdrun -npme 1 -nb gpu -pme gpu ...
Without -npme, GROMACS will abort with an error.

-bonded gpu compatibility

-bonded gpu is not supported for all system types. Pure water systems and some older force fields do not have GPU-compatible bonded implementations. If you encounter an error, remove -bonded gpu and bonded interactions will run on the CPU in parallel with GPU execution.

Output Files

File Description
*.tpr Binary run input (topology + coordinates + parameters)
*.edr Energy file — view with gmx energy
*.trr Full-precision trajectory
*.xtc Compressed trajectory
*.gro Final coordinates
*.log Detailed mdrun log including performance summary
*.cpt Checkpoint file for restarting runs

Monitoring Performance

GROMACS reports simulation performance at the end of each run:

Performance:    419.214 ns/day    0.057 hour/ns

This is found in the .log file or in the job output. Higher ns/day means faster simulation.

More Information

Documentation

Official GROMACS documentation:

https://manual.gromacs.org/current/