[lammps-users] error in "fix reax/c/species" command: "Illegal fix ave/atom command (../fix_ave_atom.cpp:139)"

Hi lammps users,

I’m trying to simulate a reactive hydrocarbon system at high temperature, everything goes well, except I use the “fix reax/c/species” command looking for the species. I use the command:
"fix spec all reax/c/species 1 1 1000 spec_test.out "
it also can work, however, if I change Nrepeat to 1000 like
"fix spec all reax/c/species 1 1000 1000 spec_test.out "
The error then happened:
“ERROR: Illegal fix ave/atom command (…/fix_ave_atom.cpp:139)”
I have tested the case if I change the Nrepeat to another value like “100” or “999”, it still can work well. So my question is why does this error happen ? I also attached a test case for you to repeat my error.

Any help is appreciated, and thank you in advance.

Jiang Xiao

fix_reaxc_bugTest.tar.gz (44.2 KB)

This is due to a bug/limitation inside of fix reaxff/species that internally uses fix ave/atom to get averaged data.
Because the neighborlist updates must be synchronized with the averaging of atom data, fix reaxff/species changes your neighbor list update settings.

The author of the code apparently never anticipated that anybody would want to average over more than 999 steps and copies some string data in a way that overwrites the terminating 0 byte and then causes the invalid internal command line.

There is indeed very little value to it and it may even have a negative impact on the correctness of your simulation to average over such large chunks.

To explain, in MD simulations the atom positions in adjacent timesteps are strongly correlated, thuse their “statistical relevance” is low.
Thus there is very little to be gained by averaging every step instead of, say averaging every 10 steps.

thus instead of:

fix spec all reax/c/species 1 1000 1000 spec_test.out

you could use:

fix spec all reax/c/species 10 100 1000 spec_test.out

for essentially the same statistical convergence and without triggering the bug.
But before doing that, you should first run without the species fix and with neighbor list checking to generate neighbor list statistics to see whether you can afford to run your simulation with updating your neighbor list only every 1000 steps, probably not.
when running a quick test with your provided input it looks like about once every 100 steps seems about as far as you may safely push it.


Dear Axel,

Thanks for your patience and promptly reply, your answer is really helpful for me to understand this problem! Thanks a lot!
In the end of your answer, you suggest that I “should first run without the species fix and with neighbor list checking …”
If my understand is correct,
“fix spec all reax/c/species 1 1000 1000 spec_test.out”
the command will only update neighbor list every 1000 steps which change our neighbor setting like
“neigh_modify every 1000 delay 0 check no”
which may result in a lot of “dangerous builds” during simulation, so I should carefully check if this setting is appropriate in our simulation, is my understanding correct? Thanks again for your answer~

Best Regards,

Jiang Xiao

Axel Kohlmeyer <[email protected]> 于2021年10月7日周四 下午7:32写道:

Yes, you are correct. There is a warning being printed that the neighbor list settings are changed, but it doesn’t say how.
Unfortunately, the documentation does not mention it either. You would have to look at the source code to see the reason.

outside of fixing the bug (which will be done in the next LAMMPS patch), there should be a better warning message and an explanation and warning in the manual.

Dear Axel,

Thanks again for your answer!

Best Regards,

Jiang Xiao

Axel Kohlmeyer <[email protected]> 于2021年10月8日周五 上午12:26写道: