# Ensemble effect on compute msd

Hello everyone I just want to be sure about the fact how LAMMPS consider effect of thermodynamic ensemble while doing MSD compute,

• from examples, I see they did 5000 steps nve equilibrium run before 100000 steos data gathering run where sole effect is to calculate MSD vector dynamically. does that mean 100000 steps data gahering is being performed under nve ensemble? shouldn’t I add compute insdie ensemble run ?
• moreover , its mentioned in restrictions ‘’ Compute msd cannot be used with a dynamic group.’ I think from this they are refering to conservation of mass.is that true ?

LAMMPS does not deal with thermodynamics ensemble directly. `fix nve` is an integrator of position that uses Newton’s equation of motion, `fix nvt` and `fix npt` are integrator using extended hamiltonians as developed in the reference papers. The thermodynamic ensemble are retrieved for periodic bulk systems as has often been discussed in the forum.

I see they did 5000 steps nve equilibrium run before 100000 steos data gathering run where sole effect is to calculate MSD vector dynamically.

Who is “they”? What are you referring to? What do you mean by calculate MSD vector “dynamically”?

its mentioned in restrictions ‘’ Compute msd cannot be used with a dynamic group.’ I think from this they are refering to conservation of mass.is that true ?

The reason `compute msd` cannot be used with dynamic group is because of the way MSD is computed on the fly by LAMMPS: the initial positions of atoms in the group is saved and the average of the square of the distances is computed with regard to these initial positions. If the atoms in the group change, as is the purpose of a dynamic group, the computation simply makes no sense.

hI @Germain Thanks for your comments, i am sorry if i couldn’t write it clearly

I understand the meaning of imposing thermodynamic ensemble using fix command very well. my question is very simple and it is connected to the 2nd comment so I am stating it in next paragraph

From they I am refereing to the LAMMPS to MSD calculation. performed for Diffusivity calculation in the LAMMPS example, where they followed the mentioned procedure. by ‘dynamically’ I want to refer continuous measurement of MSD at each time step throughout the calculation. Here my question is, whe you equilibrate system using nve for 5000 steps and than after doing unfix(as you can check in the attached input) they start another simulation just to gather MSD data. so will it retain. the same fix nve setting for 100000. ? if no , under which thermodynamics conditions LAMMPS will calculate MSD ?

here is the input

irslanullahashraf@Arslans-MacBook-Air DIFFUSE % vim in.msd.2d

# settings

variable x equal 40
variable y equal 40

variable rho equal 0.6
variable t equal 1.0
variable rc equal 2.5

# problem setup

units lj
dimension 2
atom_style atomic
neigh_modify delay 0 every 1

lattice sq2 \${rho}
region simbox block 0 \$x 0 \$y -0.1 0.1
create_box 1 simbox
create_atoms 1 box

pair_style lj/cut \${rc}
pair_coeff * * 1 1

mass * 1.0
velocity all create \$t 97287

fix 1 all nve
fix 2 all langevin \$t \$t 0.1 498094
fix 3 all enforce2d

thermo 1000
run 5000

unfix 2

reset_timestep 0

# factor of 4 in 2 variables is for 2d

compute msd all msd com yes
variable twopoint equal c_msd[4]/4/(stepdt+1.0e-6)
fix 9 all vector 10 c_msd[4]
variable fitslope equal slope(f_9)/4/(10
dt)

thermo_style custom step temp c_msd[4] v_twopoint v_fitslope

# only need to run for 10K steps to make a good 100-frame movie

dump 1 all custom 1 tmp.dump id type vx vy vz

dump 2 all image 100 image.*.jpg type type zoom 1.6 adiam 1.2

“in.msd.2d” 62L, 1281B
"

Please note that these are a lot of context information that you did not give in your initial question and that could not be guessed from readers.

Allow me now to comment your statements. When you say:

I understand the meaning of imposing thermodynamic ensemble using fix command very well.