Potential bug in fix ave/time

Dear LAMMPS developers,

I've encountered a potential problem related to fix ave/time: depending
on the order of the specified variables I get different answers.

In particular, I consider the two quantities epair and etotal, which I
store in variables before averaging them with fix_ave_time.

variable vetotal equal etotal
variable vepair equal epair

# f1 gives wrong answer as compared to thermo-output

fix f1 all ave/time 1 1 1 v_vepair v_vetotal file

# f2 gives correct answer

fix f2 all ave/time 1 1 1 v_vetotal v_vepair
file f2.dat

thermo_style custom step epair etotal
thermo 1
run 5

I appended the in.melt example with the lines above and ran the script
with the latest version of LAMMPS (16Feb16). Please find the relevant
output below and the input script to reproduce the data attached.

Is this the expected behaviour?

Best wishes,


f2.dat (207 Bytes)

f1.dat (205 Bytes)

log.lammps (3.95 KB)

in.melt (1.02 KB)

This was a bookkeeping error in thermo.cpp, trying to be too

clever about not re-calculating the potential energy multiple times.

Will be fixed in next patch.