科研 Skill

GROMACS分子动力学工作流

gromacs-workflow

Covers end-to-end MD simulations with GROMACS: topology/.mdp construction, energy minimization, NVT/NPT equilibration. Use for GROMACS-based biomolecular or materials MD.

发布者 Codar安全审核通过v0.1.0更新于 2026-11-18

SKILL.md

GROMACS Workflow

Description

This skill covers end-to-end molecular dynamics simulations using GROMACS: topology construction and the .top/.itp hierarchy, .mdp parameter anatomy for energy minimization, NVT, NPT, and production runs, the grompp → mdrun → analysis pipeline, cutoff and PME setup, thermostat and barostat selection, constraint algorithms (LINCS, SETTLE), force-field compatibility (AMBER, CHARMM, OPLS-AA, GROMOS, Martini), HPC execution with MPI/OpenMP/GPU offload, and restart continuation. GROMACS is the standard tool for biomolecular and soft-matter simulations and is the reference code for AMBER, CHARMM36, and OPLS-AA force fields. Invoke this skill when setting up, running, diagnosing, or extending any GROMACS simulation.

Domain Context

GROMACS integrates Newton's equations of motion using a leap-frog Verlet integrator (the md integrator) or stochastic dynamics (sd). Its distinctive architecture separates the run-input file (.tpr, compiled from topology + mdp + coordinates by grompp) from the raw inputs (.top, .mdp, .gro), which means all simulation parameters are locked into the binary .tpr before mdrun starts. This compile-then-run model makes GROMACS simulations highly reproducible but requires re-running grompp whenever any parameter changes.

Several domain assumptions govern GROMACS applicability:

  • Fixed topology: The bond list, angle list, dihedral list, and improper list are defined at the start of the simulation in the .top file and cannot change during the run. GROMACS is not a reactive MD code. Bond-breaking, proton transfer, and chemical reactions require reactive force fields (ReaxFF via PLUMED or an external code) or QM/MM.
  • Classical nuclei: GROMACS integrates classical equations of motion. Zero-point energy and nuclear tunneling are ignored. For proton dynamics at low temperature, path-integral extensions (GROMACS + i-PI) are required.
  • Long-range electrostatics are always present in biomolecular systems. Biomolecular and drug-like systems have partial charges on every atom. PME (Particle Mesh Ewald) is mandatory; a plain cutoff produces artifacts in electrostatic energy and forces that invalidate free energy calculations, solvation energies, and structural properties of charged systems.
  • Force-field and water-model pairing is non-negotiable. AMBER ff14SB was parameterized with TIP3P; CHARMM36m with mTIP3P (a modified TIP3P with different LJ parameters). Using TIP4P with ff14SB or TIP3P with CHARMM36m introduces systematic density and structural errors that cannot be corrected by re-equilibration.
  • GROMACS units: nm, kJ/mol, ps, K, bar. All .mdp distance parameters (rcoulomb, rvdw, rlist, box vectors) are in nanometres, not Ångströms. This is the single most frequent source of silently wrong input from users familiar with LAMMPS or AMBER.

When to Use This Skill

  • Biomolecular simulations: proteins, nucleic acids, lipid bilayers, carbohydrates, protein–ligand complexes in explicit solvent.
  • Organic molecular liquids, polymer melts, and soft-matter systems where AMBER, CHARMM, OPLS-AA, or GROMOS force fields have validated parameters.
  • Coarse-grained simulations using the Martini force field (Martini 2 or Martini 3) for membrane proteins, lipid self-assembly, or polymer systems at mesoscale.
  • Free energy perturbation and alchemical calculations (GROMACS has the most mature free-energy infrastructure among open-source MD codes).
  • Enhanced sampling with PLUMED: metadynamics, umbrella sampling, replica exchange MD.
  • Large-scale biomolecular simulations (10⁴–10⁷ atoms) where GROMACS GPU offload and PME scaling are required for throughput.

When Not to Use This Skill

  • Materials science simulations of metals, ceramics, or semiconductors. EAM, Tersoff, Stillinger-Weber, and COMB are not natively supported in GROMACS. Use LAMMPS for materials force fields. GROMACS can use these systems via PLUMED or external FF interfaces, but the workflow is non-standard.
  • Reactive MD (bond-breaking). Fixed topology precludes bond formation and breaking. Use LAMMPS with ReaxFF, or ML potentials in an appropriate code.
  • When a custom ML interatomic potential (MACE, NequIP, DeePMD) is the force field. GROMACS has no native MLP pair-style interface. Use LAMMPS (see mlp-to-lammps) or ASE for MLP-driven MD.
  • Very large inorganic systems (> 10⁶ atoms) where PME is a bottleneck. LAMMPS scales better for non-biomolecular systems because it can use truncated potentials without long-range electrostatics.
  • When only single-point energies and forces are needed. Use ASE with the relevant calculator; GROMACS requires a full .tpr compilation and mdrun invocation even for a single energy evaluation.

Core Concepts

  • .top (topology file): The top-level text file that defines the entire system: which force-field parameter files to include, which molecule types exist, and the number of each molecule type in the simulation box. The [ system ] section gives a human-readable name; [ molecules ] lists molecule name + count in the order they appear in the coordinate file. The atom count in [ molecules ] must exactly match the coordinate file.
  • .itp (include topology file): Modular topology fragment included into .top via #include. Contains one or more [ moleculetype ] definitions with [ atoms ], [ bonds ], [ angles ], [ dihedrals ], [ impropers ], and [ pairs ] sections. Force-field libraries are distributed as collections of .itp files (e.g., amber14sb.ff/aminoacids.itp, charmm36-jul2022.ff/proteins.itp).
  • .tpr (run input file): Binary file produced by grompp. Contains the complete simulation state: topology, mdp parameters, and starting coordinates. Once compiled, the .tpr cannot be edited; any change requires re-running grompp. The .tpr is the canonical input to mdrun and ensures reproducibility — the same .tpr always produces the same trajectory.
  • .mdp (molecular dynamics parameter file): Plain-text file specifying all simulation parameters: integrator, timestep, output frequencies, cutoffs, thermostat, barostat, constraints, and PME accuracy. One .mdp per stage (EM → NVT → NPT → production). Template .mdp files from CHARMM-GUI or the GROMACS manual are the recommended starting points.
  • .gro (coordinate file): GROMACS format for atomic positions (and optionally velocities), one atom per line, with box vectors at the end. Coordinates are in nanometres. Can be read by ASE and MDAnalysis. Not suitable for long trajectories (one frame only); use .xtc or .trr for trajectories.
  • .xtc (compressed trajectory): Single-precision lossy-compressed trajectory. Stores positions only; forces and velocities are not included. Standard format for long production runs. Readable by MDAnalysis, VMD, PyMOL, and OVITO.
  • .trr (full-precision trajectory): Full-precision trajectory storing positions, velocities, and forces at each saved frame. Required for: velocity-dependent observables (VACF, kinetic energy per molecule), free energy calculations, and restart checkpoints. Significantly larger than .xtc.
  • .edr (energy file): Binary file containing all thermodynamic observables (temperature, pressure, potential energy, kinetic energy, density, volume, box dimensions, and force-field energy terms) at every nstenergy steps. Parsed with gmx energy or the panedr Python library. This is the primary source for thermodynamic averages; do not use the .log file for analysis (it has lower precision).
  • .cpt (checkpoint file): Binary restart file written every nstcheckpoint steps (default: every hour of wall time). Contains full simulation state: positions, velocities, random number generator state, and simulation step counter. Use with gmx mdrun -cpi prefix.cpt to continue a run without loss of statistics.
  • grompp: Preprocessor that compiles .mdp + .top + .gro → .tpr. Performs extensive topology and parameter validation before the run starts. grompp warnings should be treated as errors — they indicate physical inconsistencies that will silently corrupt the simulation. Use -maxwarn 0 only when you understand every warning and have confirmed it is safe.
  • mdrun: The simulation engine. Reads a .tpr and produces .xtc / .trr, .edr, .log, .cpt, and final .gro. The most performance-critical step; uses MPI, OpenMP, and GPU offload.
  • LINCS (Linear Constraint Solver): GROMACS default constraint algorithm for bond-length constraints. Applied to bonds involving hydrogen (h-bonds setting) or all bonds (all-bonds). Implemented via a matrix factorization that is parallel-efficient and numerically stable. lincs-order = 4 is the default; increase to 6–8 for stiff bonds or large timesteps. LINCS replaces SHAKE for most GROMACS applications.
  • SETTLE: Analytical constraint algorithm for three-site rigid water models (TIP3P, SPC, SPC/E). Faster and more accurate than LINCS for three-point water. Applied automatically to all water molecules when constraints = h-bonds or higher and a rigid water model is used.
  • V-rescale thermostat (Bussi–Donadio–Parrinello): Stochastic velocity rescaling that generates the canonical (NVT) ensemble correctly. Temperature fluctuations follow the Maxwell-Boltzmann distribution. Recommended for production NVT. Replaces Berendsen for all production applications. tau-t = 0.1 ps is a typical coupling constant. [EXPERT REVIEW NEEDED]
  • Parrinello-Rahman barostat: Correct NPT ensemble; generates proper pressure fluctuations and compressibility. Requires pre-equilibrated density (start from Berendsen NPT if the system is far from equilibrium — P-R oscillates dangerously from cold starts). tau-p = 2.0 ps is typical for condensed-phase systems. [EXPERT REVIEW NEEDED]
  • Verlet cutoff scheme: GROMACS 2018+ exclusively uses the Verlet cutoff scheme with a buffer region determined by the verlet-buffer-tolerance parameter. The older group scheme was removed in GROMACS 2021. The Verlet scheme guarantees energy conservation and is required for GPU offload.

