Rep:Jmt12ls
Simulation of a simple liquid
Introduction
Molecular dynamics is an important way to simulate liquids. The interactions between atoms for a specific ensemble in a liquid are studied, over a given time[1]. A number of approximations must be made so that the computations are possible. It is assumed that the particles behave as classical particles and they are subjected to a force which originates from the interactions of the other particles. This force is the reason that the particles accelerate.
Introduction to molecular dynamics simulation
The Harmonic oscillator was modeled using the velocity Verlet algorithm and the following graphs were produced from this. The first graph was made by plotting the value of the classical solution for the harmonic oscilator against time, from 0 seconds to 14.2 seconds. The second graph was an error plot of the absolute difference between the approximate values from the velocity Verlet solution and the values obtained from the harmonic oscillator equation. The third graph was produced by calculating the sum of the potential and kinetic energy for the velocity Verlet solution at each time. The values used in these calculations were; k = 1.00, mass = 1.00, = 0.00, A = 1.00, = 1.00 and a timestep of 0.100.
The positions at a time, were calculated by use of the equation ;.
The energies were calculated by using the equation;
![]() |
![]() |
![]() |
In the tables below, everything was calculated in the same way as above, however, this time, the value of k was increased from 1.00 to 5.00. It is evident by comparison that increasing the value of the force constant (k) has increased the frequency of vibrations. This is because, it is known that;
so by looking at the equation above, it is obvious that if the force constant, is increased, this will therefore also cause the frequency, to also increase.
![]() |
![]() |
![]() |
The equation also shows that the frequency will also increase if all of the values are kept the same apart from if the mass is decreased. This can be seen in the tables below, where the mass was decreased from 1.00 to 0.25.
Graph 7 was produced by plotting each maxima value for the error plot against time.

So that the difference in energy does not change by more than 1%, the largest value of the timestep would need to be 0.200. This was calculated because if the total energy at its highest is 0.500, then the total energy at its lowest must not be smaller than 0.495. The value of the timestep was changed and the difference between the energy minima and maxima was calculated. The graph for the energy that was produced for this timestep value can be seen in graph 8, below.

A larger value for the timestep was inserted to show that the overall energy did change by more than 0.495 when the timestep was increased past 0.200. The graph that was produced from a timestep of 0.250 shown below as graph 9. The lowest value for the total energy at this timestep is 0.492.

It is important to monitor the total energy of a physical system when modelling its behaviour numerically so that you know that the law of conservation of energy has been obeyed. If it has not, then the simulation will not accurately reflect a real system.
Atomic Forces
The Lennard-Jones potential is used to simulate the interactions between a pair of atoms in a simple liquid. For a single Lennard-Jones interaction,
When the potential energy is equal to zero, the separation is;
and therefore
At this separation the force is calculated from
If this value for is substituted into
therefore
If then
At equilibrium, we are at the bottom of the curve and the derivative of the Lennard-Jones potential and also the force can be set to equal 0. The value of will then be equal to the equilibrium separation, , as below:
The well depth, , can be found by substituting this value for into
To give
When ;
The below integrals were then evaluated;
Periodic boundary conditions
Under standard conditions, in 1 ml of water;
Therefore
in 1ml
For 10000 atoms;
If an atom at position in a cubic simulation box which runs from . In a single timestep, it moves along the vector .
After the periodic boundary conditions have been applied, the atom would end up at position .
Reduced units
When looking at the Lennard-Jones potential, reduced units are usually used instead of real units. This is done so that the values are more manageable.
The Lennard-Jones parameters for argon are .
If the LJ cutoff is , in real units this would be
What is the well depth in ?
The well depth,
and because, from above;
Therefore
The reduced temperature in real units is
and
therefore
Equilibration
Creating the simulation box
For this, five different simulations were run using LAMMPS. Each simulation was run with a different timestep value; 0.001, 0.0025, 0.0075, 0.01 and 0.015.
It is easier to create starting points for the simulation if we are dealing with a crystal structure rather than if we are dealing with a liquid. This is because the crystal structure could simply be looked up but random starting points would have to be generated for a liquid. However, if atoms are given random starting coordinates then they may be have too strong a repulsion from each other, this means that they will be forced away from each other and cause issues in the simulation.
If the distance between the points of lattice is 1.07722 then the volume of the cube is equal to;
therefore,
If we now look at a face centered cubic lattice, with a lattice point number density of 1.2 then, as there is a total of 4 whole atoms in the cube;
therefore the
If we were to use the create_atoms command for 1000 units of the face centered cubic lattice then it would have created
Setting the properties of the atoms
The LAMMPS manual defines the following commands as:
- mass 1 1.0 - this command sets all atoms of type 1 (which is all of our atoms) to a mass of 1.0
- pair_style lj/cut 3.0 - this command computes pairwise interactions. These interactions are assessed within a specific boundary, or cut off point, in this case the cut off point is set as 3.0. lj in this command means Leonard Jones.
- pair_coeff * * 1.0 1.0 - this command is to define the pairwise force field coefficients between a pair(s) of atom types.
We are specifying and which means that the velocity Verlet algorithm is being used.
Running the simulation
In the code, the below is written:
### 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
This section of the code is present because we want to tell LAMMPS that every time, after this code, it comes across ${timestep} we want it to replace it with 0.001, in this case.
We are not able to simply write:
timestep 0.001 run 100000
instead of writing the first command, above, because we want to keep the overall time the same and just change the timestep. The second, simpler code would change both the timestep and the total time of the simulation.
Visualising the trajectory
The trajectories can be viewed using the VMD programme as can be seen in figure 1, below.

The periodic boundary conditions can also be visulaised using the VMD programme.

Checking equilibration
Here, the thermodynamic data will be used to see if the system has reached equilibrium. As can be seen from graphs 10, 11 and 12, below, the system does reach equilibrium. This is evident because, initially, there is a large change in the three graphs representing the energy, temperature and pressure. However, after this large change, the three variables then begin to fluctuate about the average, which must be the equilibrium state. It takes approximately 0.42 seconds by looking at the graphs.
![]() |
![]() |
![]() |
Graph 13 shows the difference in the energy over time for each of the five timesteps under analysis. A shorter timestep means that the calculated results will be closer to the experimental results, however, the shorter timestep also means that the measurements will have to take place over a shorter amount of time. This can be an issue if it is required that the calculations be run over a long period. As can be seen from graph 13 the timesteps with values of 0.001, 0.0025, 0.0075 and 0.01 all reach equilibrium. The data corresponding to the longest timestep of 0.015 shows the largest deviation from reality. This set of data does not reach an equilibrium and instead the the energy continues to rise, thus disobeying the law of conservation of energy. This timestep would therefore be the worst choice.

By looking at graph 14, it can be seen that the data series corresponding to the two smallest timestep values deviate the least from the average value whilst the data for the timestep values of 0.075 and 0.01 deviate noticeably more. It can be concluded that the largest timestep which still gives accurate results is the 0.0025 value.

