Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

Molecular Dynamics Simulation of a

Lennard-Jones Model System

December 2021

1 Introduction
Computer simulation methods provide an alternative approach, other than
experimental and analytical approaches, to study and understand various
physical phenomena. These methods have a strong foundation from Classical
Mechanics, Electrodynamics, Statistical Physics and Quantum Mechanics.
In this lab you will be studying the phase behaviour of one of the most
widely used model system (Lennard-Jones System) using classical Molecular
Dynamics (MD) simulation.

1.1 Basics of Molecular Dynamics [1, 2]


Molecular Dynamics is a simulation technique used for computing equilib-
rium properties of a classical many-body system. Here the word classical
means that the nuclear motion of the constituent particles obeys the laws of
classical mechanics. This is a good approximation for a wide range of mate-
rials. Molecular Dynamics simulations are quite similar to real experiments.
Often in a real experiment, we prepare a sample of the material of interest,
connect this sample to a measuring instrument to measure the property of
interest during a certain time interval. These measurements are subject to
statistical noise and hence we average over multiple measurements. In MD
simulation, we follow exactly the same approach. We select a model system
consisting of N particles characterised by it’s coordinates and momenta. Fur-
ther we solve Newton’s equations of motion and evolve the system in time
until the properties of the system no longer change with time. After reaching

1
the equilibrium state we perform the actual measurement of the quantities
of interest.
MD Program: A simple MD program can be constructed as follows:

1. Read in the parameters that specify the conditions of the in-silico ex-
periment (e.g., initial temperature, number of particles, density, time
step for numerical integration of Newton’s equation of motion etc.,).

2. Initialize the system defining the initial positions and velocities. The
positions can be initialized either as a crystal (periodic) or as a dis-
ordered (random) system. Initial velocity can be obtained from the
Maxwell-Boltzmann distribution (at a chosen T).

3. A suitable model potential is chosen. In this lab, we will use the


Lennard-Jones (LJ) interaction potential given by
 !12 !6 
σij σij
U (rij ) = 4ϵ  −  + U (rc ) for r ≤ rc (1)
rij rij

where rij is the distance between any two particles i and j, σij is the
diameter of a particle, ϵ is the depth of the potential. The interaction
potential is truncated at rc = 2.5σij , beyond which U (rij ) = 0 (see Fig.
1).

4. Compute the forces on all particles (F⃗ij = −∇U (rij ))

5. Integrate the Newton’s equations of motion. This is carried out uti-


lizing numerical integration methods (eg., Euler’s method, Leap-Frog
method etc.,), which requires a time step ∆t that determines the short-
est accessible time in the simulations. Step [4.] and [5.] is the core of
MD simulation. They constitute what is called as 1 MD time step. We
repeat this and hence perform multiple MD steps to evolve the system
in time.

6. Once the system reaches an equilibrium state, after simulating for suf-
ficient amount of time, we compute the physical observable.

In this lab you will provided with the program [3] that performs MD simu-
lation of LJ potential (truncated and shifted) in NVT ensemble .

2
Figure 1: Lennard-Jones potential profile. Here U=0 at rij = 1 corresponds
to a distane equal to the diameter of the particle. The truncation length is
defined by rc . To keep the U continuous the potential is shifted by U (rc ).
Here ϵ′ = ϵ + U (rc )
.

3
Next we will briefly describe a few average equilibrium quantities that
can measured in a MD simulation.

1.2 Equilibrium quantities - Thermodynamics, Dynamic


and Structural observable
In a MD simulation in NVT ensemble, the inputs parameters that are read
in are density (which specify N and V) and temperature (T). Upon reaching
an equilibrium state, you can measure various thermodynamics, dynamics
and structural properties.

Equilibration: A simple way to determine if the system has reached an


equilibrium state is to observe the time evolution of total energy (E) and
pressure (P). If the average value of E and P are fluctuating over a saturated
value, you can presume that the system has reached equilibrium. The time
taken for a system to attain an equilibrium state is called the Relaxation
time τα . Even though the above procedure can make sure equilibrium, but
it doesn’t provide a good estimate of τα . Beyond the equilibrium time, you
will continue to perform the simulation to obtain good statistics for various
observable. The MD runs performed for reaching an equilibrium state is
called Equilibration run and the MD runs performed to obtain a good
estimate of various quantities is called Data production run. All the
relevant equilibrium quantities are obtained from the data production run.

i. Thermodynamic properties: These include measurement of poten-


