Rep:Mod:nhl13
Simulation of a simple liquid
Introduction to Molecular Dynamics Simulation
TASK 1: Open the file HO.xls. In it, the velocity-Verlet algorithm is used to model the behaviour of a classical harmonic oscillator. Complete the three columns "ANALYTICAL", "ERROR", and "ENERGY": "ANALYTICAL" should contain the value of the classical solution for the position at time , "ERROR" should contain the absolute difference between "ANALYTICAL" and the velocity-Verlet solution (i.e. ERROR should always be positive -- make sure you leave the half step rows blank!), and "ENERGY" should contain the total energy of the oscillator for the velocity-Verlet solution. Remember that the position of a classical harmonic oscillator is given by (the values of , , and are worked out for you in the sheet).

Analytical position of a classical harmonic oscillator was plotted in figure 1, where the analytical position was calculated by equation:
,
where
The total energy of the classical harmonic oscillator for the velocity-Verlet solution was calculated by equation:
,
For a classical harmonic oscillator, and ,
and x(t) from velocity-Verlet solution was used instead of analytical x(t).
The total energy of the oscillator was plotted in figure 2. The energy fluctuated between 0.500 and 0.49875, which was relatively small when compared to the maximum total energy, i.e. 0.25% of the total energy.
The error in position between classical solution and velocity-Verlet solution was plotted in figure 3. It showed that the error gradually increased with time.
TASK 2: For the default timestep value, 0.1, estimate the positions of the maxima in the ERROR column as a function of time. Make a plot showing these values as a function of time, and fit an appropriate function to the data.
Figure 4 showed the maxima of error in position between the classical and velocity-Verlet solution respectively was plotted against time. It gave a straight line with a positive slope that indicated the error was directly proportional to time. The corresponding function was y = 0.0004x, when the line was set to intercept at origin.
TASK 3: Experiment with different values of the timestep. What sort of a timestep do you need to use to ensure that the total energy does not change by more than 1% over the course of your "simulation"? Why do you think it is important to monitor the total energy of a physical system when modelling its behaviour numerically?
The maximum total energy of the harmonic oscillator was 0.500. From figure 5, the degree of fluctuation increased when time step increased. The total energy had a fluctuation of 5x10^-3, i.e. 1% of the maximum energy, when the timestep reached 0.20 s. Hence, the timestep had to be equal or smaller than 0.20 s in order to obtain an accurate simulation.
TASK 4.1: For a single Lennard-Jones interaction, , find the separation, , at which the potential energy is zero.
When potential energy ,
TASK 4.2: What is the force at this separation?
F (r) = - dU/dr
F (r) = - d [4 ε (σ12 / r12) + 4 ε (σ6 / r06)] / dr
F (r) = d [ - 4 ε (σ12 / r12) + 4 ε (σ6 / r06)] / dr
F (r) = d [ - 4 ε (σ12 r-12) + 4 ε (σ6 r-6)] / dr
F (r) = 48 ε σ12 r-13 - 24 ε σ6 r-7
When r = r0, r0 = σ
F (r0) = 48 ε σ12 σ-13 - 24 ε σ6 σ-7
F (r0) = 48 ε σ-1 - 24 ε σ-1
F (r0) = 24 ε / σ
TASK 4.3: Find the equilibrium separation, , and work out the well depth ().
When F = 0, r = req
F (r) = 48 ε σ12 r-13 - 24 ε σ6 r-7
0 = 48 ε σ12 req-13 - 24 ε σ6 req-7
48 ε σ12 req-13 = 24 ε σ6 req-7
2 σ12 / σ6 = req13 / req7
2 σ6 = req6
req = 21/6 σ
When req = 21/6 σ,
Φ = 4 ε [(σ12 /r12 ) - (σ6 / r6)]
Φ = 4 ε {[σ12 /(21/6 σ)12] - [σ6 / (21/6 σ)6]}
Φ = 4 ε [(1/4) - (1/2)]
Φ = - ε
TASK 4.4: Evaluate the integrals , , and when .
When
= ʃ 4 ε [(σ12 / r12 ) - (σ6 / r6)] dr
= [-4 / 11 r11 + 4 / 5 r5]
Therefore,
= -0.0248
= -0.00818
= -0.00329
TASK 5: Estimate the number of water molecules in 1 ml of water under standard conditions. Estimate the volume of water molecules under standard conditions.
Density of water = 1 g cm-3
Mass of water in 1 ml of water = 1 g
No. of moles in 1 ml of water = 1 g ÷ 18.0 g mol-1 = 0.0556 mol
No. of water molecules in 1 ml of water = 0.0556 mol × 6.022×1023 = 3.34×1022 molecules
No. of moles of 10000 water molecules = 10000 ÷ 6.022×1022 = 1.66×10-20 mol
Mass of 10000 water molecules = 1.66×10-20 mol × 18.0 g mol-1 = 2.99×10-19 g
volume of 10000 water molecules = 2.99×10-19 g ÷ 1 g cm-1 = 2.99×10-19 ml
TASK 6: Consider an atom at position in a cubic simulation box which runs from to . In a single timestep, it moves along the vector . At what point does it end up, after the periodic boundary conditions have been applied?.
Periodic boundary condition states that boxes are repeated infinitely in all direction, hence, if one molecule exits the boundary of the original box, one molecule from the replicated box enters the original box through the opposite face to retain the number of molecules. As a result, we could work out the final position of the atom simply by adding the movement vector to its initial position vector, i.e. (0.5, 0.5, 0.5) + (0.7, 0.6, 0.2) = (1.2, 1.1, 0.7). As the box had a dimension of (1.0, 1.0, 1.0), so the resulting position vector was (0.2, 0.1, 0.7).
TASK 7.1: The Lennard-Jones parameters for argon are . If the LJ cutoff is , what is it in real units?
r* = r / σ
r = r* σ
r = (3.2)(0.34×10-9)
r = 1.088 nm
TASK 7.2: What is the well depth in ?
Φ = - ε, as calculated above, and ε / kB = 120K
Φ = - 120 × kB
Φ = - 1.66×10-21 J ÷ 1000 × NA
Φ = 0.998 kJmol-1
TASK 7.3: What is the reduced temperature in real units?
T* = kBT ÷ ε
T = (T*)(ε) ÷ kB
T = (1.5)(120)(kB) ÷ kB
T = (1.5)(120)
T = 180 K
Equilibration
TASK 8: Why do you think giving atoms random starting coordinates causes problems in simulations? Hint: what happens if two atoms happen to be generated close together?
In liquid, molecules are held together by intermolecular bonds. They are not fixed and can flow around and have a certain average intermolecular distance. If the molecules are too far apart, the attractive interaction between them is not as strong as it used to and behaves as gas instead of liquid. In contrast, if molecules are too close together, they experience a repulsion force between them. The liquid simulation would be affected in both extremes.
TASK 9: Satisfy yourself that this lattice spacing corresponds to a number density of lattice points of . Consider instead a face-centred cubic lattice with a lattice point number density of 1.2. What is the side length of the cubic unit cell?
can be used to rationalise the relationship between the number density, and the lattice spacing, a.
Case 1: In a simple cubic lattice, there is only 1 atom inside a lattice unit cell.
This result agreed with the value obtained from LAMMPS simulation, i.e. lattice spacing in x,y,z = 1.07722 1.07722 1.07722
Case 2: In a face-centred cubic lattice, there are 1 atom at each corner and 1 atom on each face. Atom at the corner and on the face contribute to and atom to the lattice. Hence, number of atom in a fcc lattice =
Therefore, a fcc lattice with a number density of 1.2 will have a side length of 1.494 m.
TASK 10: Consider again the face-centred cubic lattice from the previous task. How many atoms would be created by the create_atoms command if you had defined that lattice instead?
Each fcc unit cell consists of 4 atoms. With the same 10×10×10 box, i.e. 1000 lattice unit cells, hence, fcc lattice will consist of 4 × 1000 = 4000 atoms.
TASK 11: Using the LAMMPS manual, find the purpose of the following commands in the input script:
mass 1 1.0
Syntax of the command
mass I value
Mass command defines the mass of atoms, where I is the number of atom type and value is the mass of atom. In our case, there is only 1 type of atom and its mass is 1.0 in reduced unit.
pair_style lj/cut 3.0
Syntax of the command
pair_style style args
pair_style command compute different styles of pairwise interaction. The second ''style'' defines a particular type of pairwise interaction, and the ''args'' is the arguments used by that particular style. In our case, lj/cut is used to compute the cutoff Lennard-Jones potential with no Coulomb, and the cutoff potential is set at 3.0 reduced unit.
pair_coeff * * 1.0 1.0
Syntax of the command
pair_coeff command specifies the pairwise force field coefficients for one or more pairs of atom types. ''I,J'' is the atom types and ''args'' is the coefficients for one or more pairs of atom types. In out case, I and J equal * which means there is N types of atom and means all types from 1 to N, and both coefficients are set at 1.0.
TASK 12: Given that we are specifying and , which integration algorithm are we going to use?
We are using Velocity Verlet Algorithm, see below.
TASK 13: Look at the lines below.
### 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
Those extra lines would allow the variable to change automatically when timestep in the second line is changed.
TASK 14: make plots of the energy, temperature, and pressure, against time for the 0.001 timestep experiment (attach a picture to your report). Does the simulation reach equilibrium? How long does this take? When you have done this, make a single plot which shows the energy versus time for all of the timesteps (again, attach a picture to your report). Choosing a timestep is a balancing act: the shorter the timestep, the more accurately the results of your simulation will reflect the physical reality; short timesteps, however, mean that the same number of simulation steps cover a shorter amount of actual time, and this is very unhelpful if the process you want to study requires observation over a long time. Of the five timesteps that you used, which is the largest to give acceptable results? Which one of the five is a particularly bad choice? Why?
All three properties reached equilibrium after short period of time when timestep was 0.001 s. The total energy (figure 6), temperature (figure 7) and pressure (figure 8) reached the equilibrium after approximately 0.42, 0.32 and 0.25 s respectively. Figure 9 showed the total energy fluctuation against time simulated at different timestep. When timestep was as large as 0.015 s, the total energy did not reach equilibrium. This timestep was not suitable for simulation. When timestep was equal to or lower than 0.01 s, the energy did reach equilibrium. However, the fluctuation of the energy level was quite large when timestep equal 0.01 and 0.075 s. On the other hand, timestep cannot be too short, as it lowers the efficiency of the simulation. As a result, the most acceptable timestep for our simulation to compensate both disadvantages was 0.0025 s.
Running simulations under specific conditions
TASK 15: Choose 5 temperatures (above the critical temperature ), and two pressures (you can get a good idea of what a reasonable pressure is in Lennard-Jones units by looking at the average pressure of your simulations from the last section). This gives ten phase points — five temperatures at each pressure. Create 10 copies of npt.in, and modify each to run a simulation at one of your chosen points. You should be able to use the results of the previous section to choose a timestep. Submit these ten jobs to the HPC portal. While you wait for them to finish, you should read the next section.
In our simulation, timestep of 0.0025 s was used, as it allowed the oscillator to reach equilibrium and had a small fluctuation in energy level. The two pressures used were 2.55 and 2.65 atm, as there were within the range of the pressure equilibrium calculated in the last simulation. Finally, the temperature used were 1.7, 1.9, 2.1, 2.3 and 2.5, where all of them were above the critical temperature.
TASK 16: We need to choose so that the temperature is correct if we multiply every velocity . We can write two equations:
Solve these to determine .
Sub , into
TASK 17: Use the manual page to find out the importance of the three numbers 100 1000 100000. How often will values of the temperature, etc., be sampled for the average? How many measurements contribute to the average? Looking to the following line, how much time will you simulate?
The three number in the command corresponded to Nevery, Nrepeat and Nfreq respectively. Nevery tells how often are the input values to be used for calculation, Nrepeat tells the number of times of each set of input values is used to calculate the average, and Nfreq tells the number of timestep for calculating an average. In our case, i.e. 100 1000 100000, the input values are used every 100 timesteps, the average calculated from input values are repeated for 1000 times, and the averages are calculated every 100000 timesteps. As timestep of 0.0025 s was used, our simulation time would be 100000 x 0.0025 = 250 s
TASK 18: When your simulations have finished, download the log files as before. At the end of the log file, LAMMPS will output the values and errors for the pressure, temperature, and density . Use software of your choice to plot the density as a function of temperature for both of the pressures that you simulated. Your graph(s) should include error bars in both the x and y directions. You should also include a line corresponding to the density predicted by the ideal gas law at that pressure. Is your simulated density lower or higher? Justify this. Does the discrepancy increase or decrease with pressure?
Figure 10 showed that the simulated density decreases with temperature, while increases with pressure. These phenomenons could be rationalised easily. As temperature increases, molecules have higher kinetic energy to overcome the attractive interaction between them, and move apart easier, thus resulting a lower density. On the other hand, when pressure increases, molecules experience a greater compression force and are packed closer together, thus resulting a higher density. Figure 10 also showed that the error in density was much smaller than the error in temperature. On the other hand, the simulated density was much lower than the density calculated from the ideal gas law. It was because the ideal gas law assume there were no repulsive forces between molecules, while the simulation by LAMMPS was able to mimic the repulsive forces between molecules. As consequence, the simulated density was lower as repulsive force between molecules pushed each other away. Moreover, the discrepancy between simulated and calculated density increased when pressure increased. It was because gas would behave more as a real gas rather than ideal gas under higher pressure, hence, the discrepancy increased as ideal gas was no longer relevant to the situation.
Calculating heat capacities using statistical physics
TASK 19: As in the last section, you need to run simulations at ten phase points. In this section, we will be in density-temperature phase space, rather than pressure-temperature phase space. The two densities required at and , and the temperature range is . Plot as a function of temperature, where is the volume of the simulation cell, for both of your densities (on the same graph). Is the trend the one you would expect? Attach an example of one of your input scripts to your report.

