# Why is it different every time the interaction energy is calculated?

**URL:** <https://gromacs.bioexcel.eu/t/why-is-it-different-every-time-the-interaction-energy-is-calculated/3956>\
**Category:** User discussions\
**Tags:** mdp-parameters, mdrun\
**Created:** [April 5, 2022, 7:54am UTC](https://gromacs.bioexcel.eu/t/why-is-it-different-every-time-the-interaction-energy-is-calculated/3956 "2022-04-05T07:54:13Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Reza](https://avatars.discourse-cdn.com/v4/letter/r/b4bc9f/32.png) [@Reza](https://gromacs.bioexcel.eu/u/Reza)\
**Post date:** [April 5, 2022, 7:54am UTC](https://gromacs.bioexcel.eu/t/why-is-it-different-every-time-the-interaction-energy-is-calculated/3956/1 "2022-04-05T07:54:13Z")

</div>

GROMACS version:2021  
GROMACS modification: Yes/No  
I want to calculate the interaction energy between the two species. But every time I calculate the same simulation, the interaction energy varies between 250 and 600. I use the NVT ensemble. There is a vacuum inside the simulation box, and I use 148 core CPU.  
forcefield=charmm36

gmx mdrun -v -deffnm nvt -nb cpu -pme cpu -pmefft cpu -bonded cpu -update cpu -pin auto -tunepme yes -reseed 123456789 -dlb yes

gmx grompp -f Interaction\_energy.mdp -c nvt.gro -p topol.top -o Interaction.tpr  
gmx mdrun -s Interaction.tpr -rerun nvt.xtc -nt 1

gmx energy -f ener.edr -o Interactionenergy.xvg \> Interaction.log

**nvt.mdp**  
integrator = md-vv  
nsteps = 10000000  
dt = 0.001  
nstlist = 10  
rlist = 1.4  
cutoff-scheme = Verlet  
vdw-type = PME  
rvdw = 1.4  
coulombtype = P3M-AD  
DispCorr = Ener  
lj-pme-comb-rule = Lorentz-Berthelot  
rcoulomb = 1.4  
tcoupl = v-rescale  
tc-grps = system  
tau-t = 0.1  
ref-t = 353  
pbc = xyz  
gen-vel = yes  
gen-temp = 353  
gen-seed = 123456789  
ld-seed = 123456789  
constraints = none  
freezegrps = \*\*\*\*  
freezedim = Y Y Y Y Y Y  
nstxtcout = 10000  
nstxout = 10000  
nstenergy = 10000

**Interaction\_energy.mdp**

integrator = md-vv  
nsteps = 10000000  
dt = 0.001  
nstlist = 10  
rlist = 1.4  
cutoff-scheme = Verlet  
vdw-type = PME  
rvdw = 1.4  
coulombtype = P3M-AD  
DispCorr = Ener  
lj-pme-comb-rule = Lorentz-Berthelot  
rcoulomb = 1.4  
tcoupl = v-rescale  
tc-grps = system  
tau-t = 0.1  
ref-t = 353  
pbc = xyz  
gen-vel = yes  
gen-seed = 123456789  
ld-seed = 123456789  
gen-temp = 353  
constraints = none  
energygrps = \*\* \*\*  
nstxtcout = 10000  
nstxout = 10000  
nstenergy = 10000

---

<div class="post-metadata">

**Author:** ![Reza](https://avatars.discourse-cdn.com/v4/letter/r/b4bc9f/32.png) [@Reza](https://gromacs.bioexcel.eu/u/Reza)\
**Post date:** [April 5, 2022, 3:13pm UTC](https://gromacs.bioexcel.eu/t/why-is-it-different-every-time-the-interaction-energy-is-calculated/3956/2 "2022-04-05T15:13:13Z")

</div>

Why nobody answers me? The question is not complicated.

---

<div class="post-metadata">

**Author:** ![Reza](https://avatars.discourse-cdn.com/v4/letter/r/b4bc9f/32.png) [@Reza](https://gromacs.bioexcel.eu/u/Reza)\
**Post date:** [April 5, 2022, 5:27pm UTC](https://gromacs.bioexcel.eu/t/why-is-it-different-every-time-the-interaction-energy-is-calculated/3956/3 "2022-04-05T17:27:40Z")

</div>

@jalemkul  
@alevilla  
@hess

---

<div class="post-metadata">

**Author:** ![hess](https://dub1.discourse-cdn.com/flex017/user_avatar/gromacs.bioexcel.eu/hess/32/416_2.png) [@hess](https://gromacs.bioexcel.eu/u/hess)\
**Post date:** [April 5, 2022, 7:07pm UTC](https://gromacs.bioexcel.eu/t/why-is-it-different-every-time-the-interaction-energy-is-calculated/3956/4 "2022-04-05T19:07:53Z")

</div>

Before I answer I would like to say that your behavior is very unpolite. GROMACS is not a commercial software that you can demand support for, but free open-source software and many of the people answering questions on this forum are doing that to be helpful and are not begin paid for answering.

The answer to your question is that molecular dynamics is chaotic and mdrun is not binary reproducible (unless you use the -reprod flag and even then runs sometimes are not reproducible). So trajectories, also starting from the same tpr file, diverge exponentially in time.

---

<div class="post-metadata">

**Author:** ![gvigers](https://avatars.discourse-cdn.com/v4/letter/g/a9a28c/32.png) [@gvigers](https://gromacs.bioexcel.eu/u/gvigers)\
**Post date:** [April 5, 2022, 7:09pm UTC](https://gromacs.bioexcel.eu/t/why-is-it-different-every-time-the-interaction-energy-is-calculated/3956/5 "2022-04-05T19:09:07Z")

</div>

Hi Reza  
I have a question: Are you re-running both nvt and interaction.tpr each time? If you repeat just the second part (interaction.tpr) on a single nvt run do you get consistent result? In other words, at which stage is the inconsistency creeping in?

Best Wishes  
Guy Vigers

---

<div class="post-metadata">

**Author:** ![Reza](https://avatars.discourse-cdn.com/v4/letter/r/b4bc9f/32.png) [@Reza](https://gromacs.bioexcel.eu/u/Reza)\
**Post date:** [April 5, 2022, 7:41pm UTC](https://gromacs.bioexcel.eu/t/why-is-it-different-every-time-the-interaction-energy-is-calculated/3956/6 "2022-04-05T19:41:15Z")

</div>

> [@hess](#):
>
> -reprod flag

Thank you very much, Hess. I did not mention you intentionally. I just saw that you answered a few questions a few hours ago, and I thought you could help solve this problem. Because I posted this question a long time ago, and no one answered. I apologize for my behavior that upset you.  
I had a question about the -reprod flag. Does the interaction energy change decrease when I use this flag? The interaction energy I calculated is a variable range of 250-600. Does this change range decrease?

---

<div class="post-metadata">

**Author:** ![Reza](https://avatars.discourse-cdn.com/v4/letter/r/b4bc9f/32.png) [@Reza](https://gromacs.bioexcel.eu/u/Reza)\
**Post date:** [April 5, 2022, 7:48pm UTC](https://gromacs.bioexcel.eu/t/why-is-it-different-every-time-the-interaction-energy-is-calculated/3956/7 "2022-04-05T19:48:33Z")

</div>

> [@gvigers](#):
>
> Guy Vigers

Dear Guy Vigers,  
the command I use every time is below:

**first simulation**

gmx grompp -f nvt.mdp -c em.gro -p topol.top -o nvt1.tpr  
gmx mdrun -v -deffnm nvt1 -nb cpu -pme cpu -pmefft cpu -bonded cpu -update cpu -pin auto -tunepme yes -reseed 123456789 -dlb yes  
gmx grompp -f Interaction\_energy.mdp -c nvt1.gro -p topol.top -o Interaction.tpr  
gmx mdrun -s Interaction.tpr -rerun nvt1.xtc -nt 1  
gmx energy -f ener1.edr -o Interactionenergy1.xvg \> Interaction1.log

**Second one**

gmx grompp -f nvt.mdp -c em.gro -p topol.top -o nvt2.tpr  
gmx mdrun -v -deffnm nvt2 -nb cpu -pme cpu -pmefft cpu -bonded cpu -update cpu -pin auto -tunepme yes -reseed 123456789 -dlb yes  
gmx grompp -f Interaction\_energy.mdp -c nvt2.gro -p topol.top -o Interaction.tpr  
gmx mdrun -s Interaction.tpr -rerun nvt2.xtc -nt 1  
gmx energy -f ener2.edr -o Interactionenergy2.xvg \> Interaction2.log

---

<div class="post-metadata">

**Author:** ![gvigers](https://avatars.discourse-cdn.com/v4/letter/g/a9a28c/32.png) [@gvigers](https://gromacs.bioexcel.eu/u/gvigers)\
**Post date:** [April 5, 2022, 8:11pm UTC](https://gromacs.bioexcel.eu/t/why-is-it-different-every-time-the-interaction-energy-is-calculated/3956/8 "2022-04-05T20:11:15Z")

</div>

So if you just rerun the second calculation you get the same results, right?  
That tells you that your nvt runs are not identical. Have you looked at your coordinates at the ends of the nvt runs? Are they identical? I would guess not.  
This could be because of numerical instabilities or because of different random seeds. See hess’s answer above for a more precise answer.  
Guy

---

<div class="post-metadata">

**Author:** ![Reza](https://avatars.discourse-cdn.com/v4/letter/r/b4bc9f/32.png) [@Reza](https://gromacs.bioexcel.eu/u/Reza)\
**Post date:** [April 6, 2022, 8:08am UTC](https://gromacs.bioexcel.eu/t/why-is-it-different-every-time-the-interaction-energy-is-calculated/3956/9 "2022-04-06T08:08:20Z")

</div>

The interaction1 is not equal interaction2. The final coordinate about the same.