tial energy (PE), kinetic energy (KE), total energy (E) and pressure
(P). Here PE is obtained (from Eqn. 1) P Etotal = N1 i U (rij ), KE
P
P 1
is simply i 2N mvi2 , E is sum of PE and KE. The pressure is ob-
tained from the Virial expansion and is given by P = (N kB T /V ) +
(1/3V ) N rij .F⃗ij . All these quantities are outputted by the
P PN
i=1 j=1;j̸=i ⃗
MD program provided to you.

ii. Dynamic properties: We compute two time dependent quantities,


also called as dynamical properties. These include Mean Square Dis-
placement (MSD), diffusion coefficient or diffusivity, Time correlation
function and relaxation time.

4
MSD: This measures the average square distance of a particle in a
given time interval and is defined as
*N +
D
2
E 1 X 2
r (t) ≡ |⃗ri (t) − ⃗ri (0)| (2)
N i=1

where N is the total number of particles. The angular bracket rep-


resents an average over different time origins. At small time interval
particles in the system travel ballistically (with no collisions) and you
find that the MSD is proportional to t2 . The time interval when the
atoms starts to collide with its neighbouring atoms is associated with
the caging regime. After a certain time interval the atoms come out of
the cage and the motion of the atoms can be associated with that of a
random walk. In this regime the MSD is proportional to t and motion
of the atoms is termed as diffusive.

Diffusivity: The slope of the MSD in the diffusion regime is related


to the self-diffusion coefficient or Diffusivity and is given by Einstein-
Smoluchowski equation (for a three dimensional system)

