Jump to content

Rep:Modxl9814

From ChemWiki

Theory

Velocity Verlet Algorithm

One way to solve Newton's Second law F=ma is the velocity-Verlet algorithm. By using a Taylor expansion,the atomic positions, velocities and accelerations can be approximated at time t with good precision. The position of atom i, at time t, is denoted by xi(t) and the velocity of the atom at time t is denoted by vi(t). Position at the next timestep t+δt can be expressed by:

xi(t+δt)=xi(t)+dxi(t)dtδt+12!d2xi(t)dt2δt2+13!d3xi(t)dt3δt3+O(δt4)(1)


A single timestep is expressed as:

x(t+δt)=xt+vtδt+12atδt2(2)
v(t+δt)=xt+12(at+δt+at)δt(3)
Fig 1: Classically calculated positions vs. velocity verlet calculated positions

The classical harmonic oscillator can be describe by x(t)=Acos(ωt+ϕ). The errors oscillate through 5 peaks in the simulated time. The plot of the total energy vs. time of the simulated system:

Fig 2:Error vs. time

The cumulative error over a constant interval of time is given by:

error(x(t0+nδt))=O(δt2)[1]


Thus, it can be seen from this equation that the relation between the maxima of the error of the Velocity-Verlet algorithm and δt is quadratically increasing. The graph of the maxima of error vs. time therefore can be fit into the quadratic equation in figure 2.


The total energy of the oscillating system is the sum of the kinetic energy and the potential energy, with Ek=12mv2 and Ep=12kx2. In this case, m=1 and k=1, therefore the equation is E=v2+x22.


Fig 3a:Energy vs. Time at 0.1 timestep with error limites of 0.5% on either side
Fig 3b:Energy vs. Time at 0.2 timestep with error limites of 0.5% on either side

In order for the total energy not to change by more than 1% over the course of the simulation, the timestep needs to be 0.2. It is important to monitor the total energy of the system to ensure that energy conservation is obeyed, the same as the real system.

Periodic Boundary Conditions

1mL=1cm3. The density of water=1g/cm3 under standard consitions (298K, 1atm). So the total mass of 1 mL water= 1g. The number of moles of water molecules=1MH2O=1g18g/mol=0.056moles

Therefore the total number of molecules in 1 mL of water=n×Na=0.056×6.02×1023=3.37×1022

The volume of 10,000 molecules of water=100003.37×1022=2.97×1019

Equilibration

Creating the simulation box

Giving atoms random starting coordinates may make two atoms generated too close together. This will cause the two atoms to collide and arise the repulsion between the two atoms. The repulsive force between the atoms will drive them apart, leading to increase in the potential energy of the system and making it very unstable.

A face-centered cubic lattice has 4 lattice points per unit cell. The side length of the cubic unit cell=41.23=1.49

If 1000 unit cells were generated by the create_atoms command, 4000 atoms would be generated for a FCC lattice.

Setting the properties of the atoms

Mass 1 1.0

This means the mass of the single type of atom is 1.0.

Pair_style lj/cut 3.0

"Pair_style" indicates that the interaction is pairwise interaction. "lj.cut" describes the standard 12/6 Lennard-Jones potential without a Coulombic pairwise interaction. "3.0" indicates that the global cutoff for atoms is at 3.0.

Pair_coeff * *1.0 1.0

"pair_coeff" specifies the pairwise force field coefficients. The two asterisks indicate that the command will apply to all atoms.

If xi and viare specified,the Velocity-Verlet algorithm will be used for this simulation.

Running the simulation

The purpose of defining variable is that we don't need to manually change the numerical timestep each time the timestep needs to be changed. This reduces the human errors that may occur as the timestep only needs to be changed once to the value defined.

Checking equilibration

Fig 4a:Total energy vs. time at 0.001 timestep
Fig 4b: Temperature vs Time at 0.001 timestep
Fig 4c: Pressure vs. Time at 0.001 timestep

The simulation reaches equilibrium at 0.001 timestep as pressure and temperature become constant. It can be seen from pressure and temperature data that the simulation reaches equilibrium at t=0.29.The average pressure value is about 2.61 and the average temperature value is about 1.26.

Fig.5: Graph of energies for all timesteps

