PBC and dump average atomic position

Dear LAMMPS community,

I’m wondering how LAMMPS deals with the positions of atoms which went across periodic boundaries during the time-average window when dump average atomic positions using the command lines below.

fix ave all ave/atom 1 1000 1000 x y z
dump out all custom 1000 dump.*.atom.gz id type f_ave[1] f_ave[2] f_ave[3]

Thank you in advance for your answers!


LAMMPS will do exactly what you ask it to do, i.e. it will take the average of the x, y, z position values with complete disregard of whether the atoms have crossed a periodic boundary. So to avoid any artifacts, you want to average the “unwrapped” positions, xu, yu, zu.

Got it. Thank you, Axel, very much for your answer.

Hi Axel,

When I tried to average xu, yu, and zu, I got an error as below. Could you give me some suggestion to avoid it?

fix ave all ave/atom 1 1000 1000 xu yu zu
ERROR: Illegal fix ave/atom command (…/fix_ave_atom.cpp:124)
Last command: fix ave all ave/atom 1 1000 1000 xu yu zu

And after average xu, yu, and zu, Is it correct to convert them to wrapped position, x, y and z through plus/minus corresponding current box lengths, even under the NPT ensemble in which box lengths should fluctuate within a range?


You can access these through the compute property/atom command — LAMMPS documentation

BTW, it is a waste to average every step since the positions of successive timesteps are highly correlated. You are wasting memory and are needlessly slowing down your simulation.

There is no “correct” or “incorrect” here. Averaged positions will result in “deformed” molecules and unusual trajectories at any rate: any rotation will result in a “shrinkage” of the molecule and averaging over many steps can result in atoms moving “through” each other instead of “around” and so on.

Thank you, Axel, for your suggestions.

Compute property/atom works well.

My purpose of averaging position is to eliminate thermal noise in crystals at high T before structural analysis. Averaging every timestep seems to be necessary in this case?

Is there any better way to eliminate thermal noise than averaging positions? I tried energy minimization and during energy minimization some atoms seem to move to nearby lattice sites instead of their own lattice sites.

It makes no sense statistically.

If you are at high T, there has to be thermal noise or uncertainty since there are many equivalent states that the system can explore. The only time you have certainty and non-noisy data is at 0K.

You can try different methods to filter out high-frequency motions (e.g. a low pass FFT filter or a Savitzky-Golay filter), but all of them will cause some kind of artifact. That is unavoidable.

God it. Thanks, Axel, for these suggestions.

Which is perfectly physical, since that is how solid state ionic conductors work.