⟨r2 (t)⟩
D = lim (3)
t→∞ 6t
Time correlation function and τα : A time correlation function de-
scribes the variation of microscopic variables (eg., density, spin etc.,)
with time. They quantify how microscopic variables co-vary with one
another, on an average, across time. As a measure of this quantity
we define an self Overlap function as q(t) = N ri (t0 ) − ⃗ri (t + t0 )).
P
i=1 δ(⃗
Numerically we can compute this as
*N +
X
q(t) ≈ (1/N ) w(|⃗r(t0 ) − ⃗r(t0 + t)|) (4)
i=1

where w(x) = 1, if x ≤ a, else w(x) = 0. Here ”a” is obtained from


the MSD plot as the root mean square displacement value at which the
system goes from ballistic to diffusive regime. Note that q(t) = 1 when
the system is fully correlated and goes to q(t) = 0 when uncorrelated.
The time period between the two limits is termed at the correlation
time τα .

5
iii. Structural properties: We measure the structural property from a
space correlation function called radial distribution function g(r). This
quantity g(r) is a 2-point correlation function which is defined as
* +
V XX
g(r) = 2 δ(⃗r − ⃗rij ) (5)
N i j̸=i

where V is the volume of the system, N is the number of atoms, rij


represents the distance between atoms i and j. Physically, 4πr2 ρg(r)dr
gives the number of neighbours a reference atoms has at a distance
between r and r + dr. Here ρ is the number density of the system.
You can obtain the coordination number (Cn ), which is the number of
nearest neighbours to a reference atom, using the relation
Z rm
Cn = ρg(r)4πr2 dr (6)
0

where rm is the distance corresponding to the first minimum of g(r).

Note that the programs for calculating MSD, q(t) and g(r) is already provided
to you. You are expected to (a.) recognize the ballistic and diffusive regime in
the MSD and compute the Diffusivity, (b.) Compute the relaxation time from
the q(t) and (c.) Comment on the g(r) profile and compute the coordination
number.

1.3 Reduced units:


In simulations it is often convenient to express quantities such as tempera-
ture, density, pressure etc., in reduced units. This means that we choose a
convenient unit of energy, length and mass and then express all other quan-
tities in terms of these basic units. In the Lennard-Jones system a natural
(though not unique) choice for our basic units are (a.) Unit of length (σ),
Unit of energy (ϵ) and Unit of mass, m (the mass of each particle
q in the
system). From these units we can define the unit of time as σ (m/ϵ), tem-
perature as ϵ/kB and pressure as ϵ/σ 3 . With these conventions we can define
the following reduced units: E ∗ = E/ϵ, P ∗ = P/(ϵ/σ 3 ), T ∗ = T /(ϵ/kB ) etc.,
Introduction of reduced units enable a simulation model to relate to a real
experiment. The value of σ, ϵ and m can be extracted from the real experi-
ment and hence the simulation data can be mapped to the real data. In all

6
our simulations we take σ = 1, ϵ = 1 and m = 1, since we are not intending
to reproduce any experimental data for current purposes.

2 Simulation Procedure
2.1 Equilibrium and Data production runs
Part 1 : In the first part you will be performing MD simulations for the
following state points (density and temperature). The set of densities are
ρ = 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7 and 0.8 and at each of this density perform
the simulation for the temperatures are T = 1.5, 1.3, 1.1, 0.9 and 0.7. To
perform these simulations you have to use the following command.

./mdsim -in PBLJ.in -var rannum $RANDOM -var rhoin <density_value>


-var tin <temperature_value> -var dumpopt 0 -var samplenum 1 -log
LJ_T<temperature_value>_Rho<density_value>-S1.log

In the place of < density value > and < temperature value > use density
and temperature values respectively, that are provided above. Rest of the
parameters should be kept as it is and only be changed when mentioned
explicitly. In total you will be performing 40 simulations. After performing
these simulations you will find the following output files. Say the simulation
was performed at ρ = 0.1 and T = 1.5, then

i. LJ T1.5 Rho0.1-S1.log - Contains details of the simulations, thermo-


dynamic data as well as the performance details of the computation.

ii. In a directory named data contains LJ T1.5 Rho0.1 S1-equilrun.dat


and LJ T1.5 Rho0.1 S1-datarun.dat. The equilrun.dat file has data re-
lated to the equilibration run and datarun.dat file contain the data
production run. Both these files contains average thermodynamics
properties as a function of MD time step. There are six columns in
each of the file which are as follows - MD Step, Temperature, Pressure,
Potential Energy, Kinetic Energy, Total Energy, Volume and Enthalpy.

iii. The data also contains datarun.dump and equilrun.dump files, which
are also called a MD trajectory files. These files contain particle co-
ordinates and velocities as a function of MD time step (during the
equilibration and data production run). These files can be further

7
processed to visualise the microscopic evolution, compute various mi-
croscopic quantities including MSD, q(t) and g(r). Note that to create
the MD trajectory you have to change the flag dumpopt 0 to dumpopt 1
in the above command. Create the trajectory files for density ρ = 0.3
(and varying temperatures) only. These files will be used in the Part
2 of the lab work.
From the equilrun.dat files you can get a rough estimate of equilibration time
(the time taken for the system to reach a saturated value and fluctuations
around it). From the datarun.dat files you can obtain the average equilibrium
pressure and hence equation of state (measure pressure vs applied density).
This will enable you to recognize the phase behaviour of the model system,
including continuous transition, liquid-gas phase transition as well as critical
point.

Part 2: In the second part you will perform microscopic analysis from
the MD trajectories. For ρ = 0.3 and varying temperature, you will (a.)
Visualise the configuration (b.) Compute the MSD (c.) Compute the q(t)
and (d.) Compute the g(r). To the carryout these four tasks you utilize four
different tools which are

i. Visualisation: In order the visualise the trajectory we use an open


source tool called Ovito [4]. A short introduction to the tool will be
given during the lab session. You will visualisation crystal, liquid and
liquid-gas coexistence.

ii. MSD: The mean square displacement is computed utilizing the follow-
ing command. The MSD calculation is done for all the temperatures
at the fixed density of ρ = 0.3. Say if T = 1.5

./msdcalc.exe 500 data/LJ_T1.5_Rho0.3_S1-datarun.dump


LJ_T1.5_Rho0.3-S1-datarun

This command will create .MSD files containing the MD time step and
mean square displacement information. To plot the MSD data you
will be using a tool called Xmgrace. A short introduction Xmgrace
will be given during the lab session. You will recognize the ballistic
and diffusive regimes and also obtain the diffusion coefficient using the
Eqn. 3.

8
ii Time correlation function q(t): You will compute the q(t) utiliz-
ing the following command. If ρ = 0.3 and T = 1.5

./correlationcalc.exe 500 1.0 data/LJ_T1.5_Rho0.3_S1-datarun.dump


LJ_T1.5_Rho0.3-datarun

This command will create .Corr files containing the MD time step and
q(t). Plot using Xmgrace and fit the data with a0 ∗ exp(−x/a1). Ex-
tract a1, which will be the relaxation time. Another way to obtain the
relaxation time is to compute the time taken by the system to go from
q(t)=1 to q(t)=0.

iii Radial distribution function g(r): You will compute the g(r)
utilizing the following command. If ρ = 0.3 and T = 1.5

./gofr.exe 500 500 1000 data/LJ_T1.5_Rho0.3_S1-datarun.dump


LJ_T1.5_Rho0.3_S1-datarun

9
3 Aim and Objectives
Answer the following questions. Make sure all the plots have labels for axes
as well as labels are with appropriate units.

Q1 What is the value of U at rc = 2.5. Given the interaction potential


(Eqn. 1) write the equation for force between two particles. Comment
on the forces at the truncation distance rc . [1 Mark]

Part I

Q2 Plot total energy vs. MD time step during the equilibration for ρ = 0.3
and varying temperature. Obtain the rough estimate of the relaxation
time and plot τα vs temperature T for ρ = 0.3. Plot the pressure vs.
MD time step during data production run for ρ = 0.3 and varying
temperature. [1 Mark]

Q3 Obtain average pressure from all the 40 simulations. Plot average mea-
sured P vs applied ρ for all the five isotherms T = 1.5, 1.3, 1.1, 0.9 and
0.7 in a single plot. Which of the Isotherms show monotonic behaviour
and which others show a non-monotonic behaviour. Comment on the
behaviour of the isotherms. [2 Marks]

Q3 Visualise the trajectory during equilibration as well as data produc-


tion run (for T = 1.5 and T = 0.7 at ρ = 0.3). Show the snapshots
of the trajectory at the beginning of the simulation as well as at the
end. Comment on the behaviour of the system from these snapshots.
[1 Mark]

Part II

Q4 Plot MSD vs. MD time step for fixed ρ = 0.3 and varying temperatures
in a single plot. Plot the data in log-log axis and recognize the ballistic
and diffusive regimes. Why do you have to use a log-log scale. Obtain
the diffusion coefficient D, in lin-lin axis, from the diffusive regime of
the MSD using the Eqn. 3. Plot measure D vs. applied T. [5 Marks]

Q5 Plot q(t) vs. MD time step for fixed ρ = 0.3 and varying temperatures
in a single plot (in a lin-log axis). Obtain the relaxation time τα . Plot

10
measured τα vs. applied T. Compare the estimates obtained from Q2.
[5 Marks]

Q6 Plot g(r) vs r for fixed ρ = 0.3 and varying temperatures in a single


plot. Comment on the variations in the g(r). Recognize the r at the
first minimum of g(r). Obtain the coordination number using Eqn. 6.
Plot measured Cn vs. applied T. [5 Marks]

4 Useful Linux Commands


1. cat [filename] : Display file’s contents to the standard output device
(usually your monitor).

2. cd /directorypath : Change to directory.

3. clear : Clear a command line screen/window for a fresh start.

4. cp [options] source destination : Copy files and directories.

5. date [options] : Display or set the system date and time.

6. du [options] : Show how much space each file takes up.

7. file [options] filename : Determine what type of data is within a file.

8. grep [options] pattern [filenames] : Search files or output for a particular


pattern.

9. kill [options] pid : Stop a process. If the process refuses to stop, use
kill -9 pid.

10. less [options] [filename] : View the contents of a file one page at a time.

11. ls [options] : List directory contents.

12. mkdir [options] : directory Create a new directory.

13. mv [options] source destination : Rename or move file(s) or directories.

14. ps [options] : Display a snapshot of the currently running processes.

15. pwd : Display the pathname for the current directory.

11
16. tail [options] [filename] : Display the last n lines of a file (the default
is 10).

17. tar [options] filename : Store and extract files from a tarfile (.tar) or
tarball (.tar.gz or .tgz).

18. top : Displays the resources being used on your system. Press q to
exit.

References
[1] Frenkel, Daan, and Berend Smit. Understanding molecular simulation:
from algorithms to applications. Vol. 1. Elsevier, 2001.

[2] Allen, Michael P., and Dominic J. Tildesley. Computer simulation of


liquids. Oxford university press, 2017.

[3] Thompson, Aidan P., H. Metin Aktulga, Richard Berger, Dan S. Bolin-
tineanu, W. Michael Brown, Paul S. Crozier, Pieter J. in’t Veld et al.
”LAMMPS-a flexible simulation tool for particle-based materials mod-
eling at the atomic, meso, and continuum scales.” Computer Physics
Communications (2021): 108171.

[4] Stukowski, Alexander. ”Visualization and analysis of atomistic sim-


ulation data with OVITO–the Open Visualization Tool.” Modelling
and Simulation in Materials Science and Engineering 18, no. 1 (2009):
015012.

12

You might also like