Successive simulations

GROMACS version:2019.4
GROMACS modification: No

Hello Gromacs users,

I would like to run successive simulations on a system where the output of each one is the input of the next without having (as now) to wait for each one to finish before grompping and running the next. is there a way t odo this inherently in gromacs? some sort of ‘entrain’ option?


There is no magic way to do this in GROMACS, as grompp and mdrun are separate commands and have to be invoked by the user, but it’s trivial to set up a sequence of commands in a shell script to automatically run a series of jobs that pass the output of one to the next.

trivial if you know how I’m sure. In the end I just made a text document with each of the intended runs by copying and pasting and editing the numbers in the appropriate fields then copied that bodily into the terminal window which worked fine but obviously becomes tedious for large numbers of entrained commands - here there were only 9 small variations on two alternating types of run.

If you want advice on automating the workflow, show us the actual sequence of what you need to do so we can comment. Almost everything can be made very simple and rely on little more than a for-loop in a shell script or something similar.

see attached, thanks!

(Attachment pull_relax_x10.txt is missing)

here you go, thanks!

gmx_2019 grompp -f md_pull_step1.mdp -c step6.6.gro -p -r step6.6.gro -n pull.ndx -o pull_step1.tpr
nohup gmx_2019 mdrun -deffnm pull_step1 -pf pull_step1f.xvg -px pull_step1x.xvg

gmx_2019 grompp -f md_pull_step2.mdp -c pull_step1.gro -p -r pull_step1.gro -n pull.ndx -o pull_step2.tpr
nohup gmx_2019 mdrun -deffnm pull_step2 -pf pull_step2f.xvg -px pull_step2x.xvg

gmx_2019 grompp -f relax.mdp -c pull_step2.gro -p -r pull_step2.gro -n pull.ndx -o relax_step1.tpr
nohup gmx_2019 mdrun -deffnm relax_step1

gmx_2019 grompp -f md_pull_step3.mdp -c relax_step1.gro -p -r relax_step1.gro -n pull.ndx -o pull_step3.tpr
nohup gmx_2019 mdrun -deffnm pull_step3 -pf pull_step3f.xvg -px pull_step3x.xvg

gmx_2019 grompp -f relax.mdp -c pull_step3.gro -p -r pull_step3.gro -n pull.ndx -o relax_step2.tpr
nohup gmx_2019 mdrun -deffnm relax_step2

gmx_2019 grompp -f md_pull_step4.mdp -c relax_step2.gro -p -r relax_step2.gro -n pull.ndx -o pull_step4.tpr
nohup gmx_2019 mdrun -deffnm pull_step4 -pf pull_step4f.xvg -px pull_step4x.xvg

gmx_2019 grompp -f relax.mdp -c pull_step4.gro -p -r pull_step4.gro -n pull.ndx -o relax_step3.tpr
nohup gmx_2019 mdrun -deffnm relax_step3

gmx_2019 grompp -f md_pull_step5.mdp -c relax_step3.gro -p -r relax_step3.gro -n pull.ndx -o pull_step5.tpr
nohup gmx_2019 mdrun -deffnm pull_step5 -pf pull_step5f.xvg -px pull_step5x.xvg

gmx_2019 grompp -f relax.mdp -c pull_step5.gro -p -r pull_step5.gro -n pull.ndx -o relax_step4.tpr
nohup gmx_2019 mdrun -deffnm relax_step4

gmx_2019 grompp -f md_pull_step6.mdp -c relax_step4.gro -p -r relax_step4.gro -n pull.ndx -o pull_step6.tpr
nohup gmx_2019 mdrun -deffnm pull_step6 -pf pull_step6f.xvg -px pull_step6x.xvg

gmx_2019 grompp -f relax.mdp -c pull_step6.gro -p -r pull_step6.gro -n pull.ndx -o relax_step5.tpr
nohup gmx_2019 mdrun -deffnm relax_step5

gmx_2019 grompp -f md_pull_step7.mdp -c relax_step5.gro -p -r relax_step5.gro -n pull.ndx -o pull_step7.tpr
nohup gmx_2019 mdrun -deffnm pull_step7 -pf pull_step7f.xvg -px pull_step7x.xvg

gmx_2019 grompp -f relax.mdp -c pull_step7.gro -p -r pull_step7.gro -n pull.ndx -o relax_step6.tpr
nohup gmx_2019 mdrun -deffnm relax_step6

gmx_2019 grompp -f md_pull_step8.mdp -c relax_step6.gro -p -r relax_step6.gro -n pull.ndx -o pull_step8.tpr
nohup gmx_2019 mdrun -deffnm pull_step8 -pf pull_step8f.xvg -px pull_step8x.xvg

gmx_2019 grompp -f relax.mdp -c pull_step8.gro -p -r pull_step8.gro -n pull.ndx -o relax_step7.tpr
nohup gmx_2019 mdrun -deffnm relax_step7

gmx_2019 grompp -f md_pull_step9.mdp -c relax_step7.gro -p -r relax_step7.gro -n pull.ndx -o pull_step9.tpr
nohup gmx_2019 mdrun -deffnm pull_step9 -pf pull_step9f.xvg -px pull_step9x.xvg

gmx_2019 grompp -f relax.mdp -c pull_step9.gro -p -r pull_step9.gro -n pull.ndx -o relax_step8.tpr
nohup gmx_2019 mdrun -deffnm relax_step8

You’ll need something like the following script. I have not tested this, so it may need a bit of tweaking.


for (( i=1; i<10; i++ ))
    # set file prefixes
    inprefix="pull_step${j}"        # default
    if [[ $i -eq 1 ]]; then
        inprefix="step6.6"          # special for first step

    # no relax step in first two iterations 
    gmx_2019 grompp -f md_pull_step${i}.mdp -c ${inprefix}.gro -p -r ${inprefix}.gro -n pull.ndx -o pull_step${i}.tpr
    nohup gmx_2019 mdrun -deffnm pull_step${i} -pf pull_step${i}f.xvg -px pull_step${i}x.xvg
    # only add relax step after pull2 
    if [[ $i -ge 2 ]]; then
        gmx_2019 grompp -f relax.mdp -c ${inprefix}.gro -p -r ${inprefix}.gro -n pull.ndx -o relax_step${j}.tpr
        nohup gmx_2019 mdrun -deffnm relax_step${j}


If you ever find yourself needing to run the same thing over and over again, it can almost always be done in a for-loop with the occasional conditional for extra steps and/or file name alterations, as I’ve done here.

Thankyou so much for your time in producing this helpful example!