Dong,

Here is how I use fix ave/spatial to get the stress profile (Pxx, Pyy, Pzz) in the x-direction:

variable NTS equal 1000000 #Total number of timesteps

variable NBLK equal 1 #Total number of blocks

variable Nevery equal 50 #Number of time-steps between property samples

variable Nrepeat equal {NTS}/{Nevery}/{NBLK}
variable Nfreq equal {NTS}/${NBLK}

variable NBIN equal 50 #Number of bins in the x direction

variable dx equal 1/${NBIN} #Bin size

compute atomstress all stress/atom

fix 1 all ave/spatial {Nevery} {Nrepeat} {Nfreq} x center {dx} c_atomstress[1] c_atomstress[2] c_atomstress[3] units reduced file stress.txt