Using MSD to calculate the inter-diffusion coefficient

Please post to the list and not to me.

Just try them and see what happens, and
verify for yourself that the answers are correct,
e.g. by running a small system and comparing
to coordinate values in a dump file.

You can’t trust what some random “expert”
on a mail list tells you, even if it’s me.

Steve

Thanks for your help

Dear all,

I used these two kinds commands to calculate the MSD of Al and Mg:

compute msd_Al Al msd
compute msd_Mg Mg msd

fix 2 Al ave/time 100 1 5000 c_msd_Al file Al.txt mode vector
fix 3 Mg ave/time 100 1 5000 c_msd_Mg file Mg.txt mode vector

fix 1_store_state Al store/state 5000 type xu yu zu
fix 2_store_state Mg store/state 5000 type xu yu zu

dump 2 Al custom 5000 dump_Al..txt type xu yu zu
dump 3 Mg custom 5000 dump_Mg.
.txt type xu yu zu

and then to calculate the MSD of Al at 20000 steps by using the matlab:

MSD={[norm(dump_Al_20000–dump_Al_0)]^2}/1456

but the result is not agree with result of msd command.

Could you help me solve it?

Many thanks,

Yongning

I suggest you do it for a tiny system with one or two atoms and do
the calculation by hand as well, to see what the difference is
between the 2 approaches. It’s unlikely that LAMMPS is doing
it wrong.

Steve

Could you tell me how to calculates the MSD in LAMMPS? I have read the manual, but still don’t understand. How to calculate the displacement of atom? Is the original position of atom gotten after e

The original position is defined at the moment
in your input script that you invoke the compute msd
command. Have you done what I said? Have you
defined a small system, dumped out the coords, computed
the MSD yourself and compared to what the compute MSD
command outputs?

Steve

Yes, I had done it, so I have the question that the MSD which is calculated by myself is not agree with MSD command outputs.The commands are shown as following:

compute msd_Al Al msd
compute msd_Mg Mg msd

fix 2 Al ave/time 100 1 5000 c_msd_Al file Al.txt mode vector
fix 3 Mg ave/time 100 1 5000 c_msd_Mg file Mg.txt mode vector

fix 1_store_state Al store/state 5000 type xu yu zu
fix 2_store_state Mg store/state 5000 type xu yu zu

dump 2 Al custom 5000 dump_Al..txt type xu yu zu
dump 3 Mg custom 5000 dump_Mg.
.txt type xu yu zu
If they have some problems, could you tell me?

I choose the original position after e

Is this method correct, if not ,could you tell me the right one?

Many thanks,

Yongning

The store_state fixes are not being used, not sure why you define them.
I suggest you put 2 atoms in a box. Run them for 5000 steps. Dump
them and compute MSD by hand. Compare to compute msd and fix ave time.
I think you will get the same answer.

Steve

thanks for your help

I used these commands to calculate the displacement of atoms:

compute msd_Al Al msd
compute msd_Mg Mg msd
compute dis_Al Al displace/atom
compute dis_Mg Mg displace/atom

fix 2 Al ave/time 100 1 500 c_msd_Al file Al.txt mode vector
fix 3 Mg ave/time 100 1 500 c_msd_Mg file Mg.txt mode vector
fix 7 Al ave/time 100 1 500 c_dis_Al file coor_Al.txt mode vector
fix 8 Mg ave/time 100 1 500 c_dis_Mg file coor_Mg.txt mode vector

I can get the msd files, but for displace/atom commands, it showed that

ERROR: Fix ave/time compute does not calculate a vector (fix_ave_time.cpp:193)

I don’t know why.

Many thanks,

Yongning

B/c compute displace/atom calculates a per-atom vector of values,
and fix ave/time works on global scalars or vectors. See Section 6.15
of the manual for details.

To be frank, your sequence of emails have this flavor:
try a random command, get an error or unexpected result, post a question, repeat

That is not what the mail list is for. You have to do your “homework”.
Read the doc pages, read the error section of the manual, experiment
with small systems to get things to work, and more importantly, to
understand what the code is doing.

Steve

Thanks for your help, I have read the manual again, and find the problem about the commands.

I simulated a simple case, and used the msd commands to get the diffusion coefficient of Al and Mg.

I found that the msd of Mg is larger than Al’s, but from the atoms of VMD, we can find the the atoms of Al (green ball) have larger displacement than Mg’s ( red ball).

Could you help me?

atoms.PNG

Have you verified that what LAMMPS is computing for MSD
matches what is in the dump file of atom coords for a series
of snapshots? That is ground truth. What you think you
see in a viz display is not.

Steve

How did you calculated the diffusion coeff? What is the problem with vmd and it has to do with the diffusion anyway?