Cv/V was plotted against temperature in figure 11. For both density, the simulation indicated the volume of the liquid remain unchanged, i.e. 16875 and 4218.75. The graph showed that the Cv/V decrease with temperature. The extent of decrease was greater when temperature was small and started to decrease slower as temperature increase gradually. However, there was an anomalous when T=2.4, D=0.8, which possibly arose due Brownian motion of the liquid.
Example of the script is shown below, where density is 0.2 and temperature is 2.0.
### DEFINE SIMULATION BOX GEOMETRY ### lattice sc 0.2 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 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 fix nvt all nvt temp ${T} ${T} ${tdamp} run 10000 reset_timestep 0 unfix nvt fix nve all nve ### MEASURE SYSTEM STATE ### thermo_style custom step etotal temp press density atoms vol variable dens equal density variable dens2 equal density*density variable temp equal temp variable temp2 equal temp*temp variable press equal press variable press2 equal press*press variable N equal atoms variable N2 equal atoms*atoms variable etotal equal etotal variable etotal2 equal etotal*etotal variable volume equal vol fix aves all ave/time 100 1000 100000 v_dens v_temp v_press v_etotal v_dens2 v_temp2 v_press2 v_etotal2 run 100000 variable avedens equal f_aves[1] variable avetemp equal f_aves[2] variable avepress equal f_aves[3] variable aveetotal equal f_aves[4] variable aveetotal2 equal f_aves[8] variable Cv equal ${N2}*(${aveetotal2}-${aveetotal}*${aveetotal})/(${avetemp}*${avetemp}) print "Averages" print "--------" print "Density: ${avedens}" print "Temperature: ${avetemp}" print "Pressure: ${avepress}" print "Heat Capacity: ${Cv}" print "Total Energy: ${aveetotal}" print "Total Energy2: ${aveetotal2}" print "Volume: ${volume}" print "No of atoms square: ${N2}"
Structural properties and the radial distribution function
TASK 20: perform simulations of the Lennard-Jones system in the three phases. When each is complete, download the trajectory and calculate and . Plot the RDFs for the three systems on the same axes, and attach a copy to your report. Discuss qualitatively the differences between the three RDFs, and what this tells you about the structure of the system in each phase. In the solid case, illustrate which lattice sites the first three peaks correspond to. What is the lattice spacing? What is the coordination number for each of the first three peaks?
The following table showed the conditions under which the simulations of the Lennard-Jones system were performed.
Temperature | Density | |
---|---|---|
Solid | 1.25 | 1.25 |
Liquid | 1.1 | 0.7 |
Gas | 1.1 | 0.05 |
RDF provides the density of atoms at particular radial distance to a reference atom. Each peak in RDF indicates a particularly favoured separation distance of a neighbouring atom to a reference atom. Thus, RDF reveals the atomic structure of the system being simulated. Figure 12 showed that RDF of solid had lots of sharp peaks, while there were only a few broad peaks for liquid, and just one large broad peak for gas. It revealed atoms in solid were highly ordered and stayed at particular distance to the reference atom. Sharp peaks also indicated the atoms were not spread out randomly but were concentrated at several favoured particular distances. Moreover, the coordination number at favoured particular distances could be determined from the integral of RDF. In contrast, a few peaks in liquid RDF revealed its system was less ordered and atoms were able to move around freely and rarely stay at a particular distance to the reference atom. However, peaks still showed up illustrated that the atoms were still held together by some sort of attraction forces. On the other hand, broad peaks were observed in RDF of liquid and gas, while peak for gas was broader than those for liquid. This could be rationalised by the Brownian motion of the atoms in the system. The atoms in gas had higher kinetic energy, therefore, they could move faster and more randomly and resulted in a broad distribution at particular distance, where the only peak observed indicated the gas atoms were still holding with each other at a maximum interacting distance.
The first three peaks at the RDF of soild appeared at 1.025, 1.475 and 1.825. These corresponded to the first three sets of nearest coordinating neighbours to a reference atom. The simulation shown the lattice spacing, a, was 1.47361, and by visualising the fcc lattice model, we knew the nearest neighbour had a separation of , the second nearest neighbour had a separation of , and the third nearest neighbour had a separation of . When we combined all informations, the lattice spacing between the reference atom and the nearest neighbours could then be calculated by Pythagoras theorem. The results were summarised in the table below.It was found that the peaks in RDF were similar and comparable to the calculated results. On the other hand, the integral of RDF, which was accumulative, showed the coordination number of the neighbouring atoms. This also agreed with the theoretical fcc model. See figure 14 and 15. To conclude, both peak and integral of RDF gave evidence that RDF could be used to determine lattice structure.
no of peak | RDF Peak, Lattice spacing | Calculated lattice spacing | Coordination Number | Integral of RDF |
---|---|---|---|---|
First | 1.025 | 1.042 | 12 | 11.912 |
Second | 1.475 | 1.474 | 6 | 17.8-11.96 |
Third | 1.825 | 1. 805 | 24 | 41.8-17.824 |
Dynamical properties and the diffusion coefficient
TASK 21: In the D subfolder, there is a file liq.in that will run a simulation at specified density and temperature to calculate the mean squared displacement and velocity autocorrelation function of your system. Run one of these simulations for a vapour, liquid, and solid. You have also been given some simulated data from much larger systems (approximately one million atoms). You will need these files later.
The following table shows the conditions under which the simulations were performed.
Temperature | Density | |
---|---|---|
Solid | 1.25 | 1.25 |
Liquid | 1.1 | 0.7 |
Gas | 1.1 | 0.05 |
TASK 22: make a plot for each of your simulations (solid, liquid, and gas), showing the mean squared displacement (the "total" MSD) as a function of timestep. Are these as you would expect? Estimate in each case. Be careful with the units! Repeat this procedure for the MSD data that you were given from the one million atom simulations.



