Dispersion correction broken with mdrun -rerun
Created an attachment (id=458)
Input files for reproducing the bug
With the latest git master, if I do a mdrun -rerun with a topology that has dispersion correction enabled and if the input trajectory does not have velocities, the dispersion correction energy and pressure seem to be random, most often giving +-Inf values in the log file (multiple runs with the same .tpr file seem to give different values). If velocities are present in the trajectory, everything seems to work. I'm attaching a package with .top, .gro, and .mdp files for reproducing the problem (create a .tpr file from the files, and then rerun with the .gro file as the input trajectory).
#1 Updated by Teemu Murtola almost 10 years ago
The problem is that the update_globals() call that calculates the dispersion correction (line 2363 in src/kernel/md.c) gets the box from the variable lastbox, but that is only initialized on line 2237, which is inside an if statement (starting on line 2228) and is only executed if the rerun trajectory contains velocities. So if there are no velocities, the box size passed to update_globals() is uninitialized. I'm not sure what's the best way of fixing this, since following the flow of execution for all the cases in do_md() is quite difficult...