It can be seen from Fig 5 that the total energy produced by 0.0025 timestep are very close to those produced by 0.001 timestep. Simulations at 0.0075 and 0.01 also reach equilibrium but the total energies are higher than those produced by 0.001 timestep, thus these timesteps are not very accurate. Therefore the largest timestep to get acceptable results is 0.0025 and the worst choice is 0.015 timestep as the simulation doesn't reach equilibrium.

Running simulations under specific conditions

Examining the Input Script

The numbers 100 1000 100000 indicate the timesteps the input values will be used to compute the averages of density, pressure and temperature. For this simulation, the average will be calculated using values produced by timestep 100,200,...100000. Therefore, 1000 values will be used to calculate the average. The following line tells LAMMPS to run the simulation for 100000 timesteps. 0.0025 timestep will be used. Therefore 250 time units are simulated.

Plotting the Equations of State

Fig.6:Density vs Temperature and Ideal Gas law at p=2.3 and p=2.6
Fig.7:Density calculated by Ideal Gas Law compared to LJ model at P=2.3 and P=2.6


Simulations were conducted at temperatures 2,2.5,3,3.5,5 and pressures 2.3 and 2.6.

Heat Capacity Calculation

In the NVT ensemble, pressures (0.2,0.8) and temperatures (2,2.2,2.4,2.6,2.8) were used to calculate the heat capacity by using the following equation:

CV=ET=Var[E]kBT2=N2E2E2kBT2

The code to run the simulation in the NVT ensemble is as following:

variable density equal 0.2

### DEFINE SIMULATION BOX GEOMETRY ###
lattice sc ${density}
region box block 0 15 0 15 0 15
create_box 1 box
create_atoms 1 box

### DEFINE PHYSICAL PROPERTIES OF ATOMS ###
mass 1 1.0
pair_style lj/cut/opt 3.0
pair_coeff 1 1 1.0 1.0
neighbor 2.0 bin

### SPECIFY THE REQUIRED THERMODYNAMIC STATE ###
variable T equal 2.0
variable p equal 4
variable timestep equal 0.0025

### ASSIGN ATOMIC VELOCITIES ###
velocity all create ${T} 12345 dist gaussian rot yes mom yes

### SPECIFY ENSEMBLE ###
timestep ${timestep}
fix nve all nve

### THERMODYNAMIC OUTPUT CONTROL ###
thermo_style custom time etotal temp press
thermo 10

### RECORD TRAJECTORY ###
dump traj all custom 1000 output-1 id x y z

### 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 pdamp equal ${timestep}*1000
fix nvt all nvt temp ${T} ${T} ${tdamp} 
run 10000
reset_timestep 0

### MEASURE SYSTEM STATE ###
thermo_style custom step etotal temp press atoms density vol
variable dens equal density
variable dens2 equal density*density
variable temp equal temp
variable volume equal vol
variable temp2 equal temp*temp
variable press equal press
variable press2 equal press*press
variable N2 equal atoms*atoms
variable E2 equal etotal*etotal
variable E equal etotal
fix aves all ave/time 100 1000 100000 v_dens v_temp v_press v_dens2 v_temp2 v_press2 v_E v_E2
unfix nvt
fix nve all nve
run 100000

variable avedens equal f_aves[1]
variable avetemp equal f_aves[2]
variable avepress equal f_aves[3]
variable errdens equal sqrt(f_aves[4]-f_aves[1]*f_aves[1])
variable errtemp equal sqrt(f_aves[5]-f_aves[2]*f_aves[2])
variable errpress equal sqrt(f_aves[6]-f_aves[3]*f_aves[3])
variable heatcapacity equal ${N2}*(f_aves[8]-f_aves[7]*f_aves[7])/f_aves[5]
variable CV equal ${heatcapacity}/${volume}

print "Averages"
print "--------"
print "Density: ${avedens}"
print "Stderr: ${errdens}"
print "Temperature: ${avetemp}"
print "Stderr: ${errtemp}"
print "Pressure: ${avepress}"
print "Stderr: ${errpress}"
print "heatcapacity: ${heatcapacity}"
print "volume: ${volume}"
print "heatcapacity/volume: ${CV}"

Fig.8: Cv/V vs. temperature at densities 0.2 and 0.8

Structural properties and the radial distribution function

Fig.9: g(r) vs. r for solid, liquid and gaseous phases

The radial distribution function was plotted for vapour, liquid and solid phases(Fig.9). The densities and temperatures were chosen from the phase diagram for the Lennard-Jones diagram.[2]:

