Slice simulation box in Z direction and compute mobility of water in seperate slices

Hi, I have a simulation box with a charged infinite planar surface(in the xy plane), water, and counterions. Because of the charged surface, the oppositely charged counterions will be accumulated close to the surface. Consequently, counterions and water of different z coordinates have different diffusion coefficients(equilibrium state) and velocities(non-equilibrium state with an electric field parallel to the surface). I wonder if it is possible to plot the diffusion coefficients and velocities of different molecules in different regions against the distance in the z direction, i.e., how to slice my simulation box in the z direction based on a specific bin width, then calculate the diffusion coefficients of one group in every slice, and plot the diffusion coefficients of this group against the distance in the z direction. I appreciate it a lot if anyone has experience in this or can give suggestions on this. Thank you!

This is a tricky problem as you want spatially static localized properties for a dynamic quantity. You need to track atoms over some time in which the might change slice.

If you don’t want to write your own tool, you can select atoms based on in which slice they are at a certain point in time and compute the MSD for that set.

Hi Hess,
Thanks for your reply. I used ‘gmx select’ to create a lot of indexes for a type of molecules/ions based on their z coordinates (slicing). Then I used these indexes to calculate MSD (gmx msd) for each slice. However, when I visualize the MSD curves, they are not linear compared to the overall MSD curve I obtained without slicing the box. Even though there are values for diffusion coefficients in the xvg outputs, I am not sure if they are reliable since the MSD curves are not linear. Is it because the bin (0.05 nm) I used to slice the box is too small, so there are not so many ions in each slice for enough sampling?