Blog
How to Solvate a Protein and Add Ions in GROMACS (gmx solvate and gmx genion), Step by Step
- July 30, 2026
- Posted by: Stem Skills Lab
- Category: Molecular Modeling

To add ions in GROMACS, first solvate the protein with gmx solvate, then build a run input file with gmx grompp and a short ions.mdp, and run gmx genion -s ions.tpr -p topol.top -pname NA -nname CL -neutral. At the interactive prompt, choose the SOL group so ions replace water molecules, not protein atoms.
Once you have a topology and a box, two steps stand between you and a runnable system: filling the box with water, then dropping in ions so the net charge is zero. Skip the ions and your Ewald electrostatics are computing the energy of a charged box against an artificial neutralizing background, which is not the physics you meant to study. This guide from the StemSkills Lab team, who have spent 10+ years building and running molecular dynamics systems across drug-discovery and materials projects, walks through gmx solvate and gmx genion with the exact commands, the water-model choice that trips people up, and the SOL group prompt that quietly ruins runs. New to the engine? Start with our GROMACS molecular dynamics guide, then come back here for the solvation and ions step.
What does it mean to solvate a protein and add ions in GROMACS?
Solvation means surrounding your protein with explicit water molecules so the simulation reproduces the aqueous environment a real protein lives in. Adding ions then does two jobs: it neutralizes the total charge of the system, and it can reproduce a physiological salt concentration so screening effects on the protein surface are realistic.
The reason neutrality is not optional is the electrostatics method. Production MD uses Particle Mesh Ewald (PME) to compute long-range electrostatics under periodic boundary conditions, and PME assumes a net-neutral cell. A protein almost never has an integer charge of zero, so you compensate by replacing a handful of water molecules with sodium or chloride ions until the counted charge is exactly zero. GROMACS is the open-source engine described in Abraham et al., “GROMACS: High performance molecular simulations through multi-level parallelism from laptops to supercomputers,” SoftwareX 1-2 (2015): 19-25 (doi:10.1016/j.softx.2015.06.001), and this solvate-then-neutralize sequence is the standard setup taught in its reference tutorials.
What do you need before you can solvate?
Solvation is not the first step. Two things must already exist:
- A processed structure and topology. You get these from
gmx pdb2gmx, which reads your cleaned PDB, applies a force field, and writestopol.topplus a.grocoordinate file. If you have not chosen a force field yet, read our guide on how to choose a force field for GROMACS first, because the choice also fixes which water model you can use. - A defined box. Water needs a container. Centre the protein and set a box with
gmx editconf:
gmx editconf -f protein_processed.gro -o protein_newbox.gro -c -d 1.0 -bt cubic
Here -c centres the protein, -d 1.0 keeps at least 1.0 nm between the protein and every box edge (so a periodic image never sees its neighbour), and -bt cubic chooses a cubic box. A rhombic dodecahedron (-bt dodecahedron) uses roughly 71% of the volume of a cube for the same minimum image distance, so it needs fewer waters and runs faster, which is why many practitioners prefer it for globular proteins.
How do you solvate a protein in GROMACS with gmx solvate?
With a box in place, fill it with water in one command:
gmx solvate -cp protein_newbox.gro -cs spc216.gro -o protein_solv.gro -p topol.top
Reading the flags: -cp is your boxed protein (the solute), -cs spc216.gro is the pre-equilibrated solvent configuration to stamp into the empty space, -o is the solvated output, and -p topol.top tells solvate to append the number of added water molecules to your topology automatically. That last flag matters more than it looks: if you forget -p, your coordinate file will hold thousands of waters that your topology knows nothing about, and the next gmx grompp will fail with a coordinate-count mismatch.
The file spc216.gro is a small equilibrated box of 216 water molecules that ships with GROMACS. It works as the stamping unit for any three-site water model (SPC, SPC/E, TIP3P) because they share the same three-point geometry. The official gmx solvate documentation describes exactly which solvent files to pair with each model.
Which water model and solvent box should you use?
The water model is actually chosen earlier, at the gmx pdb2gmx step, with the -water flag (for example -water spce or -water tip3p). The -cs file you pass to gmx solvate must have the same number of interaction sites as that model, or the geometry will not match. Use this table to pair them correctly:
| Water model | Interaction sites | -cs solvent file | Common force-field pairing |
|---|---|---|---|
| SPC | 3 | spc216.gro | GROMOS |
| SPC/E | 3 | spc216.gro | GROMOS, general use |
| TIP3P | 3 | spc216.gro | AMBER, CHARMM |
| TIP4P | 4 | tip4p.gro | OPLS-AA, some AMBER |
| TIP5P | 5 | tip5p.gro | specialised studies |
For most beginner protein simulations, SPC/E or TIP3P with spc216.gro is the sensible default. SPC/E was introduced in Berendsen, Grigera and Straatsma, “The Missing Term in Effective Pair Potentials,” Journal of Physical Chemistry 91 (1987): 6269-6271 (doi:10.1021/j100308a038); it corrects the self-energy term in the earlier SPC model and reproduces the density and diffusion of liquid water better, which is why it remains a standard choice decades later.
Want the guided, hands-on version?
Our live Molecular Modeling & MD Simulations cohort bootcamp takes you from zero to running real docking and MD workflows, with a portfolio project for your grad-school applications.
How do you add ions in GROMACS with gmx genion?
Ions are added in two moves. First, gmx genion needs a portable run input file (.tpr) that carries the charges, so you assemble one with gmx grompp and a minimal parameter file called ions.mdp. This ions.mdp is just a short energy-minimization style file; genion never runs dynamics with it, it only reads the topology and charges. If the parameters inside it are unfamiliar, our breakdown of the GROMACS .mdp file explains what each line does.
gmx grompp -f ions.mdp -c protein_solv.gro -p topol.top -o ions.tpr
Then run genion against that .tpr:
gmx genion -s ions.tpr -o protein_solv_ions.gro -p topol.top -pname NA -nname CL -neutral
The GROMACS documentation describes what happens next: genion “randomly replaces solvent molecules with monoatomic ions” (gmx genion reference). Reading the flags:
-pname NAand-nname CL: the residue names of the positive and negative ions. These must match the names defined in your force field’sions.itp. Sodium (NA) and chloride (CL) are standard across the AMBER, CHARMM, GROMOS and OPLS ports that ship with GROMACS.-neutral: add exactly enough ions to bring the total system charge to zero, and no more.-conc 0.15(optional, added alongside-neutral): also reach a salt concentration of 0.15 mol/L, the physiological value of about 150 mM, computed from the box volume in the.tpr.
A physiological setup therefore usually reads -neutral -conc 0.15: it neutralizes the charge and adds background salt in one call.
What does the SOL group prompt mean, and how many ions get added?
This is the single most common place a beginner’s system goes wrong. After you run genion, it prints how many ions it will add, then asks you to pick a group, listing the index groups in your system (System, Protein, Water, SOL, and others). It is asking which atoms it is allowed to replace. You must choose SOL, the solvent group, so ions take the place of water molecules.
If you accidentally select System or Protein, genion can try to replace protein atoms with ions, which corrupts your structure. Choosing SOL is what keeps the swap confined to water. You can avoid the interactive prompt entirely by piping the group name in: echo SOL | gmx genion ..., which is also how you script the step for a cluster.
How many ions? genion reads the exact net charge from the .tpr and adds the minimum number of counter-ions to cancel it. A protein with a net charge of -8e, for example, gets 8 sodium ions added under -neutral. Add -conc and it layers extra NA and CL pairs on top until the target concentration is reached. After genion finishes, it decrements the SOL count in topol.top and adds the ion lines, which is why passing -p here is just as essential as it was at the solvate step.
How do you troubleshoot common gmx solvate and gmx genion errors?
Most solvation and ion failures come from a small set of causes. Here are the ones students hit most, with the real fix for each.
| Symptom | Likely cause | Fix |
|---|---|---|
| grompp reports “number of coordinates does not match topology” | You solvated or added ions without -p topol.top, so counts drifted | Re-run solvate/genion with -p; never hand-edit water counts in the topology |
| genion: “No ions to add” | The system is already neutral and you used only -neutral | Expected behaviour; add -conc 0.15 if you want background salt |
| Structure looks broken after genion | You selected System or Protein at the group prompt instead of SOL | Re-run genion and choose the SOL group, or pipe echo SOL | |
| genion cannot find the ion name | -pname/-nname do not match the force field | Open the force field’s ions.itp and use the exact residue names listed there |
| Waters appear inside the protein after solvate | Internal cavities filled with water | Usually fine for surface cavities; for buried sites, inspect in a viewer and remove stray waters if unphysical |
Once the system is neutral, your next step is energy minimization, then the two-phase equilibration before production. When you reach it, our guide to GROMACS NVT and NPT equilibration picks up exactly where this one ends. For the wider skill path from setup to publication-ready analysis, see the computational biology skills roadmap.
Frequently asked questions
Do I always need to add ions, even if my protein is neutral?
If the net charge is already zero, -neutral adds nothing, and that is correct. Many researchers still add -conc 0.15 so the simulation includes a realistic 150 mM salt background, which better matches physiological conditions and screens surface charges.
What is the difference between -neutral and -conc in gmx genion?
-neutral adds only enough ions to cancel the system’s net charge. -conc adds ions to reach a target salt concentration in mol/L, computed from the box volume. Used together, genion neutralizes the charge and then reaches the requested concentration.
Why does genion need a .tpr file instead of the .gro directly?
The .gro file has coordinates but no charges. genion must know each atom’s charge to compute how many counter-ions to add, and that information lives in the topology. The .tpr produced by gmx grompp bundles coordinates, topology and parameters together, so genion reads everything it needs from one file.
Which group do I pick at the genion prompt?
Always pick SOL, the solvent group, so ions replace water molecules. Selecting System or Protein lets genion replace protein atoms, which damages your structure. To script it, pipe the choice with echo SOL | gmx genion ....
Can I use NaCl parameters with any force field?
The ion names NA and CL work with the AMBER, CHARMM, GROMOS and OPLS force fields bundled with GROMACS, because each defines them in its ions.itp. If genion cannot find an ion, open that file and use the exact residue name your force field expects.
Want the guided, hands-on version?
Our live Molecular Modeling & MD Simulations cohort bootcamp takes you from zero to running real docking and MD workflows, with a portfolio project for your grad-school applications.