# Gromacs Md

> Automate GROMACS molecular dynamics (MD) simulations end-to-end. Use when the user wants to set up, run, debug, or analyze MD simulations with GROMACS/gmx, including protein, protein-ligand, peptide, nucleic-acid, or membrane systems; build topologies and .mdp files; run pdb2gmx, solvate, genion, grompp, mdrun; perform energy minimization, NVT/NPT equilibration, and production runs with GPU acceleration; analyze trajectories (RMSD, RMSF, Rg, hydrogen bonds, contacts, free energy); or troubleshoot GROMACS errors. Also triggered by Chinese requests containing GROMACS, gmx, or 分子动力学模拟, and Japanese requests containing 分子動力学シミュレーション.

- Skill: `huc-he/gromacs-md` (Agent Skill, multi-file: 7 files)
- Install (CLI): `npx skillmds@latest add huc-he/gromacs-md`
- Raw SKILL.md: https://api.skillmd.com/api/skills/huc-he/gromacs-md/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: HUC-he (https://skillmd.com/u/huc-he)
- Updated: 2026-09-22
- Page: https://skillmd.com/skills/huc-he/gromacs-md

---


# GROMACS MD Automation

## Goal

Take a user's system description and structure, then run a scientifically sound GROMACS MD simulation with minimal back-and-forth and report the results.

## Language

Users may write in Chinese (中文), English, or Japanese (日本語). Respond in the language the user uses.

## Workflow

### 0. Collect inputs (ask only for what is missing)

- System type: protein / protein-ligand / nucleic acid / membrane / other
- Structure: PDB ID, PDB file, or ligand SMILES/SDF (sequence-only -> suggest AlphaFold modeling first)
- Goal: stability, conformational change, binding, free energy, etc.
- Optional preferences: force field, water model, temperature (default 310 K), simulation length (default 100 ns), salt concentration

See references/workflow.md for the input table and default choices. Do not block on optional preferences; use the defaults.

### 1. Verify environment

Run:

- `gmx --version` (expect `GPU support: CUDA` and GROMACS >= 2024)
- `nvidia-smi` (GPU visible)

If missing or broken, fix the environment first (references/workflow.md, Environment section).

### 2. Create the project directory

- Create `~/md_projects/<project>/` inside WSL. Never run large simulations on `/mnt/c` (slow I/O).
- Use subdirectories: `top/`, `em/`, `nvt/`, `npt/`, `md/`, `analysis/`.

### 3. Build topology and solvate (per system type)

- Protein/peptide: `gmx pdb2gmx` with the chosen force field; check termini, disulfides, and missing atoms.
- Protein-ligand: parameterize the ligand first (acpype/GAFF2 for AMBER, CGenFF for CHARMM), merge with the protein, and verify residue names/charges.
- Nucleic acid: `pdb2gmx` supports DNA/RNA with AMBER or CHARMM force fields.
- Membrane: prepare with CHARMM-GUI or insane.py, then follow the membrane notes in references/workflow.md.

Then run `editconf -d 1.0`, `solvate`, and `genion` (neutralize, default 0.15 M NaCl). See references/workflow.md for exact commands.

### 4. Energy minimization

- `grompp` with assets/templates/em.mdp, then `mdrun`.
- Acceptance: potential energy negative and converged (Fmax < 1000 kJ/mol/nm), no LINCS warnings.

### 5. Equilibration

- NVT (100 ps) then NPT (100 ps) with position restraints on heavy atoms.
- Use assets/templates/nvt.mdp and npt.mdp; adjust `tc-grps` to the actual groups in the system.
- Acceptance: temperature and pressure stable near targets, no explosions.

### 6. Production MD

- Use assets/templates/md.mdp; set `nsteps` for the requested time.
- Run on GPU:

```bash
gmx mdrun -deffnm md -nb gpu -pme gpu -update gpu -bonded gpu
```

- Drop `-bonded gpu` for systems without GPU-supported bonded types.
- Check the first ~1 ns: energy, temperature, pressure, RMSD drift.

### 7. Analysis

- Core analyses: `gmx rms`, `rmsf`, `gyrate`, `hbond`, `energy`, distances/contacts.
- Free-energy methods (umbrella sampling, gmx_MMPBSA, FEP) only when explicitly requested; confirm with the user because they are long and method-sensitive.
- Produce plots (matplotlib or xmgrace). Verify convergence before interpreting.

### 8. Report

Summarize: system, protocol (force field, water model, ions, time), GPU performance, key results (RMSD/RMSF/Rg/hydrogen bonds), equilibrium status, and caveats. Suggest next steps.

## Rules

- Never fabricate results; only report numbers from actual output files.
- Validate every `mdrun` completion: check for `Finished mdrun` and scan the log for fatal warnings.
- Scientific validity matters: ask when the force field or other choices would materially change the result.
- Keep raw trajectories (.xtc) and logs; all analysis must be reproducible.

## Resources

- references/workflow.md - detailed commands per system type, recipes, and common errors
- assets/templates/*.mdp - ready-to-use EM/NVT/NPT/production parameter files

