computing local densities

I am studying some extensions of L-J potentials and would like eventually to visualize time dependent density fluctuations, say, by using blue and red backgrounds to denote low and high densities in a movie.

But first I have to get the numbers. I have looked at compute chunk/atom, but none of the examples refers to density. I can also get the average density of the system, but I need the density in some specified local domain. There is pair_style local/density, which tells me that LAMMPS can compute local densities, but this is a mean-field potential, not simply the density itself.

I can generate a movie of the atoms in motion, but the density differences are subtle enough that I cannot tell visually where the higher and lower local density regions are.

Are there possible options for this?

you can use compute chunk/atom to do 3d binning and then use fix ave/chunk to determine either the number or the mass density per bin.


I’ve tried the following:

compute mychunkID all chunk/atom bin/3d x 0 1 y 0 1 z 0 1

fix ID group-ID ave/chunk Nevery Nrepeat Nfreq chunkID value1 value2 … keyword args …

fix 3 all ave/chunk 10 10 10 mychunkID density/number

…and I get an error

ERROR: Illegal fix ave/chunk command (src/fix_ave_chunk.cpp:273)

Since the message simply says it’s illegal, I don’t know how to correct it.

I’m sure the issue is simple, but I cannot find it having gone over the following pages with examples:

compute chunk/atom
fix ave/check
tutorial 8.4.2

your nevery, repeat, nfreq parameters are incorrect, hence the error about the illegal command.

how to choose those settings is documented:

The Nevery, Nrepeat, and Nfreq arguments specify on what timesteps the input values will be accessed and contribute to the average. The final averaged quantities are generated on timesteps that are a multiples of Nfreq. The average is over Nrepeat quantities, computed in the preceding portion of the simulation every Nevery timesteps. 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. Nrepeat*Nevery can not exceed Nfreq.

For example, if Nevery=2, Nrepeat=6, and Nfreq=100, then values on timesteps 90,92,94,96,98,100 will be used to compute the final average on timestep 100. Similarly for timesteps 190,192,194,196,198,200 on timestep 200, etc. If Nrepeat=1 and Nfreq = 100, then no time averaging is done; values are simply generated on timesteps 100,200,etc.