In gromacs using the commands, command_1

gmx insert-molecules -f run03.pdb -ci CL.pdb -o out.pdb -nmol 119

will distribute CL ions in the system randomly, but how to specify a specific location to put the ions or molecules. For example if my periodic box is $\pu{5*5*10 nm^3}$ I want to put the ions to the location of $\pu{x < 5 nm, y < 5 nm }$ but $\pu{ z > 8 nm}$ (of course randomly but specific) in another words top part of the box I have also tried, command 2

gmx genion -s ions.tpr -o out.pdb -p system.top -pname NA -nname CL -neutral

But this command only replaces the SOL molecules (water) or some another residue in system.

Can someone help me, many thanks may be some other software can edit the pdb file but adding lot of ions one by one is quite annoying.

  • 3
    $\begingroup$ This can be done by a software called "Packmol" . Did you try that? $\endgroup$
    – Vasista
    Apr 2, 2022 at 12:14
  • $\begingroup$ Thanks I will check it out $\endgroup$ Apr 2, 2022 at 14:58
  • 1
    $\begingroup$ I think you can do this using gmx insert-molecules using the ip and dr functionality. I have not used it, but the documentation makes it seem like this is what these options exist for. See manual.gromacs.org/documentation/current/onlinehelp/…. Even if it works, I would probably stick with packmol $\endgroup$
    – B. Kelly
    Apr 2, 2022 at 23:41
  • 2
    $\begingroup$ @B.Kelly -ip and -dr function worked thanks $\endgroup$ Apr 3, 2022 at 4:07
  • $\begingroup$ @NightShade I added it as an answer so there can be a sense of finality. $\endgroup$
    – B. Kelly
    Apr 3, 2022 at 23:50

1 Answer 1


GROMACS should be able to do this using the -ip -dr options associated with the tool insert-molecules.

I have not used this myself, but the GROMACS insert-molecules documentation seems to indicate that these will do what you want. (now that you have tried them and they do work... well, now we know.)

As was also mentioned in the comments by @Vasista, the venerable Packmol can do this too.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .