Problem with fix ave/histo

Dear LAMMPS users,

I’m trying to calculate the dipole moment of water molecules and create a histogram of the dipole vector components. Yet, there are several problems encountered during coding. Test codes and problems are listed below.

Input files:
" compute chunk_water_molecule water chunk/atom molecule
compute dipole_water water dipole/chunk chun_water_molecule
fix f1 water ave/time 10 1 10 c_dipole_water[*] file dipole.out mode vector
fix f2 water ave/histo 10 1 10 0 1 10 c_dipole_water[1] file histo.out mode vector
variable v1 vector ‘c_dipole_water[3] / c_dipole_water[1]’
fix f3 water ave/time 10 1 10 v_v1 file vdipole.out mode vector
fix f4 water ave/histo 10 1 10 0 1 10 v_v1 file vhisto.out mode vector”

Problems:

  1. The fix ‘f1’, ‘f2’, and ‘f3’ return the results I expected, yet the ‘f4’ returns ERROR “Fix ave/histo input is invalid kind of variable”. Why the variable v1 can be used in fix ‘f3’ while not in ‘f4’?
  2. If I delete the fix ‘f1’, it returns another ERROR “Variable v1: variable formula compute array is zero length”. It appears that the variable v1 was not evaluated when the fix was invoked.

Although I bypassed the aforementioned problems through post-processing, I am still confused why these problems emerge. Could anyone please let me know if I have overlooked any factors causing coding errors?

Thanks in advance,
Jianbo Wang

FYI: the LAMMPS version is 7 Aug 2019

Please check with the latest LAMMPS version or the documentation for your specific version.The online documentation always refers to the latest version. Also, that version will have possible bugs fixed as they were discovered.

Nobody has the time to track down issues in a five year old version of LAMMPS.

I actually think there actually is a bug related to the first question. I created a related PR for it.

2 Likes

Hi @Leonenor,

Axel is right in that you should use a newer version of LAMMPS as the one you are mentioning it very old.

I think your first question is indeed a bug as I was able to reproduce it with a simple SPCe water model. However I cannot reproduce your second issue so it might be fixed through updating your version of LAMMPS.

2 Likes

Thank you, Axel. I will try the latest version. Thank you for your help

Hi Germain, thanks for your help.
I will try the latest version and will keep you updated when the test is done.

Hi, Axel. I tried the same input file with the latest LAMMPS (17 Apr 2024 version).

Problem 1 still exists and the fix ‘f4’ brings the ERROR “fix ave/histo variable v1 is incompatible style”.
I’m confused why the variable vector v1 works well with the fix ‘f3’ while it went wrong with fix ‘f4’.

In contrast, Problem 2 is solved.

Hi, Germain.

I tried the latest version as you and Axel suggested.
Like you said before. the second issue is fixed through the updates. Yet, the first issue still exists.

I believe the defined variable ‘v1’ is a vector as I tried to output it into logfiles. But the fix ave/histo still has problems in invoking the vector-style variable.

A pull request addressing this issue was merged a few days ago in the develop version of the code. There was indeed a small check difference between the code and what was stated in the doc.

I guess this shall be bundled with the next stable release, bad timing for you I guess. :slightly_frowning_face: In the mean time, you can try to compile the develop branch or ask for its installation.