Fix ave/atom always return 0, unless the average is made on one single value

LAMMPS version(s): 12Jun2025 and 11Feb2026 (same behaviour)

Hi,

I would like to compute the per-atom kinetic energy and output it to a .dump file, here’s (part of) my code:

fix             df1 all property/atom mol
fix             df2 all property/atom q
compute         ckatom all ke/atom
fix             akatom all ave/atom ${N1} ${N1} ${N3} c_ckatom 
variable 	    dummyMol atom "gmask(droplet)+2.0*gmask(surface)"
dump 		    d1 all custom 500 ${out_traj} id v_dummyMol type q x y z vx vy vz f_akatom
dump_modify	    d1 element Co Fe Ni Co Fe Ni

Ignore mol, q and dummyMol, they are needed just for post-processing purposes.

I notices that if I set:

fix akatom all ave/atom 1 1 500 c_ckatom

or

fix akatom all ave/atom 500 1 500 c_ckatom 

I get a non-zero output value in the .dump file:

ITEM: ATOMS id v_dummyMol type q x y z vx vy vz f_akatom
17971 2 4 0 2.21121 1.82077 32.0924 -3.03121 -10.5493 3.88055 0.414394

However, any other combination, like:

fix akatom all ave/atom 1 500 500 c_ckatom

or

fix akatom all ave/atom 1 2 500 c_ckatom

or

fix akatom all ave/atom 1 17 500 c_ckatom

always results in zero:

ITEM: ATOMS id v_dummyMol type q x y z vx vy vz f_akatom
17971 2 4 0 2.21121 1.82077 32.0924 -3.03121 -10.5493 3.88055 0

Could it be a mismatch between ave/atom frequency and dump frequency? Shouldn’t LAMMPS complain in that case? I have tried other output frequences, like:

ITEM: ATOMS id v_dummyMol type q x y z vx vy vz f_akatom
17971 2 4 0 2.21121 1.82077 32.0924 -3.03121 -10.5493 3.88055 0

and I still get zero.

You have to get zero in the output of the first frame (i.e. step 0) for any combination where nrepeat is larger than 1 and thus you have to average over multiple steps. At step 0 you have no data to average over and hence you get a zero, but for step 500 you should get non-zero output.

If nrepeat is 1, you can even get output on step 0 since you can use the energy from the setup() phase of the simulation and don’t have to compute any averages.

You can avoid the bogus output by using

dump_modify d1 delay 500