Running simulations under specific conditions
In this section, the simulations were modified so that the NpT (isobaric-isothermal) ensemble conditions were followed. The previous section simulated the liquid under microcanonical (NVE) ensemble conditions.
Ten simulations were run for this section. The timestep was set to 0.001 because then the most accurate results would be obtained. Five different temperatures were chosen. These temperatures needed to be higher than the critical temperature of T* = 1.5. The temperatures that were chosen were T = 1.6, 2.6, 3.6, 4.6, 5.6. Finally, two pressures needed to be chosen. These were chosen by looking at the average pressure from graph 12. The pressures that were chosen were p = 2.50 and 3.00.
Each of the five temperatures were run at each of the two pressures for a timestep of 0.001.
Thermostats and Barostats
In statistical thermodynamics, the equipartition theorem states that every degree of freedom for a system at equilibrium has an energy equal to . As we are considering a system of atoms which each have three degrees of freedom, the following equation can be written:
After every timestep, the kinetic energy can be calculated using equation 1. We use the left side of the equation and then divide this by so that , the instantaneous temperature, can be calculated. We want this instantaneous temperature to equal the temperature that was specified in the script, the target temperature, . This can be achieved by multiplying each velocity by a constant, . This constant is calculated by solving equation 1 and equation 2.
This can be done by dividing equation 2 by equation 1 to obtain:
Therefore
Examining the Input Script
fix aves all ave/time 100 1000 100000 v_dens v_temp v_press v_dens2 v_temp2 v_press2
The above line is present in the input script. This line tells LAMMPS to take an average of certain values over a certain number of timesteps. The order that the values are inserted is important.
The first value, which in this case is 100, corresponds to Nevery. This means that the values will be averaged every 100 timesteps.
The second value, 1000, corresponds to Nrepeat. This means that LAMMPS will use 1000 input values to calculate the averages.
The final value, 100000, corresponds to Nfreq. LAMMPS will therefore calculate averages every 100000 timesteps.
The amount of time that will be simulated is 100000.
Plotting the Equations of State
The density as a function of temperature was plotted for both of the chosen pressures.
As can be seen from the graphs, both of the plots of density as a function of temperature are higher for the plot using the density predicted by the ideal gas law than for the computed density. This is because the ideal gas equation assumes that the atoms do not interact with each other. This means that there would be less repulsion between atoms and they will therefore will not have to be as far away from each other as they would in reality. As;
and because the atoms are able to be closer together, the volume will be decreased due to the ideal gas law. From the equation above, then, by decreasing the volume, the density will have to increase as the mass is kept constant.
From the graphs, the higher the temperature is, the lower the density is. This is due to an increase in kinetic energy with rising temperature, meaning that the atoms will be further apart from each other and therefore the density will decrease.
The data points for both pressures were plotted on the same axes to compare the deviation from the ideal gas equation plots at the two different pressures. The graph below shows that increasing the pressure leads to more deviations from the density predicted by the ideal gas equation. This can be explained because the ideal gas law ignores interactions with other atoms. At lower densities, in a real system, there will be fewer interactions taking place. This means that at lower densities, properties of a real system are more reflective of the same properties as predicted by the ideal gas law.
Calculating heat capacities using statistical physics
This section concentrated on the NVT ensemble. As the temperature is being held constant, in its equilibrium state, the energy must be fluctuating about an average value. These fluctuations about the average relate to the magnitude of the heat capacity according to the equation:
The input files for this section were a modification of the file from the previous section.
Again, ten different simulations were run for this section, but this time in the density-temperature phase space.
The simulations were run at two densities of 0.2 and 0.8 and five temperatures of 2.0, 2.2, 2.4, 2.6 and 2.8. The graph below shoes a plot of as a function of temperature. An example of one of the input files used can be found here. This is for a temperature of 2.0 and a density of 0.2.

The below graph shows as a function of temperature. The volume was calculated by . The number of atoms for both densities was 3375. This gave a volume of 16875 for the density of 0.2 and a volume of 4218 for the density of 0.8

As can be seen from the above graph, as the temperature increases, the heat capacity per unit volume decreases. The simulation at the higher density has a larger heat capacity compared to the lower density one for the same temperature. The higher the density, the higher the number of atoms will be when we are looking at an equal volume. The heat capacity is an extensive property of the system. This means that as the size of the system increases, the heat capacity will also increase, which is supported by looking at the graph above.
Structural properties and the radial distribution function
The radial distribution function (RDF), , is a measure of density with respect to the distance from an atom. Using this function, the distance of the nearest neighbours of a certain atom can be calculated.
This journal [2]. provided the phase diagram of the Leonard-Jones potential that was used to choose the pressures and temperatures of a solid, liquid and gas that the simulations in this sections were run with. The table below shows these differing values for the different phases.
Solid | Liquid | Vapour | |
---|---|---|---|
Temperature | 1.2 | 1.15 | 1.15 |
Density | 1.2 | 0.6 | 0.09 |
The results of the simulations of the Leonard-Jones system were then used in VMD to calculate and .
The RDFs of a (fcc) solid, a liquid and a vapour are shown on the same axis, for comparison, in graph 21, below.

Graph 21 shows the probability of finding at atom at different distances with respect to another atom, with each peak representing the position of an atom. The graph shows that up to a distance of about 0.8, there is zero probability of finding another atom. This is true for all of the three phases because of the high repulsion forces at such short distances. The solid has many sharp peaks which correspond to the strict ordering of a crystalline solid. The peaks are also still present and visable at longer distances of r, which is not true for either a liquid or a vapour. Only a few, more broad peaks can be seen at short distances for the liquid, these peaks reflect the solvent shell of the atom under consideration. At longer distances, the probability tends to 1 which shows that there is a high degree of disorder at longer distances and a smaller probability of finding at atom at that position. Only a single peak can be seen for the vapour, there is a very high degree of disorder in this phase which means that there is a very low probability of finding an atom after the nearest neighbour.
The first three peaks for the solid correspond to the first three nearest neighbours. These peaks can be found at distances of 1.025, 1.525 and 1.825 which can be seen as 1, 2 and 3 respectively on figure 3 (edited from http://www.saylor.org/content/watkins_flattice/04fig01.gif).

It is obvious from figure 3 that the lattice spacing in this lattice is just the difference between the atom under consideration and the atom labelled 2. Therefore, the lattice spacing must just be equal to the distance between the origin and the second nearest neighbour. The lattice spacing is equal to 1.525.
The coordination number of the atoms corresponding to the first three peaks of the FCC solid RDF can be calculated by comparing the number integral over plot for the solid phase (graph 22) with the RDF plot for the solid (graph 23).
In graph 23, it can be seen that the first peak reaches a minimum at 1.275. If this figure for is read off the curve, then a value for the number integral can be obtained which corresponds to this peak; the coordination number for the first peak is therefore 12. This process is then repeated for the second peak, it reaches a minimum at 1.625 and the corresponding number integral over is 18. If the coordination number of the first peak is then subtracted from 18 then the coordination for the second peak can be obtained; 6. If this is repeated once more, for a minumum in the RDF plot at 1.975 and corresponding number integral over of 42. Subtraction then leaves a coordination number of 24 for peak three.
![]() |
![]() |
Dynamical properties and the diffusion coefficient
This section will concentrate on the amount that the atoms in the system move around. This will be done by calculating the diffusion coefficient, .
Mean squared displacement
can be calculated by using its connection to the mean squared displacement:
It is a measure of the spatial extent of random motion. The mean squared value is taken to ensure that a positive value is obtained.
First, three simulations were run; on a solid, a liquid and a vapour. The temperature and density values from the previous section were used in the input files.
Graphs 24, 25 and 26 show the total mean squared displacement as a function of timestep for the three phases, solid, liquid and vapour respectively. It would be expected that the graphs would be of a linear fashion. This trend is followed for the plot of the liquid. However, the vapour plot can be seen to have a slight curve at the beginning. This is due to the lack of collisions at the start of the simulation in the low density vapour phase - the trend becomes linear after a collison. An atom in the high density solid is unable to move in a random fashion therefore the expected linear trend is not observed.
To calculate the diffusion coefficient, the x axis needs to be converted from units of timesteps to units of time. This can be seen in graphs 27, 28 and 29. The diffusion coefficient for these two graphs can therefore be calculated from the gradient of the data points. The gradient is multiplied by to obtain .
Thus, if the graph for the liquid is considered first, the equation that resulted from the linear trendline was . The diffusion coefficient is therefore This process is also repeated for the solid and vapour phases.
The resulting gradients are shown in the below table:
Solid | Liquid | Vapour | |
---|---|---|---|
Gradient | 3x10-6 | 1.1387 | 14.502 |
D | 5x10-7 | 0.190 | 2.417 |
The above was repeated for a system of 1 million atoms. The total mean squared displacement as a function of time plots are shown in graphs 30, 31 and 32 and the resulting gradients and diffusion coefficients can be seen below.
Solid | Liquid | Vapour | |
---|---|---|---|
Gradient | 3x10-5 | 0.5236 | 15.249 |
D | 5x10-6 | 0.0873 | 2.54 |
The gradient of the plot for the solid was not taken over the entire graph, it was only taken over the section from graph 33.
Comparison of the graphs of the systems of different sizes shows that the simulation with one million atoms provides smoother plots, this is to be expected for a larger system.
Velocity Autocorrelation Function
An alternative way of calculating the diffusion coefficient, , is to use the velocity autocorrelation function which is given by the below equaiton:
This function states the difference in velocity at a time, , compared with the starting time, .
The equation for the evolution of the position of a 1D harmonic oscillator as a function of time;
was used to evaluate the normalised velocity autocorrelation function for a 1D harmonic oscillator.
- because
- and we know that
- the first equation can be differentiated to give
- and therefore
- If this is substituted into
- Then this produces
- Because
- The above therefore becomes
- The above will then cancel to
- The function on the right hand side of the equation is odd. This means that when integrated, it will equal zero. Therefore, one final simplification can be made to produce:
The final result of the above was then used, with , to plot the harmonic oscillator. This can be seen in graph 34. The VACFs for the liquid and the solid that were simulated above were also plotted on the same axis.
The above procedure was then repeated for the system containing one million atoms, this can be seen in graph 35.
As can be seen from graphs 34 and 35, the VACF of the solid resembles the plot of the harmonic oscillator close to but then reaches a constant value with increasing time. The harmonic oscillator is such a consistent shape because it ignores all interactions with other particles and only experiences one single force while the particle under observation vibrates. The minima of the VACF plots represents the points where the particle changes its direction of velocity. In reality, the solid and the liquid both represent a damped harmonic oscillator because the attractive and repulsive forces they experience force the particles to settle to an equilibrium where the forces it is subjected to balance out, rather than continuously vibrating as in the harmonic oscillator. The solid suffers more oscillations than the liquid does. This is because the solid is more constricted than the liquid which means that the liquid isn't forced to oscillate as much because it is not fixed in a certain position.
The trapezium rule was then used to approximate the integral under the velocity autocorrelation function for the solid, liquid, and gas. The graphs produced can be seen below as graphs 37, 39 and 41.
The diffusion coefficients were calculated from these integrals, as shown below;
Solid | Liquid | Vapour | |
---|---|---|---|
D | 1.44x10-4 | 0.181 | 3.11 |
It would be expected that the magnitude of the diffusion coefficients would follow the trend vapour > liquid > solid. This is because the atoms in the vapour are much further away from each other, meaning diffusion can take place with ease. Diffusion coefficient of the liquid would depend on its viscosity; a more viscous liquid would have a smaller . The solid would be expected to have a very small value because very limited diffusion can take place in a solid. From the above table, this is true.
The above was then repeated for the simulated system of one million atoms.
The below diffusion coefficients were obtained for these systems from graphs 43, 45 and 47;
Solid | Liquid | Vapour | |
---|---|---|---|
D | 1.22x10-4 | 0.089 | 3.26 |
These values for follow the same trend as explained above.
The largest source of error in the estimates of from the VACF would come from the use of the trapezium rule for the integration. The trapezium rule is an approximation which integrates the area under a curve by splitting up the area into multiple trapeziums and summing their individual areas. However, in this calculation, a very large number of trapeziums have been used and the accuracy increases with increasing number of trapeziums, meaning that this should be a good approximation to use in this case. This is shown to be true because similar values were calculated for the diffusion coefficients using the mean squared displacement and the velocity autocorrelation function.