Increase box size and continue a run

GROMACS version: 2020.2
GROMACS modification: No

Hi all,

I am currently running a simulation and would like to increase the box size and then continue the run. So far, I have not found the correct way to do so. Any suggestions would be greatly appreciated.

Thank you.

That’s not something you can do and actually continue the simulation. Increasing the box requires addition of solvent and subsequent equilibration. It’s simply a new simulation, and can not be a continuation (functionality within GROMACS, since the topology and state of the system has changed, there is no mechanism by which the previous state can be preserved and used to continue the simulation).

I understand, thank you for your reply. This makes much more sense. I would then restart from time 0 because nothing from the smaller box size can be preserved?

You can start a new simulation starting from the old one’s endpoint.

Take your ending configuration (trjconv -dump to get a frame at the end of your .trr/.xtc, or use the final .gro file if your simulation completed), modify it to the new configuration. If you’re just changing the box size, gmx editconf works, though changing the box without adding/removing particles will likely lead to instability. If yo’re trying to do something like duplicate your box with all the components in extra dimensions, gmx genconf will work. Then (if atom counts have changed), update your topology/index file, and create a new tpr using those inputs, and go through all the normal equilibration steps.

Whether that’s worth all the effort vs restarting from scratch depends on how long your simulation ran and what you’re trying to do.

Thank you for your reply. This simulation has been running for quite some time and it would be useful to continue from the current time point. So far I have modified the last frame of my simulation to the right box size by gmx editconf. I do not need to duplicate the box, but only have to increase its dimensions. But with this I do have to change the atom counts. I am running from a tpr file, would I only need to edit the number of solvent molecules in the topology? And also, when I rerun the equilibration is it sufficient to just rewrite the energy minimization and npt tpr files before rerunning? These are the steps where I am slightly confused.

Again, thank you for your help and advice.

If you’re updating the number of solvent molecules in the structure file, then yes you’ll need the corresponding changes to the topology file.

You will need a new tpr - each TPR relies on the information provided from the topology, mdp, structure file, and any indices you use during grompp. Mdrun only sees the contents of the tpr, so if you make a change to any of the other files, but try to use your original tpr, the simulation will be of the old system.

Not sure what you mean by that. Introducing new particles/updating a simulation box likely needs to nonphysical/unstable states. In this case, you need to actually run minimization or your system will explode, and you’ll probably need all the equilibration steps as well.

Thank you so much for the detailed instruction, it has been extremely helpful. IN order to make the tpr file can I use the new gro file and convert-tpr?

If you’re changing the contents of the system, you need to create an entirely new .tpr file with grompp. The new system has nothing to do with the old one; convert-tpr is only for either changing the number of steps in an existing .tpr file or saving a subset of the coordinates.

I see, thank you for the clarification. If I am understanding correctly, this will be for the new equilibration tpr files as well?

Additionally, after modifying the topology file manually and then attempting to write the new tpr using grompp (from the gro file of the last frame). I run into the error of not having the same number of atoms in the topology and gro file. However, I obtained the number for the topology file by setting up a new system with the desired box size. Does changing the box size automatically add solvent molecules which may be causing this discrepancy?

Yes, as I noted above, you’re starting effectively a new simulation, even if it originates from a snapshot of a previous simulation. You have to minimize, equilibrate, etc. as you would any other new run.

No. editconf changes box size, solvate and genion change contents. If your coordinates and topology don’t match, check again what you added and count the relevant species. This is always just a bookkeeping error and is solved by correctly listing the number of molecules in the topology.

This has greatly helped my understanding, thank you. If I am originating from a snapshot of my old simulation and need to add additional solvent and ions to the topology, using solvate and genion still leads to this discrepancy. So far, I created the gro file as is listed above, updated the box size, and attempted to use it as the input for solvate and genion. Does solvate add on in addition to which solvent molecules already existed?

This is the step where I encounter the issue, since my confusion is on how to appropriately update the topology file (as in how to determine how many atoms I must add).

solvate and genion will update the topology if you ask them to. Please post the exact error you’re getting, as well as all relevant commands, output, and the contents of your [molecules] section in your updated .top file.

I have so far followed the steps:

gmx trjconv -s protein.tpr -f protein_lastpart.xtc -o protein_lastpart.gro -dump 2000000

gmx editconf -f protein_lastpart.gro -o protein_newbox.gro -box 21 21 21

gmx solvate -cp protein_newbox.gro -cs spc216.gro -o protein_solv.gro -p topol.top

gmx grompp -f ions.mdp -c protein_solv.gro -p topol.top -o ions.tpr

gmx genion -s ions.tpr -o protein_solv_ions.gro -p topol.top -pname NA -nname CL -neutral -conc 1.2

I get the error after the last step (attached below). And here are the contents of [molecules] as well.error4

molecules

You will need to move all the ion coordinates to follow the water in the coordinate file, then add together the SOL blocks in the topology and reorder the ions to match the coordinate file. SOL must be continuous, as the error message tells you.

I understand why these steps have to be taken, but want to make sure that I understand which files are being changed and how I can to do so:
1)To ‘follow’ the water in the coordinate file (the gro file), it seems that I can make the necessary changes in a text editor. But, where in this file can I see whether the ions follow water?
2) Adding together the SOL blocks would be done in the topology file by summing what is left after solvate
3) Would I be reordering ions in the new coordinate file (gro) produced after adding together the SOL blocks?

I am slightly confused on what can be done to follow the water and reorder the ions.

Thank you very much for all of your help, and for bettering my understanding of how I may resolve this issue. I really appreciate it.

By moving the lines. Put all the ions after the last SOL line.

Yes.

Not if you just shift this block of lines down to the end of the coordinate file.

Thank you, this allowed me to appropriately adjust the system and write the ions.tpr file. I had assumed that I would then add the NA and CL lines from after genion to the original lines forming one line for each ion (as I had done with the SOL line) but this leads to an error. When I move to write the em.tpr file I get too many warnings -

(more than 20 non-matching atom names)
atom names from topol.top will be ignored
atom names from solv.ion.gro will be used

Is this just because I changed the topology and edited the solvated gro file? I see that I can overwrite this with -maxwarn, but am not sure if this is safe to do.

My advice is to never use -maxwarn. There is only one scenario in which it is useful but is otherwise a terrible idea.

Your coordinates and topology are in different orders, hence the mismatch. The full error message would be instructive (please always provide a complete error, copied and pasted from your terminal).

Apologies, the error is as follows:

I also inspected the gro file and am just not sure where I can find this numbering in the topol.top file, since it just has the number of NA and CL atoms under the number of SOL atoms. My confusion is basically on where to visualize the atom names in the topology file so that I can see exactly where the order is not agreeing. Line 52 is also just the number of CL atoms (which is the sum of the original ions and those added after genion).

When I rearrange the coordinate file, is it that I should also correct the numbering in the first column of the gro file? This was when I moved all ions below SOL in the gro file before genion. For example, if I moved atoms numbered 44012NA-59302CL to the bottom leaving a ‘gap’ in numbering in SOL.