Phase Density Temperature
Vapour 0.1 1.2
Liquid 0.8 1.2
Solid 1.6 1.2


Fig.10: Integral of g(r) vs. interatomic distance for solid phase

Dynamical properties and the diffusion coefficient

Mean Squared Displacement

The mean squared displacement is given by:

MSD(xx0)2=1Nn=1N(xn(t)xn(0))2

For 3375 atoms:

Fig 11a: Liquid simulation at d=0.8, T=1.2
Fig 11b: Gas simulation at d=0.1, T=1.2
Fig 11c: Solid simulation at d=1.6, T=1.2

For 1 million atoms:

Fig 12a: Liquid simulation at d=0.8, T=1.2
Fig 12b: Gas simulation at d=0.1, T=1.2
Fig 12c: Solid simulation at d=1.6, T=1.2

The diffusion coefficient is given by:

D=16δr2δt

δr2 is the slope of the trendline of the mean squared displacement vs. timestep plot. The timestep δt=0.002.

Velocity Autocorrelation Function

The equation of the position of a 1D harmonic oscillator is:

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

v(t)=dxdt, thus:

v(t)=d(Acos(ωt+ϕ)dt=Aωsin(ωt+ϕ)

and

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

Therefore, by substitution:

C(τ)=v(t)v(t+τ)dtv2(t)dt=Aωsin(ωt+ϕ)×Aωsin(ω(t+τ)+ϕ)dt(Aωsin(ωt+ϕ))2dt=(Aω)2sin(ωt+ϕ)sin(ω(t+τ)+ϕ)dt(Aω)2sin2(ωt+ϕ)dt=sin(ωt+ϕ)sin(ω(t+τ)+ϕ)dtsin2(ωt+ϕ)dt

Since sin(x+y)=sin(x)cos(y)+cos(x)sin(y):

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

Since sin(2x)=2sin(x)cos(x):

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

As sin(x) is an odd function, the area above the x-axis and below the x-axis cancel out from negative infinity to positive infinity. Thus, sin(2(ωt+ϕ))=0. therefore:

C(τ)=cos(ωτ)
Fig.14: VACF for solid, liquid and 1D Harmonic Oscillator

The minima in the VACF for the liquid system represent the collisions between the atoms and the solvent molecules and change in direction. The minima in the VACF for the solid system represent the collisions between the atoms and change in direction. The minima for the solid system is lower than the minima for the liquid system because of the stronger interatomic forces. The VACF for the liquid system only has one weak oscillation, this is because the atoms only interact with their closest neighbor. In the VACF for the solid system, there are more oscillations as the atoms can vibrate in fixed positions. The harmonic oscillator VACF is very different to the Lennard Jones liquid and solid as there are no interactions between the atoms so the atoms will always vibrate with constant velocity without loss in energy. Therefore, the amplitude doe not change.

By applying the trapezium rule, integral under VACF can be calculated and running integral can be plotted:

For 3375 atoms:

Fig.15a: running integral vs. time for liquid
Fig.15b: running integral vs. time for solid
Fig.15c: running integral vs. time for gas

For 1 million atoms:

Fig.16a: running integral vs. time for liquid
Fig.16b: running integral vs. time for solid
Fig.16c: running integral vs. time for gas

The diffusion coefficient is calculated by:

D=130dτv(0)v(τ)

The last point of the running integral is 0dτv(0)v(τ).

For 3375 atoms: Liquid: D=13×0.2937=9.79×102; Solid: D=13×5.64×104=1.88×104; Gas: D=13×7.054=2.351;

For 1 million atoms: Liquid: D=13×0.2703=9.01×102; Solid: D=13×1.37×104=4.57×105; Gas: D=13×9.805=3.268.

The diffusion coefficient calculated from this method was largest for gas, followed by liquid and then gas. The coefficients for the larger system were very similar to the ones for the smaller system. The coefficients calculated by MSD were similar to the ones calculated by VACF for liquid and gas, but the coefficient calculated by VACF was larger than the one calculated by MSD for solid. The largest source of error may be that the trapezium rule overestimates the area under the solid curve as the timestep is not small enough.

Reference

  1. https://www.saylor.org/site/wp-content/uploads/2011/06/MA221-6.1.pdf
  2. http://journals.aps.org/pr/abstract/10.1103/PhysRev.184.151