Molecular

GROMACS

Molecular dynamics simulation package for biomolecular systems

GROMACS is a versatile package for molecular dynamics simulations, primarily designed for simulations of proteins, lipids, and nucleic acids. It is free, open-source software licensed under the GNU Lesser General Public License.

Overview

GROMACS provides extremely high performance compared to other molecular dynamics software. It supports GPU acceleration and scales efficiently to hundreds of processors.

Key Features:

  • High-performance MD simulations
  • GPU acceleration (CUDA/OpenCL)
  • Advanced force fields (AMBER, CHARMM, OPLS)
  • Free energy calculations
  • Trajectory analysis tools
  • Parallel scaling across multiple nodes

Docker Compose Configuration

version: '3.8'

services:
  gromacs:
    image: gromacs/gromacs:2023
    container_name: dxflow-gromacs

    # Working directory
    working_dir: /workspace

    # Mount volumes
    volumes:
      - ./input:/workspace/input:ro
      - ./output:/workspace/output
      - ./mdp:/workspace/mdp:ro

    # GPU support (optional)
    deploy:
      resources:
        limits:
          cpus: '16'
          memory: 32G
        reservations:
          devices:
            - driver: nvidia
              count: 1
              capabilities: [gpu]

    # Keep container running for interactive use
    command: tail -f /dev/null

Usage

Step 1: Prepare System

Upload your input files:

# Create directories
mkdir -p input output mdp

# Upload protein structure
dxflow fs upload protein.pdb input/

# Upload topology files
dxflow fs upload topol.top input/
dxflow fs upload posre.itp input/

# Upload MDP parameter files
dxflow fs upload em.mdp mdp/         # Energy minimization
dxflow fs upload nvt.mdp mdp/        # NVT equilibration
dxflow fs upload npt.mdp mdp/        # NPT equilibration
dxflow fs upload md.mdp mdp/         # Production MD

Step 2: Deploy Workflow

# Deploy GROMACS container
dxflow compose create --identity gromacs-sim gromacs.yml
dxflow compose start gromacs-sim

Step 3: Run Simulation

Execute GROMACS commands in the container:

# Generate topology
dxflow compose execute gromacs-sim -- \
  gmx pdb2gmx -f input/protein.pdb -o output/processed.gro -water spce

# Define simulation box
dxflow compose execute gromacs-sim -- \
  gmx editconf -f output/processed.gro -o output/newbox.gro -c -d 1.0 -bt cubic

# Solvate system
dxflow compose execute gromacs-sim -- \
  gmx solvate -cp output/newbox.gro -cs spc216.gro -o output/solv.gro -p topol.top

# Add ions
dxflow compose execute gromacs-sim -- \
  gmx grompp -f mdp/ions.mdp -c output/solv.gro -p topol.top -o output/ions.tpr

dxflow compose execute gromacs-sim -- \
  gmx genion -s output/ions.tpr -o output/solv_ions.gro -p topol.top -pname NA -nname CL -neutral

# Energy minimization
dxflow compose execute gromacs-sim -- \
  gmx grompp -f mdp/em.mdp -c output/solv_ions.gro -p topol.top -o output/em.tpr

dxflow compose execute gromacs-sim -- \
  gmx mdrun -v -deffnm output/em

# NVT equilibration
dxflow compose execute gromacs-sim -- \
  gmx grompp -f mdp/nvt.mdp -c output/em.gro -r output/em.gro -p topol.top -o output/nvt.tpr

dxflow compose execute gromacs-sim -- \
  gmx mdrun -v -deffnm output/nvt

# NPT equilibration
dxflow compose execute gromacs-sim -- \
  gmx grompp -f mdp/npt.mdp -c output/nvt.gro -r output/nvt.gro -t output/nvt.cpt -p topol.top -o output/npt.tpr

dxflow compose execute gromacs-sim -- \
  gmx mdrun -v -deffnm output/npt

# Production MD
dxflow compose execute gromacs-sim -- \
  gmx grompp -f mdp/md.mdp -c output/npt.gro -t output/npt.cpt -p topol.top -o output/md.tpr

dxflow compose execute gromacs-sim -- \
  gmx mdrun -v -deffnm output/md -nb gpu

Step 4: Analysis

# RMSD analysis
dxflow compose execute gromacs-sim -- \
  gmx rms -s output/md.tpr -f output/md.xtc -o output/rmsd.xvg -tu ns

# RMSF analysis
dxflow compose execute gromacs-sim -- \
  gmx rmsf -s output/md.tpr -f output/md.xtc -o output/rmsf.xvg -res

# Radius of gyration
dxflow compose execute gromacs-sim -- \
  gmx gyrate -s output/md.tpr -f output/md.xtc -o output/gyrate.xvg

Step 5: Retrieve Results

# Download all output files
dxflow fs download output/ /local/results/

MDP Parameter Files

Energy Minimization (em.mdp)

; em.mdp - Energy minimization

integrator  = steep
emtol       = 1000.0
emstep      = 0.01
nsteps      = 50000

nstlist     = 10
cutoff-scheme = Verlet
ns_type     = grid
coulombtype = PME
rcoulomb    = 1.0
rvdw        = 1.0
pbc         = xyz

