[lammps-users] fix ave/atom in 21 Apr 08 release incomplete/incorrect docs or bug in code?

Hi all,

I recently tried to use the fix ave/atom command in the 21 Apr 08 release (haven’t upgraded to the latest yet, but no bug fix is mentioned for this anyway). I came across an interesting ‘gotcha’ that as far as I can tell isn’t mentioned anywhere nor do the errors outputed by the code (Illegal fix ave/atom command) give any useful indication of what is wrong.

the docs say that the command is to be invoked as follows:

fix ID group-ID ave/atom Nevery Nrepeat Nfreq value1 value2 …

the command I invoked is as follows:

fix 4 all ave/atom 1 20 5 x y z

Which seems reasonable as the docs only say that Nfreq must be a multiple of Nevery and Nevery must be nonzero even in Nrepeat is 1. However, the examples shown show the case where Nfreq >= Nrepeat > Nevery . But this is the interesting part…

In the code in fix_ave_atom.cpp (FixAveAtom::FixAveAtom) around line 120 there is an error-checking if statement that is as follows:

if (peratom_freq < nevery || peratom_freq % nevery ||
(nrepeat-1)*nevery >= peratom_freq)
error->all(“Illegal fix ave/atom command”);

So, actually according to this, Nfreq must be less than (Nrepeat-1)*Nevery in order for the error code not to be evaluated, in addition to the requirements listed in the docs. This seems like a bug in the code, since if Nrepeat = 1, Nfreq would have to be less than zero for the code to continue. Anyone been able to use this fix successfully? I am missing something?

Dave

David E. Farrell

Graduate Student

Mechanical Engineering

Northwestern University

email: d-farrell2@…435…

I think the code is correct, but the doc page is incomplete. It now
reads:

{Nfreq} must be a multiple of {Nevery} and {Nevery} must be non-zero
even if {Nrepeat} is 1. Also, the timesteps contributing to the
average value cannot overlap, i.e. Nfreq > (Nrepeat-1)*Nevery is
required.

Steve

OK, thanks for the update.

Dave