**Sorry, it was my bad, I didn’t explain myself well and also I copied the mistaken error from another trial calculation that I was doing. But my command line for ave/chunk in that case was correct I think.**

**The error that I was talking about is the following one:**

ERROR: Fix ave/chunk compute does not calculate per-atom values (…/fix_ave_chunk.cpp:294)

Last command: fix 2 O ave/chunk 1 1 1 1 c_msd[*] file tmp2.out

**Here, lammps is complaining that ave/chunk is not using a per atom compute, and I neither can use msd/chunk command, so my question is, is there any way using ave/chunk or any other command for selecting a region of my cell, compute the msd of a group of atoms of that region and get the average value of all the atoms in that region over time?**

**I add again the script that I’m currently using:**

**
**
fix 1 all npt temp 1200 1200 0.5 iso 0 0 0.5 drag 1

group O type 1

compute 1 O chunk/atom bin/1d z 47 20 bound z 47 67 compress yes

compute msd O msd

fix 2 O ave/chunk 100 1 100 1 c_msd[*] file tmp2.out

**All the best,**

**Jose**

the sequence of commands and syntax you have to use is what you have quoted at the very beginning.

group O type 1

compute 1 O chunk/atom bin/1d z 9.0 2.0 bound z 9.0 11.0

compute msd O msd/chunk 1

fix 2 O ave/time 100 1 100 c_msd[*] file tmp2.out mode vector

however, there is a complication here: compute chunk/atom will update the atoms in the chunks every time the compute is triggered, but that is contrary to the expectations of compute msd/chunk, which expects those atoms to always be the same.

there is an option that you can do the assignment only once. but there is a more general problem: computing an MSD for spatial bins is not such a well defined entity (unlike a per molecule MSD). the concepts of an MSD requires that you follow the same atoms, but those atoms will leave the bin and then the question is how to handle this case.

if you keep following those atoms (i.e. only require that the atoms are in the bins in the very first step) you will not really be computing the MSD for atoms in the bins, the longer you wait and the binning is going to make less sense.

if, on the other hand, you require that atoms are inside the bind for the whole duration of the MSD evaluation, you will drop the “fast” atoms and thus have an arbitrary bias on your results and - again - the make less sense the longer to wait for it to converge.

so i would suggest to look at some other property to describe what you want to show. something like averaged velocities or only the velocity in a specific direction or averaged residence times (watch out for re-entries there) or something that I currently cannot think about.

axel.

Thank you so much Steve, that was exactly what I was looking for.

I have used it and analysed the results and is working perfectly for my problem of study. Thanks again for your patience and your time.

All the best,

Jose

Hi,

Sorry for bothering you again but I have one more question related to the topic. I have performed the simulation following your advice and the outcome is exactly what I wanted, thank you for the help. However, I have some problems understanding the output that I obtained. In lammps manual it says that “The first 3 elements of the vector are the dx,dy,dz displacements. The fourth component is the total displacement, i.e. sqrt(dx*dx + dy*dy + dz*dz).”

Therefore, in order to obtain the total msd I just have to take the last column and square it. However, I also would like to see the displacement on each direction, but the values on the output file for the first 3 displacement elements are not corresponding well with what I expected. I give here an example:

500 1 1528

1 1 37 1528 -0.0594909 -0.0197338 0.0831332 0.295248

Here I have for the 500 step: 1 chunk with 1528 atoms, then, in the next row I have the displacement results for them, being the last 4 columns the values that are specified as dx,dy,dz and sqrt(dx*dx + dy*dy + dz*dz). However, if I do manually the operation sqrt(dx*dx + dy*dy + dz*dz) using dx,dy,dz columns values, I’m not obtaining the fourth one. Therefore, I think I’m not understanding well what this command is doing.

It is important for me because I would like to see not only the total displacement of atoms in the material but also the displacement in 1 direction, understanding like this the difficulties that they will experience to diffuse in one or other direction.

This is the command line that im using:

fix 1 all npt temp 1200 1200 0.5 iso 0 0 0.5 drag 1

group O type 1

compute 1 O chunk/atom bin/1d z 27 20 nchunk once ids once bound z 27 47 compress yes

compute msd O displace/atom

fix 2 O ave/chunk 1 1 1 1 c_msd[*] file tmp2.out

Happy new year and thank you for your help,

Jose

The 4 numbers you are looking at are average values over many atoms in a chunk.

So your formula “I have the displacement results for them, being the last 4 columns the values that are specified as dx,dy,dz and sqrt(dx*dx + dy*dy + dz*dz). However, if I do manually the operation sqrt(dx*dx + dy*dy + dz*dz) using dx,dy,dz columns values, I’m not obtaining the fourth one.”

is not correct.

Say there are 2 atoms in the chunk and the first displaced (-1,0,0) and the second (+1,0,0).

Then the average x displacement would be 0. But the average total displacement would be 1.

Steve