Possible bug in fix ave/time

Dear LAMMPS users and developers,

I would like to use fix ave/time to calculate the average of a compute during an NVE run and store that average in a variable for later use. My short example script worked as expected with version 9Dec14, but does not work any more with 5Mar15.

The following dummy piece of code should average one value of the instantaneous kinetic energy and store it in the variable Ke_avg.

compute cKe all ke

fix fAvg all ave/time 1 1 1 c_cKe
fix fNVE all nve
run 1
variable Ke_avg equal $(f_fAvg[1])

With 9Dec14, this is exactly what happens. With 5Mar15, on the other hand, I get Ke_avg = 0. Is this the expected behaviour or a bug?

Please find attached the outputs of 9Dec14 and 5Mar15 as well as a minimal example.

Thanks,
Peter

LAMMPS (9 Dec 2014)
Lattice spacing in x,y,z = 1.6796 1.6796 1.6796
Created orthogonal box = (0 0 0) to (16.796 16.796 16.796)
1 by 1 by 1 MPI processor grid
Created 4000 atoms
Setting up run …
Memory usage per processor = 2.19271 Mbytes
Step cKe cT
0 17995.5 3
1 17990.972 2.9992451
Loop time of 0.00331116 on 1 procs for 1 steps with 4000 atoms

Pair time () = 0.00304103 (91.8419) Neigh time () = 0 (0)
Comm time () = 6.81877e-05 (2.05933) Outpt time () = 7.00951e-05 (2.11694)
Other time (%) = 0.000131845 (3.98185)

Nlocal: 4000 ave 4000 max 4000 min
Histogram: 1 0 0 0 0 0 0 0 0 0
Nghost: 5841 ave 5841 max 5841 min
Histogram: 1 0 0 0 0 0 0 0 0 0
Neighs: 156000 ave 156000 max 156000 min
Histogram: 1 0 0 0 0 0 0 0 0 0

Total # of neighbors = 156000
Ave neighs/atom = 39
Neighbor list builds = 0
Dangerous builds = 0

I ran your script with the 6Mar version and it gave the old answer (correct).

Steve

Dear Steve,

thanks for your quick reply. Is it possible that you compiled LAMMPS with make serial?

It seems that lmp_serial gets it right, but lmp_mpi fails (with mpiicc and mpic++ (version 4.8.2))!

I just checked out the latest version using

svn co svn://svn.lammps.org/lammps-ro/trunk mylammps

compiled it with

make -j2 mpi

and ran the example. I got the wrong value again (see first output below). When I did

make clean-all
make -j2 serial

and reran the example, it worked (second output below).

Peter

lmp_mpi:

LAMMPS (6 Mar 2015)
Lattice spacing in x,y,z = 1.6796 1.6796 1.6796
Created orthogonal box = (0 0 0) to (16.796 16.796 16.796)
1 by 1 by 1 MPI processor grid
Created 4000 atoms
Neighbor list info …
1 neighbor list requests
update every 20 steps, delay 0 steps, check no
master list distance cutoff = 2.8
Setting up run …
Memory usage per processor = 2.19271 Mbytes
Step cKe cT
0 17995.5 3
1 17990.972 2.9992451
Loop time of 0.00272703 on 1 procs for 1 steps with 4000 atoms

Pair time () = 0.00252509 (92.5949) Neigh time () = 0 (0)
Comm time () = 5.00679e-05 (1.83599) Outpt time () = 4.79221e-05 (1.7573)
Other time (%) = 0.000103951 (3.81186)

Nlocal: 4000 ave 4000 max 4000 min
Histogram: 1 0 0 0 0 0 0 0 0 0
Nghost: 5841 ave 5841 max 5841 min
Histogram: 1 0 0 0 0 0 0 0 0 0
Neighs: 156000 ave 156000 max 156000 min
Histogram: 1 0 0 0 0 0 0 0 0 0

Total # of neighbors = 156000
Ave neighs/atom = 39
Neighbor list builds = 0
Dangerous builds = 0

Interesting, the same thing happens here. Compiling with MPI makes it output zeros, but the serial build outputs the correct results. Weird.

I see the problem now via valgrind. This was due to changes to

accommodate the new chunk stuff where the number of chunks

(input to fix ave/time) varies with time.

Steve

I think this is the one-line fix. Will be in the next patch (after 12Mar).

Thanks,

Steve

— fix_
ave_time.cpp (revision 13172)
+++ fix_ave_time.cpp (working copy)
@@ -355,7 +355,7 @@

} else {
vector_flag = 1;

  • size_vector = nvalues;
  • size_vector = nrows = nvalues;
    extvector = -1;
    extlist = new int[nvalues];
    for (int i = 0; i < nvalues; i++) {

Dear Steve and Stefan,

thanks for looking into this!

Peter