Jump to content

Rep:Thermomp4114

From ChemWiki

Molecular Dynamics Simulations of Simple Liquids Introduction

Molecular dynamic simulations involved studying the motion of a system of particles. Several fundamental elements of a system need to be known in order to achieve this. This includes a knowledge of the interaction potential for the particles and the equations of motion which govern the dynamics of the particles.1 Once we know the positions, velocities, and forces, of the atoms (which are obtained using statistical) we can calculate various thermodynamic quantities of the system such as temperature and pressure. We must introduce a series of approximations in order for the caluculations to be feasible. Firstly we apply the The Classical Particle Approximation. The schoedinger equation is too complex to solve for a large system of atoms, however if the atoms are treated classically then the positions and and velocities of each can atom can be calculated using Newton's second law (equation 1):


Fi=miai=midvidt=mid2xidt2(1)


As there are N atoms and therefore N equations representing each atom a computer is a necessity. The Verlet algorithim is used to solve to Newton's law for all the atoms in the system. In this case time is not continuous but is made discrete, the simulation is thus broeken up into specific timesteps.

The position of atom i at time t is given by xi(t).

Positional Verlet algorithim (equation (2)):

xi(t+δt)2xi(t)xi(tδt)+Fi(t)miδt2(2)

(Velocity Verlet algorithim (equation (3)):

vi(t) represents the velocity of that atom at time t.


vi(t+δt)=vi(t+12δt)+12ai(t+δt)δt(3)

Put in example of industrial applications

Harmonic Oscillator

The harmonic oscillator illustrates the the accuracy and discrepancies associated with using the velocity Verlet algorithim. Equation (4) is used to model the behavior of the harmonic oscillator in an analytical sense:


x(t)=Acos(ωt+ϕ)(4)

ϕ = 0.00
ω = 1.00
A = 1.00

Graph (1) illustrates the results the analytical solution gave for the relationship between position and time.



Graph 1: Analytical solution of harmonic oscillator




The difference in position between the velocity-verlet solution and analytical solution is represented by an error. Error plotted against time is illustrated by graph (2).


Graph 2: Error vrs Time


The orange line illustrates the positive trend between error and time. This shows that error is accumulative with time. Each timestep represents a calculation which has an associated error thus as the simulation proceeds the errors will be summed.


The total energy of the system will consist of the sum of kinetic and potential energy. Equation (5) can be used to find kinetic energy of the system:


Ek=12mv(t)2(5)


When x(t) is used in equation (5) the potential energy can be found.

The following graphs represent the difference in change in energy with time when the timestep is varied.

Energy change when a timestep of 0.1 is used
Energy change when a timestep of 0.15 is used
Energy change when a timestep of 0.2 is used

The maximum change in energy for each of the different timesteps is shown in table (1).


Timestep 0.1 0.15 0.2
Max. change in Energy 0.2% 0.6% 1%

The results clearly indicate that a timestep greater than 0.2 will result in an energy change greater than 1%. As the timestep increases as does the maximum error. The timestep defines the number of calculations made in a given time, therefore the shorter the timestep the larger the number of calculations carried out and therefore a more accurate result is produced. The total energy of a real physical system should not change, when modeled numerically there can be fluctuations therefore it is important to monitor this change and ensure that the fluctuations are minimised.

Atomic Forces

The forces an atom experiences is determined by the positions of all the atoms in the system, rN. The Lennard-Jones function accurately sums all the key inter-atomic forces an atoms experiences (U).

U(rN)=iNijN{4ϵ(σ12rij12σ6rij6)}(10)

For a single Lennard-Jones interaction:

ϕ(r)=4ϵ(σ12r12σ6r6)

The separation, r0, at which the potential energy is zero is given by:

0=4ϵ(σ12r012σ6r06)

After division by 4 and rearrangement:

σ6r06=σ6r06

After further rearrangement and cancelling down:

r0=σ

σ is also a solution however this can be disregarded.

In order to calculate the force the following equation is used:

F=dσ(r)dr

After differentiation and simplification:

F(r0)=24ϵσ

At equilibrium:

dϕ(re)dr = 0

4ϵ(12σ12re136σ6re7) = 0

After rearrangement:

re=21/6σ

This value of re can now be used to find the well depth:


4ϵ(σ124sigma12σ62σ6)

When σ=ϵ=1.0

2σϕ(r)dr = 4ϵ(15r5111r11)22.48102

2.5σϕ(r)dr = 8.18103

3σϕ(r)dr = 3.29103

Periodic Boundary Conditions

  • No. of moles in 1 mL of water = 0.056
  • No. of molecules = moles x Avogadro's constant = 3.37 x 1022


  • 1000 molecules = 1.66 x 1021 moles
  • Density = mass/vol. = 1
  • vol. = mass/density = 2.99 x 10-20


  • Due to periodic boundary condition once the atom leaves the current box it will enter the beginning of an identical box. The atom is at (0.5,0.5,0.5) and thus once it breaches 0.5 in a particular direction it will be at the start of the next box. Using these principles after the atom moves (0.7,0.6,0.2) it will be at the point (0.2,0.1,0.7)

Reduced Units

Reduced units are applied to the Lennard-Jones equation to make the calculation more managable.

  • distance r*=rσ
  • energy E*=Eϵ
  • temperature T*=kBTϵ


For argon:


  • Distance in real units: r = 1.09 x 10-7 cm-1
  • Well depth = ϵ = 0.996 KJmol-1
  • T = 180 K

Equilibriation

Simulation Box

As there is a large number of atoms in a discrete volume allowing random assignment of positions could result in atoms overlapping. This would cause an unrealistically high potential as potential is distance dependant (as observed in the Lennard - Jones equation).

  • Density is given by the following equation:

ρ=nv

n = 1 (as there is only 1 atom per unit cell)

v=1.077223=1.25 (lattice spacing = 1.07722)

Thus:

ρ=11.25=0.8

The length of a side of one fcc unit cell with number density 1.2 would be:

v=nρ

n = 4 (as there is 4 atoms per unit cell in an fcc lattice)

v = 3.33

l=v3=1.49

  • The number of atoms that would be created by the create_atoms command for an fcc lattice would be:

4 x 1000 = 4000

This is due to fact that there is 1 atom per unit cell that yeilds 1000 altogether in simple cubic. Fcc has 4 times the number of atoms per unit cell.

Setting the Properties of Atoms

mass 1 1.0
pair_style lj/cut 3.0
pair_coeff * * 1.0 1.0

The command above has the following purpose:

  • The first line sets the mass of all atoms of type '1' to 1.0.
  • Line 2 is used to control the Lennard-Jones potential. The value of 3.0 indicates the distance in reduced units upon which the potential is calculated. The potential is distance dependent and falls to 0 at large values of r thus only atoms within a distance of 3.0 are considered. 'lj/cut' defines the cut off point.
  • The last line defines the force field constants as 1.0 for all sets of atoms. The * controls the fact that the command is set for all atoms.

The velocity-Verlet is the integration algorithm that can be used when xi(0) and vi(0) are defined.

### SPECIFY TIMESTEP ###
variable timestep equal 0.001
variable n_steps equal floor(100/${timestep})
variable n_steps equal floor(100/0.001)
timestep ${timestep}
timestep 0.001

### RUN SIMULATION ###
run ${n_steps}
run 100000

The second line (starting "variable timestep...") tells LAMMPS that if it encounters the text ${timestep} on a subsequent line, it should replace it by the value given. In this case, the value ${timestep} is always replaced by 0.001. In light of this, what do you think the purpose of these lines is? Why not just write:

timestep 0.001
run 100000


The codes is in place to ensure that the timestep can be varied but the total time taken for the simulation to run will not change.

Checking equilibration

The graphs below illustrate the time it takes for different thermodynamic properties to equilibriate at a timestep of 0.001. The plateau represents the point at which equilibration is achieved.

Energy Vrs Time
Temp vrs Time
Pressure Vrs Time

The graph below illustrates the effect changing the timestep has on equilibration. As can be seen from the graph a from below 0.01 a shorter timestep results in a lower energy value for equilibration until 0.0025 where the value of equilibration does not change with lower timestep. This trend is due to the fact that a smaller timestep results in a more accurate result however if it is too small this can over-complicate the calculation (especially when there is a large over-all time). Thus a timestep of 0.0025 is a good balance and therefore ideal. A timestep of 0.025 is too large and results in the system not reaching equilibrium.


Energy Vrs Time with different timesteps

Running Simulations Under Specific Conditions

The following two equations can be used to define the energy of the system:


EK=32NkBT

12imivi2=32NkBT

The instantaneous tempertaure T will not remain constant throughout the simulation and will fluctuate, it will thus be different to out target temperature 𝔗.

The value of γ so that the temperature is correct T=𝔗 if we multiply every velocity γ is as follows:

γ212imivi2=32NkB𝔗

γ232NkBT=32NkB𝔗

γ2T=𝔗

γ2=𝔗T

γ=(𝔗T)1/2

 fix aves all ave/time 100 1000 100000 v_dens v_temp v_press v_dens2 v_temp2 v_press2
run 100000

Within the preceding code:

100 - Nevery: This command results in a sample being taken every 100 steps and being incorporated into the average. 1000 - Nrepreat: Tells the computer how many samples should be used to calculate the average. Nfreq 10 000: At every 10000th timestep an average is calculated.

All thermodynamic properties are calculated by averages that is the necessity for those commands.

Plotting the Equation of State

Density Vrs Temp

The densities produced from the simulation are lower than for the ideal gas. This is a result of the simulation creating a more realistic picture of how the atoms interact as it takes into account Lennard-Jones potential. In an ideal gas the motion of atoms will be random, chaotic and inter atomic interactions are ignored however in the simulation the atoms will want to minimize their potential and therefore this will drive them to occupy a greater volume thus reducing the density.

Calculating Heat Capacities Using Statistic Physics

Example of input code used:

  • Density 0.2
  • Temperature 2.0

SPECIFY TIMESTEP

RUN SIMULATION TO MELT CRYSTAL 

run 10000
unfix nve
reset_timestep 0

BRING SYSTEM TO REQUIRED STATE
variable tdamp equal ${timestep}*100
variable ddamp equal ${timestep}*1000
fix nvt all nvt temp ${T} ${T} ${tdamp}
run 10000
reset_timestep 0

MEASURE SYSTEM STATE
unfix nvt
fix nvt all nvt temp ${T} ${T} ${tdamp}
thermo_style custom step etotal temp press density
variable etot equal etotal
variable etot2 equal etotal*etotal
variable temp equal temp
fix aves all ave/time 100 1000 100000 v_etot v_temp v_etot2
run 100000

variable aveetot equal f_aves[1]
variable avetemp equal f_aves[2]
variable aveetot2 equal f_aves[3]
variable varetot equal f_aves[3]-f_aves[1]*f_aves[1]


print "Averages"
print "--------"
print "Temperature: ${avetemp}"
print "Energy Variance: ${varetot}"

The following equation was then used to calculate heat capacity from the results:

CV=Var[E]kBT2


Heat Capacity Vrs Temp


CV=ET=Var[E]kBT2=N2E2E2kBT2

For a fixed number of particles, N, a larger density is indicative of a smaller volume. That is why the plot Cv\V Vrs T generally lies at a higher values for a density of 0.8.

From both plots it can been seen that heat capacity increases with temperature. Var[E] increases with temp as at higher temp there are a greater number of accessible rotational, vibration, electronic and kinetic energetic states therefore the system is able to to absorb more energy per rise in temperature.

Structural Properties and the Radial Distribution function

RDF at different phases
Integral of g(r)

To carry out the RDF calculations temperature was kept constant at 1.2 but density was varied.

Density in reduced units used for each phase:

  • Gas = 0.05
  • Liquid = 0.8
  • Solid = 1.2

The number of peaks for each RDF plot decreases in the order gas<liquid<solid. This reflects the ordering of each phase. A gas has a large degree of disorder and thus produces only peak. The liquid has three peaks which gradually decrease in amplitude, this behavior is due to the fact that the liquid is modeled as central molecule surrounded by shells of other molecules, this initially creates some degree of order. As the simulation continues the molecules become more diffuse so the ordering decreases and thus the amplitude of peaks decrease.


The above plot indicates the positions of the first three peaks. These will correspond to the three closet atoms in the lattice.

  • 1.025 will correspond to one of the atoms at the corner of the unit cell neighboring the starting position.
  • 1.525 will correspond to one of the atoms in the centre of the face of the cube. (The lattice is fcc)
  • 1.825 will correspond to an atom on one of the faces adjacent to the starting point. It cannot be one of the adjacent corners as this would be too large thus it must fall in between the corners and therefore on a face.

Dynamical Properties and the diffusion coefficient

solid
liquid
gas

The plot give insight into the displacement of particles as they illustrate mean square displacement with time. There are variations in the shape of the lines for the large number of atoms and small number of atoms, this is due to the variations in positions being averaged for a large number of atoms and thus gives a better indication of the behavior of the system. The difference is very apparent for solid where one can see that the line is much more smooth in the region where the gradient becomes close to 0.

The diffusion constant D was found by calculating the gradient of the line for each phase. The gradient after the line had leveled off was used for the solid.

D (small System) D (Large System)
Vapour Phase 0.0304 0.0305
Liquid Phase 0.001 0.0012
Solid Phase 6x108 7x109

There is a gradual decrease in D in the order solid<liquid<gas. This fits out chemical intuition; e.g. the motion of a solid would be much more restricted that the motion of a gas.

VACF vrs Temperature

Minima in the VACF plot correspond to points where the atoms collide and change direction. The greater number of minima for a solid is due to the restricted mean square displacement in which the atoms can move, this therefore results in greater collisions as the atoms seek to minimize their potential energy. As a liquid has a greater diffusion coefficient it is able to diffuse away from an atom after a collision, this is why there are fewer minima, the line tends to 0 as the atoms eventually move in opposite directions resulting in velocities cancelling out and therefor the integration becomes 0. The harmonic oscillator is simply a mathematical function without physical meaning therefore it will continue to oscillate around 0 until infinity.

The normalised velocity autocorrelation function for a 1D harmonic oscillator can be evaluated using the equation for a 1D harmonic oscillator.

C(τ)=v(t)v(t+τ)dtv2(t)dt

x(t)=Acos(ωt+ϕ)

Differentiation of the displacement function will produce a velocity function:

dxdt=Aωsin(ωt+ϕ)=v(t)

v(t+τ)=Aωsin(ωt+ωτ+ϕ)

Substitution into velocity autocorrelation:

C(τ)=Aωsin(ωt+ϕ)Aωsin(ωt+ωτ+ϕ)dtAωsin(ωt+ϕ)Aωsin(ωt+ϕ)dt

Cancelling -A\omega:

C(τ)=sin(ωt+ϕ)sin(ωt+ωτ+ϕ)dtsin2(ωt+ϕ)dt

Trigometric relation can simplify equation:

sin(ωt+ωτ+ϕ)=cos(ωτ+ϕ)sin(tω)+sin(ωτ+ϕ)cos(tω)

C(τ)=cos(ωτ+ϕ)sin(tω)+sin(ωτ+ϕ)cos(tω)dtsin2(ωt+ϕ)dt

Integration of ansymmetical function results in 0:

sin(x)cos(x)dt=0

Thus after cos(tω)is removed from top line the equation simplifies to:

C(τ)=cos(tω)



Vapour Phase
Vapour Phase of 1 million atoms
Solid Phase
Solid Phase of 1 million atoms
Liquid Phase
Liquid Phase of 1 million atoms
D (small System) D (Large System)
Vapour Phase 1.64 1.63
Liquid Phase -0.2215 0.157
Solid Phase 0.254 -0.123


Using the trapezium rule to calculate D from a VACF plot yeilded a similar trend in diffusion coefficients however there was a discrepancy in one of my results. The value of D for a liquid of small number of atoms was smaller and more negative than the solid. This indictaes that using the MSD method is more accurate than VACF. This also indicates that it is more important to use the VACF plot for a large system when calculating D.

References

1. Mark Klarpus, Gregory A. Petsko, (1990) Molecular Reaction Dynamics in Biology, 347, 631-9, doi:10.1038/347631a0