[lammps-users] Ave/spatial within regions?

Hello Lammps users,

Is it possible to create layers in specific regions to spatially-average properties? Let’s say I want to divide regions X and Y in 10 and 20 layers, respectively and compute the temperature gradient inside each one. Here, regions X and Y are filled initially with different substances and the interface between them moves over time.

I know it is possible to create groups of atoms for these regions, but the main limitation is that ave/spatial divides the whole molecular domain in layers and sometimes the atoms inside of these regions move away from their borders. Hence a layer can extend farther from the real / actual position of atoms. I was thinking that I can probably compute the centroid of the atoms in each layer of each region.

Any suggestion?

In addition, is there a better / efficient way to do this?

group g1 region r1
group g2 region r2

I think you would need to modify fix ave/spatial to operate (optionally)
on regions rather than groups.

Steve