Using ave/correlate/long outputs in variable

Dear LAMMPS users,

I am planning to compute correlation functions in long simulation over the maximum time span. I thought about using the ave/correlate/long fix since it allows to maximise the computed time span with decent memory usage.

However, I'm not directly interested in the functions, but in a value I get from them and thought I could compute it directly after the simulation in order to reduce disk space usage and post-processing. I first tried to use ave/correlate fix in a LJ crystal test case and the following worked fine:

fix COR all ave/correlate 100 100 10000 v_Pxy vPxz v_Pyz v_Nyz v_Nxz v_Nxy ave running overwrite file cor1.dat

variable G vector "((f_COR[1]+f_COR[2]+f_COR[3])+(f_COR[4]+f_COR[5]+f_COR[6])/6.)"

while switching to this:

fix COR all ave/correlate/long 100 10000 v_Pxy vPxz v_Pyz v_Nyz v_Nxz v_Nxy overwrite file cor2.dat

variable G vector "((f_COR[1]+f_COR[2]+f_COR[3])+(f_COR[4]+f_COR[5]+f_COR[6])/6.)"

ended the simulation (G is only evaluated through a fix ave/time at the end) with the following message:

`ERROR: Variable G: Mismatched fix in variable formula (../variable.cpp:1850)`

From the documentation, I read that this message refers to a fix that `is referenced incorrectly or a fix that produces per-atom values is used in an equal-style variable formula` yet the correlation functions from ave/correlate/long are not per-atom values and the fix is referenced correctly (I just comment/uncomment corresponding fix lines in my input file. I do not touch the lines about the G variable). Fixes names are the same and are not illegal since the simulation runs. Is this difference in behaviour intentional?

Looking at the code where indicated, I suspect a difference in the fixes flags between fix ave/correlate and ave/correlate/long but I'm not sure. I pulled the version from the official stable repository and recompiled before testing (7 aug. 2019). Also I could not found anything related in the mailing-list archives.

Thank you for your time.

Regards,

Germain.

Dear LAMMPS users,

I am planning to compute correlation functions in long simulation over
the maximum time span. I thought about using the ave/correlate/long fix
since it allows to maximise the computed time span with decent memory usage.

[…]

ERROR: Variable G: Mismatched fix in variable formula (../variable.cpp:1850)

From the documentation, I read that this message refers to a fix that
is referenced incorrectly or a fix that produces per-atom values is used in an equal-style variable formula yet the correlation functions
from ave/correlate/long are not per-atom values and the fix is
referenced correctly (I just comment/uncomment corresponding fix lines
in my input file. I do not touch the lines about the G variable). Fixes
names are the same and are not illegal since the simulation runs. Is
this difference in behaviour intentional?

it is consistent with the documentation. while fix ave/correlate documents how to access its internal data through variable expressions and other output options, this is not documented for fix ave/correlate/long (and the corresponding methods are indeed not implemented). the general rule in LAMMPS is: if it is not documented, it is not supported.

Axel.

Dear Axel,

Thank you for the reply. This was indeed what I concluded, yet starting the doc page of ave/correlate/long stating that “This fix is similar in spirit and syntax to the fix/ave/correlate” can be very misleading as it could imply that the outputs are also similar in type (both computing global arrays), “spirit” being a pretty vague term. The many references to the ave/correlate page makes it more confusing.

Concerning the opening of my message, I stated the obvious to emphasize how simple my reasoning was and could lead to this kind of error (correlate/long outputs = correlate outputs but just for longer durations).

Yet this answered my question. Thanks for the efforts you put in this list and this program, they are much appreciated.

Germain

Axel - I suggest we add a line or two to the doc page for fix ave/correlate/long
doc page in the section at the end which states it does not
produce output. And that this is different from fix ave/correlate.
To avoid the confusion Germain mentioned.

Steve

done. see PR #1875