From equation , we can calculate D in reduced unit, D*, from the MSD-timestep graph, i.e. . The timestep of the simulation was 0.002 s, therefore, . The results are illustrated in the table below.
D from MSD | Solid | Liquid | Gas |
---|---|---|---|
Simulated Data | |||
1 Million Atom Data |
The D values obtained were expected. Gas had the highest D among the three, as gas molecules had the highest kinetic energy, and can move around freely with only a little restriction. Liquid had a smaller D value, while liquid molecules can move around freely, but have lower kinetic energy, pack closer together and have less space to move around. In contrast, solid had a very low D value of . It is because solid molecules have the least kinetic energy. Also, they are ordered in a rigid shape, and can only oscillate about its equilibrium position. On the other hand, Simulated data was similar to the 1 million atom data given, which showed consistency of the the simulation.
TASK 23.1: In the theoretical section at the beginning, the equation for the evolution of the position of a 1D harmonic oscillator as a function of time was given. Using this, evaluate the normalised velocity autocorrelation function for a 1D harmonic oscillator (it is analytic!):
The position of the oscillator is defined as
The velocity is the first derivative of the position equation:
Then substitute into the
Now we get:
And can be cancelled out.
Using trigonometry identity:
We know that Sine is an odd function and cosine is an even function. We also know an odd function multiplies an even function gives an odd function, and the integral of an odd function with a symmetrical limit becomes 0.
Therefore,
Therefore, .
TASK 23.2: On the same graph, with x range 0 to 500, plot with and the VACFs from your liquid and solid simulations. What do the minima in the VACFs for the liquid and solid system represent? Discuss the origin of the differences between the liquid and solid VACFs. The harmonic oscillator VACF is very different to the Lennard Jones solid and liquid. Why is this? Attach a copy of your plot to your writeup.
Figure 19 compared the VACF of a solid and a liquid simulation to the normalised classic harmonic oscillator. The solid simulation showed a minima at timestep = 47, while liquid simulation did not give a obvious minima, its function fluctuated about 0 after timestep = 109. Minima was observed because there were atom collisions in the solid and liquid simulations, and caused a change in velocity direction. Moreover, collisions in Lennard-Jones system led to loss of velocity and loss of energy, hence, the VACF was no longer correlated to time at very long time and remained at 0. In contrast, the VACF of harmonic oscillator gave a periodic function because there was no atom collision within the system. Therefore, no lost of energy and the oscillator would oscillate forever.

TASK 24: Use the trapezium rule to approximate the integral under the velocity autocorrelation function for the solid, liquid, and gas, and use these values to estimate in each case. You should make a plot of the running integral in each case. Are they as you expect? Repeat this procedure for the VACF data that you were given from the one million atom simulations. What do you think is the largest source of error in your estimates of D from the VACF?
Diffusion coefficient could be calculated from equation:
Hence,

The results were compared with the D calculated from MSD and were showed in the table below.
D from VACF | Solid | Liquid | Gas | D from MSD | Solid | Liquid | Gas |
---|---|---|---|---|---|---|---|
Simulated Data | Simulated Data | ||||||
1 Million Atom Data | 1 Million Atom Data |

The diffusion coefficient, D, obtained from MSD and VACF were not quite the same, however, they did have comparable value in term of the magnitude. D of solid was almost zero for both calculations. D calculated from VACF was 100 times larger than that from MSD. In contrast, two calculated D values for liquid were similar and were comparable, even for both 1 atom simulation and 1 million atom simulation. The D value obtained for 1 million atom simulation were similar to those for 1 atom simulation. The largest source of error for estimate D from VACF was that it was only an approximation of the integral.



