[lammps-users] query regarding fix ave/spatial command.

Dear Lammps-users

I have a question related to fix ave/spatial command. I am getting a little confused why the layer 1 starts with -2.607. For my system xlo is -0.3741 and then I have 50 bins with 5.2142 lengths. This is what I wrote in input script and what I got in gradient1.dat file.

fix temp all ave/spatial {Nevery} {Nrepeat} {Nfreq} x xlo {bin} c_ke v_temp units box norm sample file gradient1.dat
fix temp all ave/spatial 10 5 50 x -0.3741 5.2142 c_ke v_temp units box norm sample file gradient1.dat
Spatial-averaged data for fix temp and group all

TimeStep Number-of-layers

Layer Coordinate Natoms c_ke v_temp

50 51
1 -2.60764 27 0.0440712 0.0293808
2 2.60764 144 0.0451462 0.0300975
3 7.82293 144 0.045375 0.03025
4 13.0382 144 0.0448503 0.0299002
5 18.2535 182.2 0.0443986 0.0295991
6 23.4688 153.8 0.0449872 0.0299915
7 28.6841 144 0.0442927 0.0295285
8 33.8993 144 0.0378457 0.0252304
9 39.1146 144 0.03773 0.0251533
10 44.3299 182.6 0.0376113 0.0250742
11 49.5452 153.4 0.0391475 0.0260983

I changed xlo to lower in the above command but got the same result. I will highly appreciate if anyone could clarify this confusion. It seems like it starts from -ve half of bin length which is (5.2142). Why it is so? Also, are these layer co-ordinates centre of the bins or lower extreme of the bins? Which format of fix ave/spatial should I use so that the first bin starts with xlo and it centres around xlo+0.5*binlength.

Thanks in advance and many regards,
Vikas

The coord printed in the file for the layer is its midpt. This pgraph from
the doc page explains how the layer extents are computed relative
to an origin which will be the boundary between 2 bins. If you don't
start at "lower" then you might get a bin that extends outside the
box on one end or both.

Each per-atom property is also averaged over atoms in each layer,
where the layers are in a particular dim and have a thickness given by
delta. Every Nfreq steps, when an averaging is being performed and the
per-atom property is calculated for the first time, the number of
layers and the layer boundaries are computed. Thus if the simulation
box changes size during a simulation, the number of layers and their
boundaries may also change. Layers are defined relative to a specified
origin, which may be the lower/upper edge of the box (in dim) or its
center point, or a specified coordinate value. Starting at the origin,
sufficient layers are created in both directions to completely cover
the box. On subsequent timesteps every atom is mapped to one of the
layers. Atoms beyond the lowermost/uppermost layer are counted in the
first/last layer.

Steve

Dear Steve,
Thanks for the response. When I used lower, I got the same result. Also, I am running NVE simulations, so no volume change. To my understanding after your email, it seems like if some atoms have image values which are -1 and 1 in restart file, The first layer will contain all the atoms which have -ve image values. and the last layer will contain all the atoms which have positve image values. Does that make sense?

Regards,
Vikas

Are you using the most current version of LAMMPS? Can you
put your ave/spatial command in a simple input file (like bench/in.lj)
and see what happens. Please post the entire (simple) input
script if there is still a problem.

Steve

Dear Steve,
What you mentioned was correct. When I tried that on melt example, it started at 0.5. Thereafter, I figured out that in my simulations, I was using p p f boundary conditions. As I was making slabs along “f” direction, the atoms were not imaged within the box and the ave/spatial command used its true co-ordinates calculating spatial properties.

Regards,
Vikas