Key Workflows

Full steps for each part are in references/key-workflows/; open the one you need:

Common Failure Modes

Moved to references/common-failure-modes.md to keep this file short; read it when this part is needed.

Best Practices

  • Always use gmx grompp -maxwarn 0 for production runs. Every warning from grompp indicates a physical inconsistency. Investigate and fix each warning before submitting to a cluster. Increasing -maxwarn to suppress warnings without understanding them is the most common cause of silently wrong GROMACS simulations.
  • Use CHARMM-GUI for all non-trivial system construction. Manually building .top files for membrane proteins, protein-ligand complexes, or glycosylated systems is error-prone. CHARMM-GUI validates topology against the force-field database and provides consistent .mdp templates, index groups, and step-by-step scripts.
  • Verify atom count consistency at every step. After pdb2gmx, solvate, and genion, inspect the [ molecules ] section and compare the total atom count to the .gro file line count minus 3. One mismatch → grompp will reject the topology.
  • Pre-equilibrate with Berendsen barostat before switching to Parrinello-Rahman. Start every NPT simulation with pcoupl = Berendsen for 200–500 ps, then switch to Parrinello-Rahman. Parrinello-Rahman applied from a high-stress starting geometry oscillates uncontrollably and may crash the simulation. C-rescale (GROMACS 2021+) is an excellent alternative that converges quickly while producing the correct NPT ensemble.
  • Record the .tpr SHA-256 hash for every production run. The .tpr encodes the complete simulation specification (topology + parameters + starting coordinates) in a single binary file. The hash fully identifies the simulation for reproducibility purposes. Store it in the run directory README alongside the GROMACS version.
  • Run panedr analysis rather than gmx energy for thermodynamic averages. panedr reads .edr files directly into a pandas DataFrame, enabling block averaging, autocorrelation time estimation, and stationarity checks that the gmx energy .xvg output requires manual processing for. Install with pip install panedr.
  • Use gmx trjconv -pbc mol -center before any structural analysis. Trajectories from mdrun have molecules split across PBC boundaries. All RDF, RMSD, and SASA calculations require whole molecules. Apply the correction pipeline (Workflow 7) before any analysis and save the processed trajectory separately.
  • Match nstlist and rcoulomb to the Verlet buffer. Setting nstlist = 10 with rcoulomb = 1.2 nm gives a neighbor-list buffer of ~0.05 nm. If performance is critical, increase nstlist to 20–40 and let verlet-buffer-tolerance set the buffer automatically. Do not set nstlist = 1 in production — it is 5–10× slower with no accuracy benefit.
  • For HPC runs, always set -maxh to 1–2 hours below the job wall time. mdrun -maxh 23.5 for a 24-hour job ensures GROMACS writes a final checkpoint before the job is killed by the scheduler. Without -maxh, a job killed at the wall time may leave a corrupt or absent .cpt, forcing the entire run to restart.
  • Keep a clean copy of the pre-production .tpr. The .tpr used for gmx trjconv, gmx rdf, gmx rms, and all other analysis commands must correspond to the production trajectory. If the .tpr is regenerated with different parameters, topology-based selections (atom type, residue, molecule) may produce wrong results. Never overwrite production.tpr after a production run begins.