NVT Equilibration (nvt.mdp)

; nvt.mdp - NVT equilibration

define      = -DPOSRES
integrator  = md
nsteps      = 50000
dt          = 0.002

nstenergy   = 500
nstlog      = 500
nstxout-compressed = 500

continuation = no
constraint_algorithm = lincs
constraints = h-bonds

cutoff-scheme = Verlet
ns_type     = grid
nstlist     = 10
rcoulomb    = 1.0
rvdw        = 1.0

coulombtype = PME
pme_order   = 4
fourierspacing = 0.16

tcoupl      = V-rescale
tc-grps     = Protein Non-Protein
tau_t       = 0.1 0.1
ref_t       = 300 300

pcoupl      = no
pbc         = xyz

gen_vel     = yes
gen_temp    = 300
gen_seed    = -1

NPT Equilibration (npt.mdp)

; npt.mdp - NPT equilibration

define      = -DPOSRES
integrator  = md
nsteps      = 50000
dt          = 0.002

nstenergy   = 500
nstlog      = 500
nstxout-compressed = 500

continuation = yes
constraint_algorithm = lincs
constraints = h-bonds

cutoff-scheme = Verlet
ns_type     = grid
nstlist     = 10
rcoulomb    = 1.0
rvdw        = 1.0

coulombtype = PME
pme_order   = 4
fourierspacing = 0.16

tcoupl      = V-rescale
tc-grps     = Protein Non-Protein
tau_t       = 0.1 0.1
ref_t       = 300 300

pcoupl      = Parrinello-Rahman
pcoupltype  = isotropic
tau_p       = 2.0
ref_p       = 1.0
compressibility = 4.5e-5

pbc         = xyz

gen_vel     = no

Production MD (md.mdp)

; md.mdp - Production MD

integrator  = md
nsteps      = 50000000  ; 100 ns
dt          = 0.002

nstenergy   = 5000
nstlog      = 5000
nstxout-compressed = 5000
compressed-x-grps = System

continuation = yes
constraint_algorithm = lincs
constraints = h-bonds

cutoff-scheme = Verlet
ns_type     = grid
nstlist     = 10
rcoulomb    = 1.0
rvdw        = 1.0

coulombtype = PME
pme_order   = 4
fourierspacing = 0.16

tcoupl      = V-rescale
tc-grps     = Protein Non-Protein
tau_t       = 0.1 0.1
ref_t       = 300 300

pcoupl      = Parrinello-Rahman
pcoupltype  = isotropic
tau_p       = 2.0
ref_p       = 1.0
compressibility = 4.5e-5
refcoord_scaling = com

pbc         = xyz

gen_vel     = no

System Requirements

CPU-Only:

  • CPU: 16+ cores
  • RAM: 32GB minimum
  • Storage: 500GB SSD

GPU-Accelerated (Recommended):

  • CPU: 8-16 cores
  • GPU: NVIDIA RTX 3090, A100
  • RAM: 32-64GB
  • Storage: 1TB NVMe SSD

HPC Cluster:

  • Multiple GPU nodes
  • High-speed interconnect
  • Parallel filesystem

Performance Tips

GPU Acceleration:

  • Use -nb gpu flag for neighbor list on GPU
  • Use -pme gpu for PME calculations on GPU
  • Use -bonded gpu for bonded interactions on GPU
  • Monitor GPU utilization with nvidia-smi

Parallel Execution:

# MPI parallelization
mpirun -np 16 gmx_mpi mdrun -v -deffnm md

# Thread-MPI (automatic)
gmx mdrun -v -deffnm md -ntmpi 4 -ntomp 4

Optimization:

  • Use -tunepme yes for automatic PME tuning
  • Adjust -nstlist for optimal neighbor list updates
  • Use Verlet cutoff scheme for better performance
  • Enable LINCS for constraint algorithms

Troubleshooting

Simulation crashes:

  • Check energy minimization convergence
  • Reduce time step if system is unstable
  • Check for bad contacts in structure
  • Verify topology is correct

Poor performance:

  • Check GPU utilization
  • Optimize domain decomposition
  • Adjust PME grid spacing
  • Monitor load balancing

Memory errors:

  • Reduce system size
  • Increase available RAM
  • Use trajectory compression
  • Write less frequently to disk

Analysis Tools

GROMACS provides comprehensive analysis tools:

# Energy analysis
gmx energy -f md.edr -o energy.xvg

# Hydrogen bonds
gmx hbond -f md.xtc -s md.tpr -num hbond.xvg

# Secondary structure (DSSP required)
gmx do_dssp -f md.xtc -s md.tpr -o ss.xpm

# Distance analysis
gmx distance -f md.xtc -s md.tpr -select 'resname LYS and name CA' -oall dist.xvg

# Cluster analysis
gmx cluster -f md.xtc -s md.tpr -method gromos -cutoff 0.2

References

Citation

Abraham, M.J., Murtola, T., Schulz, R., Páll, S., Smith, J.C., Hess, B., Lindahl, E. (2015).
GROMACS: High performance molecular simulations through multi-level parallelism from laptops to supercomputers.
SoftwareX, 1-2, 19-25.

Need help? Check the GROMACS manual or community forums for detailed guidance.