# Managing long simulations

**URL:** <https://gromacs.bioexcel.eu/t/managing-long-simulations/1416>\
**Category:** User discussions\
**Created:** [January 10, 2021, 12:07pm UTC](https://gromacs.bioexcel.eu/t/managing-long-simulations/1416 "2021-01-10T12:07:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gil](https://avatars.discourse-cdn.com/v4/letter/g/9fc29f/32.png) [@Gil](https://gromacs.bioexcel.eu/u/Gil)\
**Post date:** [January 10, 2021, 12:07pm UTC](https://gromacs.bioexcel.eu/t/managing-long-simulations/1416/1 "2021-01-10T12:07:08Z")

</div>

GROMACS version:2020.3

Hello  
I’m trying to run 500ns simulation but willing to split the trajectory into 10 continuous simulations (50ns for each one).  
in order to do that for each simulation I’ve created a tpr file using the same md.mdp file by looping on

for ((i = 1 ; i \<= 10 ; i++)); do

> gmx grompp -f md.mdp -c md.tpr -o md\_{i}.tpr -t md\_{i}.cpt -p topol.top

then running the simulation by

> gmx mdrun -s md\_{i}.tpr -o md\_{i}.trr -cpo md\_$((i+1)).cpt

are the trajectories that I got continuing each other? is it the right way to split a simulation?

Best regards,  
Gil

---

<div class="post-metadata">

**Author:** ![milosz.wieczor](https://avatars.discourse-cdn.com/v4/letter/m/b19c9b/32.png) [@milosz.wieczor](https://gromacs.bioexcel.eu/u/milosz.wieczor)\
**Post date:** [January 10, 2021, 1:58pm UTC](https://gromacs.bioexcel.eu/t/managing-long-simulations/1416/2 "2021-01-10T13:58:53Z")

</div>

Maybe it would be easier to first run your single, regular job for 500 ns, and then use the -b/-e options of gmx trjcat to concatenate the trajectories in 50 ns blocks?

Your version would be a bit harder to restart correctly since the script starts from 1 each time it is evoked. You’d have to check the latest one and restart the loop from the correct iteration.

Best,  
Miłosz

---

<div class="post-metadata">

**Author:** ![Gil](https://avatars.discourse-cdn.com/v4/letter/g/9fc29f/32.png) [@Gil](https://gromacs.bioexcel.eu/u/Gil)\
**Post date:** [January 11, 2021, 8:00am UTC](https://gromacs.bioexcel.eu/t/managing-long-simulations/1416/3 "2021-01-11T08:00:59Z")

</div>

Thank you for your reply Miłosz!  
I would like to created them separately so I’ll be able to restart the simulation from any point if necessary

regards,  
Gil

---

<div class="post-metadata">

**Author:** ![jalemkul](https://dub1.discourse-cdn.com/flex017/user_avatar/gromacs.bioexcel.eu/jalemkul/32/18_2.png) [@jalemkul](https://gromacs.bioexcel.eu/u/jalemkul)\
**Post date:** [January 11, 2021, 4:33pm UTC](https://gromacs.bioexcel.eu/t/managing-long-simulations/1416/4 "2021-01-11T16:33:09Z")

</div>

Your loop just runs multiple simulations from the same starting point. If you want to do intervals of 50 ns, then:

1. Use `grompp` and `mdrun` to run a 50-ns MD simulation.
2. Use `convert-tpr` to increase the number of steps in the first `.tpr` file and use `mdrun -cpi` to start from the previous `.cpt` file.
3. Repeat step 2 as needed

---

<div class="post-metadata">

**Author:** ![milosz.wieczor](https://avatars.discourse-cdn.com/v4/letter/m/b19c9b/32.png) [@milosz.wieczor](https://gromacs.bioexcel.eu/u/milosz.wieczor)\
**Post date:** [January 11, 2021, 5:00pm UTC](https://gromacs.bioexcel.eu/t/managing-long-simulations/1416/5 "2021-01-11T17:00:55Z")

</div>

If the only thing you need is intermediate checkpoints, consider adding -cpnum to your mdrun command - this will keep numbered .cpt files instead of overwriting them. You can specify the interval between saving consecutive .cpts with -cpt (default is 15 minutes).

Alternatively, if you want the velocities at exact timesteps but don’t care about exact continuation of thermostats/barostats, set nstvout and nstxout to e.g. 500000 in your .mdp, and every 1 ns your coordinates/velocities will be saved to the .trr file. From there, you can read the velocities & positions using grompp.

Otherwise, go for Justin’s solution which should work the way you originally intended.