Integration with Other Skills

  • md-equilibration: This skill provides GROMACS-specific mdp syntax for equilibration (V-rescale, Parrinello-Rahman, density checks with gmx energy). That skill provides the physical criteria and diagnostic workflows (block averaging, stationarity tests, flying ice cube detection) that determine when the GROMACS equilibration stages have succeeded. Both skills must be used together.
  • md-analysis: Workflow 7 here covers GROMACS-native analysis tools (gmx rdf, gmx msd, gmx hbond, gmx trjconv). That skill covers MDAnalysis- and OVITO-based analysis that applies to GROMACS trajectories loaded via the .tpr + .xtc interface. The PBC pre-processing from Workflow 7 here is a prerequisite for the analysis in that skill.
  • md-force-fields: That skill covers the physical basis, parameterization domain, and transferability of AMBER, CHARMM, OPLS-AA, and GROMOS force fields. This skill provides the GROMACS-specific deployment: topology hierarchy, .itp structure, [ defaults ] section, and special_bonds settings that implement those force fields correctly in GROMACS.
  • enhanced-sampling: GROMACS is the reference code for PLUMED-driven enhanced sampling (metadynamics, umbrella sampling, replica exchange MD). The production .tpr produced in Workflow 3 here is the starting point for PLUMED-patched mdrun in that skill. The equilibration protocol here is a prerequisite before enhanced sampling begins.
  • free-energy-md: GROMACS has the most mature free energy perturbation (FEP) and alchemical transformation infrastructure among open-source MD codes. That skill covers the lambda coupling parameter mdp settings, the dhdl.xvg output, and MBAR/BAR analysis. This skill's equilibration and topology construction are prerequisites for any GROMACS FEP calculation.
  • coarse-grained-md: The Martini coarse-grained force field (Martini 2 and Martini 3) runs natively in GROMACS using the same .top/.itp/.mdp infrastructure covered here, with modified cutoffs (rcoulomb = 1.1 nm, rvdw = 1.1 nm for Martini), energy-shift vdW modifier, and LINCS-free integration. That skill covers Martini-specific parameterization and CHARMM-GUI Martini Maker setup.
  • reproducibility-workflow: The .tpr SHA-256 hash, GROMACS version, force-field .itp hashes, and .mdp files together form the minimal reproducibility record for a GROMACS simulation. That skill covers DVC-based data provenance, MLflow run tracking, and the README structure for archiving simulation inputs alongside results.
  • scientific-visualization: GROMACS trajectories (.xtc + .tpr) are loaded by VMD, PyMOL, OVITO, and MDAnalysis for visualization. That skill covers rendering proteins with secondary structure coloring, lipid bilayer visualization, and per-atom property mapping from GROMACS analysis outputs (RMSF, SASA, order parameters).

Key References

  1. Abraham, M. J., et al. (2015). GROMACS: High performance molecular simulations through multi-level parallelism from laptops to supercomputers. SoftwareX, 1–2, 19–25. https://doi.org/10.1016/j.softx.2015.06.001
  2. Bussi, G., Donadio, D., & Parrinello, M. (2007). Canonical sampling through velocity rescaling. Journal of Chemical Physics, 126(1), 014101. https://doi.org/10.1063/1.2408420
  3. Parrinello, M. & Rahman, A. (1981). Polymorphic transitions in single crystals: A new molecular dynamics method. Journal of Applied Physics, 52(12), 7182–7190. https://doi.org/10.1063/1.328693
  4. Hess, B., et al. (1997). LINCS: A linear constraint solver for molecular simulations. Journal of Computational Chemistry, 18(12), 1463–1472. https://doi.org/10.1002/(SICI)1096-987X(199709)18:12<1463::AID-JCC4>3.0.CO;2-H
  5. Huang, J., et al. (2017). CHARMM36m: An improved force field for folded and intrinsically disordered proteins. Nature Methods, 14(1), 71–73. https://doi.org/10.1038/nmeth.4067
  6. Maier, J. A., et al. (2015). ff14SB: Improving the accuracy of protein side chain and backbone parameters from ff99SB. Journal of Chemical Theory and Computation, 11(8), 3696–3713. https://doi.org/10.1021/acs.jctc.5b00255
  7. Darden, T., York, D., & Pedersen, L. (1993). Particle mesh Ewald: An N log(N) method for Ewald sums in large systems. Journal of Chemical Physics, 98(12), 10089–10092. https://doi.org/10.1063/1.464397

示例提示词

我想用GROMACS搭建从拓扑构建到生产运行的完整MD模拟流程。

所属插件

计算材料学:第一性原理与原子模拟面向计算材料研究:DFT 与第一性原理(VASP、Quantum ESPRESSO、CP2K、AiiDA)、缺陷/表面/声子/弹性常数、机器学习势函数训练与验证、分子动力学与增强采样、晶体性质图神经网络与生成模型。

安装该插件会一并获得同领域的 35 个 Skill / MCP。

同插件的其他科研 Skill

常见问题

GROMACS分子动力学工作流能做什么?

Covers end-to-end MD simulations with GROMACS: topology/.mdp construction, energy minimization, NVT/NPT equilibration. Use for GROMACS-based biomolecular or materials MD。

如何安装GROMACS分子动力学工作流?

在科搭 Codar 左侧点击「插件」,在「组件」页签搜索「GROMACS分子动力学工作流」并安装;在 Claude Code 或 Codex 中可以发送本页的安装提示词,或下载 Skill 包后解压到 ~/.claude/skills 或 ~/.codex/skills。

GROMACS分子动力学工作流需要哪些权限?

该科研 Skill没有声明额外权限;执行具体操作时仍由 Agent 按自身规则请求确认。

GROMACS分子动力学工作流经过官方审核吗?

是。SpeedSkills 收录的每个版本都会记录内容摘要与权限声明,当前版本已通过安全审核。