Talk:Mod:P0TAT0
JC: General comments: Most tasks answered, but a few parts missing from some questions. Make sure that you fully understand the theory behind this experiment and what you are being asked to calculate and plot in each task.
Molecular Dynamics Simulations of Simple Liquids
Ab9314 (talk) 11:11, 24 March 2017 (UTC)
Introduction
Molecular dynamics (MD) is a method to simulate the motion of many particles by numerically integrating Newton's Laws of Motion over time. The simulation can be conducted in an ensemble, e.g. NVT or NVE, by setting limits on temperatures and pressures (thermostatting and barostatting respectively).[1] MD can be used to simulate the behaviour of protein folding, lipid bilayers, and other biological systems, thereby making this a very practical and convenient way to experiment with complex systems.[2] The potential between particles were calculated using pairwise-additive 12-6 Lennard-Jones potentials. All simulations were performed on the HPC system using the LAMMPS software package.
Velocity Verlet Algorithm
To begin the simulation, a lattice of atoms can be initiated with atoms a user-defined length apart (inputted in reduced units). All particles were given an initial velocity (according to Maxwell-Boltzmann distribution). Integrating each particle's velocity over time iteratively gave the new positions of the atoms in the system. This was done using the velocity-Verlet algorithm.
At first, the timestep of the simulation was varied to observe the errors in the positions with passing time when using the velocity-Verlet algorithm. This was done by calculating the exact position of a simple harmonic oscillator, and comparing against the position given by the velocity-Verlet calculation.
For a simple harmonic oscillator, . Using an Excel spreadsheet, the error in the Velocity-Verlet algorithm was calculated. In this case, and . The error is plotted in Figure 1, and the maxima in the error is plotted against time in Figure 2.
-
Figure 1: Error in displacement (when calculated by velocity-Verlet algorithm) against time for a simple harmonic oscillator.
-
Figure 2: Maximum error in displacement against time for the harmonic oscillator.
By changing the timestep in the spreadsheet, it was found that the error in as calculated by the velocity-Verlet algorithm is less than over the course of the simulation when the timestep is less than .
The total energy of the system should be monitored to make sure that the energy is conserved in the system, and to check if the system is in thermal equilibrium. If the total energy is not stable, then the thermodynamic values derived from the system will not be equilibrium values, and cannot be compared to other MD systems.
JC: Good choice of timestep, the total energy should be approximately constant to ensure that the simulations give physically meaningful results. Why does the error oscillate over time?
Atomic Forces
In order to make the calculations easier, the LJ-potentials were given a 'cut-off' distance - any atoms separated by a distance larger than this truncation distance will not be included in the LJ force calculations.[3]
When :
Thus, when limits are introduced:
From the above calculations, the force of attraction reduces very quickly when the distance from the Lennard-Jones centre is greater than . Hence, truncation at such a distance will introduce only a very small error in the system.
JC: You are missing half of the maths questions - what is r0, the force at r0, req and the potential at req? The integral is not correct, the integral of 1/(r^12) is -12/(r^11), not -1/(12 r^11).
Periodic Boundary Conditions
As it is very heavy computationally to simulate even millimole amounts in LAMMPS, Periodic Boundary Conditions (PBCs) are used to cut down the calculation times.[3] The reason for this difficulty can be seen by considering the number of particles in a small volume of water.
For example, 1 mL of water contains: molecules.
In most cases, the number of particles used will be between 103 and 104.
104 water molecules take up a volume of:
PBCs allow for the relatively small number of particles in our simulation to act as though it's part of a bulk solution. To this end, the particles are simulated such that when moves off one edge of the box, it reappears on the opposite face with the same velocity. Hence, the number of particles in the box, N, is always conserved.
For example, consider an atom at in a cubic box with vertices at and . If this atom moves by vector in a single timestep, then the final position of the particle will be: .
Reduced Units
Reduced units are used to make the numbers more manageable.
For Argon, . Given that the LJ-cutoff in reduced units is at , the cutoff in nanometers is: .
Given ,
well depth, .
Therefore, when , and given ,
.
JC: Calculations correct. PBCs are used to remove the effects of the edges of the simulation box and make simulations a small systems behave like a bulk systems.
Equilibriation
The Simulation Box
The particles for the simulation were initiated in a simple cubic lattice structure. A random set of coordinates were not used. This was to avoid two atoms being generated too close together - this would lead to a very large potential, and cause the pair to split violently apart. This simulation would be unlikely to be a good representation of a real life scenario of a crystal melting.
JC: High repulsive forces make the simulation unstable and can cause it to crash unless a much smaller timestep is used.
In this simulation, a lattice density of 0.8 was used (0.8 lattice points per unit volume). If a face-centred cubic (fcc) lattice had been used instead, with a lattice density of 1.2, then the side length of the cubic unit cell, , can be found thus:
JC: Correct. How many more atoms would be created in an fcc lattice compared to a simple cubic lattice?
Properties of atoms
The reaction conditions such as the lattice density are passed into LAMMPS using text commands in the input file. Part of the commands are shown below:
mass 1 1.0
mass
defines the property of the atom that is being defined. 1
indicates the type of particle being defined; all particles in LAMMPS are given a type, in form of an integer number. For example, if considering a mixture with 2 types of atoms, then the particles in LAMMPS would be differentiated by having type 1
and type 2
particles, and so on.
1.0
indicates the mass of the particle in g mol-1.
pair_style lj/cut 3.0
This line defines the potential between two interacting particles. Once again, the pair_style
keyword indicates the property being defined. lj/cut
defines the potential as a truncated Lennard-Jones potential, while the 3.0
defines the potential to be truncated at . Overall, the potential is being defined as:
pair_coeff * * 1.0 1.0
This line is defining the force that each particle exerts on all other particles is the same as that defined by the negative of the derivative of the Lennard-Jones potential.
JC: What do the asterisks mean in this command and what do the number refer to for the Lennard-Jones potential? Why is a cutoff used for the Lennard-Jones potential?
The generated particles are then given initial coordinates, and their initial velocities. As and are both specified, the velocity-Verlet integration is used for the simulations.
Running the Simulation
The final lines of the input file are as follows:
variable timestep equal 0.001 variable n_steps equal floor(100/${timestep}) ### RUN SIMULATION ### run ${n_steps}
variable timestep equal 0.001
creates a variable so that any subsequent occurence of the string ${timestep}
is replaced by 0.001
. The number of steps the simulation is run for is also determined by the value of the timestep. By assigning a variable name to the timestep, editing the timestep value will automatically adjust the number of steps, avoiding tedious editing of the value in two different places each time the timestep is changed.
JC: Correct, using variables makes it easier to run different simulations with different valued parameters using the same script.
Checking Equilibriation
Several different simulations were run using different timesteps, and the total energy of the system was monitored at each step. Figure 3 shows the results of the simulations.

All systems reach equilibrium, except for the system where the timestep is 0.015. The equilibrium was reached by around - in quite a short amount of time.
Of the five timesteps used, the largest acceptable timestep is 0.01. A particularly bad choice would be a timestep of 0.015. This is because the total energy of the system seems to be increasing indefinitely with increasing time with large fluctuations. This is a poor representation of a real system, hence this simulation timestep length is too long for this system.
JC: The average total energy should not depend on the choice of timestep so timesteps of 0.01 and 0.0075 are not suitable. Both 0.0025 and 0.001 give roughly the same average total energy so the best choice would be the larger of these two (0.0025) to enable longer simulations to be run more efficiently.
NPT Simulation
This section looks at running simulation under specific conditions, using an NPT ensemble. This is done using barostats and thermostats.
Temperature and Pressure Control
Temperature, , fluctuates in the simulation, and the target temperature is . As temperature is related to the total kinetic energy of particles within the system, the temperature is kept roughly constant by multiplying the velocities of the particles by a factor . Hence, these two equations can be surmised from the above, from which an expression of is derived:
JC: Nearly, there shouldn't be a factor of 2 in the square root, check your working again.
The Input Script
The thermodynamic property values of the system were periodically computed and saved to file using the following command in the input script:
fix aves all ave/time 100 1000 100000 v_dens v_temp v_press v_dens2 v_temp2 v_press2
These values are time-averaged in a specific way. The arguments 100 1000 100000
instruct LAMMPS to compute the properties every 100000 steps using preceding 1000 values in intervals of 100 values. For example, at the 200000th step, the properties are averaged using values at steps number 100100, 100200, 100300... 199000, 200000.
JC: Correct.
Plotting the Equations of State
Simulations of a crystal melting were run at two different pressures, P = 2.5 and P = 3.0, with 8 temperatures for each pressure. A graph of density against temperature was then plotted, along with the density predicted by the Ideal Gas Law with respect to temperature at these two pressures. The results are shown in Figure 4. It can be seen that in general, the MD simulation predicts a lower density than the ideal gas law. This is because the ideal gas law does not take the forces between particles into account. In the Lennard-Jones potential model, the repulsive forces are very strong (compared to the attractive forces). Hence, the MD simulations show the particles will prefer to be more spread out (i.e. less dense) so as to minimise the unfavourable repulsive forces. The discrepancy decreases with increasing temperature, because the particles in the MD systems will move further apart. This in turn decreases the magnitude of the forces between particles, bringing it closer to the ideal system of no forces between particles.

JC: Correct, how does the discrepancy between the simulation and ideal gas results change with pressure? The ideal gas is a good approximation to a dilute (high temperature, low pressure) gas.
Heat Capacity Calculations using Statistical Physics
To investigate the effect of changing temperature on the heat capacity, a simulation was run in the NVT ensemble for two different densities ( and ). The results of the simulations are summarised in Figure 5.

The expected value for in an ideal system is:
Hence, for an ideal gas, when and when .
The value of found in the simulations are around 4 orders of magnitude smaller than what is predicted the ideal system, even at low densities (more ideal system). Also, the simulation shows variation of with increasing temperature (approximately ).[4] The value of n is unknown, and must be found by fitting different curves to the data. We know that and that . Hence, we can estimate that . This is in contrast to the ideal system, which predicts no variation of heat capacity with temperature.
However, qualitatively, the trends seen are reasonable. As the temperature is raised, the particles have more and more energy, yet the number of available degrees of freedom fall. As is a measure of how easily the system is excited to higher energy states - an already excited system requires even more energy to put the particles in a higher vibrational energy states. Increasing the number of particles, , also leads to a larger number of degrees of freedom, leading to an increase in the heat capacity, . Consequently, increasing also leads to an increase in . This trend is clearly seen in Figure 3.
Finally, the apparent reversal in trends from to is showing the change from a liquid to a gaseous phase.
JC: Some good suggestions. Why do you think the number of degrees of freedom reduces as energy is increased? Remember these simulations are classical simulations of spherical particles, there are no vibrational energy levels.
The Input Script
One of the scripts used for running the NVT simulations is shown below:
### CREATING VARIABLE TO DEFINE LATTICE DENSITY variable rho equal 0.8 ### DEFINE SIMULATION BOX GEOMETRY ### lattice sc ${rho} 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.2 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 ### ENDING NVT ONCE SYSTEM IN REQUIRED STATE. NVE RESTATED. unfix nvt fix nve all nve ### MEASURE SYSTEM STATE ### thermo_style custom step etotal temp press density variable temp equal temp variable temp2 equal temp*temp variable eng equal etotal variable eng2 equal etotal*etotal fix aves all ave/time 100 1000 100000 v_temp v_temp2 v_eng v_eng2 run 100000 variable avetemp equal f_aves[2] variable errtemp equal sqrt(f_aves[5]-f_aves[2]*f_aves[2]) ### CALCULATION OF C_V variable vareng equal (f_aves[8]-f_aves[7]*f_aves[7]) variable cv equal (3375*3375*${vareng})/(${avetemp}*${avetemp}) ### PRINTING CALCULATED VALUES TO OUTPUT FILE print "Averages" print "--------" print "Temperature: ${avetemp}" print "Stderr: ${errtemp}" print "Heat Capacity: ${cv}"
Structural Properties and the Radial Distribution Function
The Radial Distribution Function (RDF, or ) can provide some insight into the structure of the particles in the simulation. The three phases, solid, liquid and gas, have distinctive RDF plots. These RDF plots can be compared directly to X-Ray diffraction plots produced experimentally, so that the identity of the systems can be verified by this property.[3] Figure 6 shows the RDF plots acquired by varying the density and temperature of the NVT simulation.
-
Figure 6: The RDF of the same particles in solid, liquid and gaseous phase. The initial part of the graph where indicates space between adjacent particles. This figure also shows that tends to as becomes large.
-
Figure 7: The integral of the RDF of the same particles in solid, liquid and gaseous phase.

As can be seen from Figure 6, from to is where the repulsive forces between the adjacent atoms are too great to be overcome, and hence is empty space.
The RDF of solids have sharp peaks at well defined spacing. The atoms responsible for each of the first three main peaks are outlined in Table 1 using Figure 8 as a reference. The lattice parameter is the distance between two adjacent atoms on the fcc lattice along a straight edge (i.e. not diagonally adjacent). This appears to be approximately . The RDF decreases slowly as the radius increases.
By using the plot of against (see Figure 7), the coordination number around a single reference atom as the distance, , increases. The coordination numbers at symmetry related lattice vectors 1, 2 and 3 for this fcc lattice are tabulated in Table 1.
Vector | Distance from central atom/ | Coordination Number |
---|---|---|
1 | 1.025 | 8 |
2 | 1.775 | 8 |
3 | 2.725 | 16 |
The liquid has a smooth RDF, with the peaks similar distances apart, but its decay is faster than that of the solid's. The progressively smaller peaks indicate the coordination shells around each atom.
Finally, the RDF of the gas phase tends to 1 very quickly, with no visible oscillations about . This indicates a uniform distribution of particles in the simulation box, as is expected of a gas in equilibrium.
JC: Solid has long range order, liquid only has short range order. How did you calculate the lattice parameter, it should be roughly the distance to the second peak which is less than 1.775. Could you have also calculated it from the first and third peaks and taken an average? The coordination numbers for the first 3 peaks should be 12, 6 and 24, did you zoom in to the integral graph to get these values?
Dynamical properties and the Diffusion Coefficient
Mean Square Displacement (MSD)
The motion of the particles in the molecular simulation were investigated by finding several properties of the systems.
The Mean Square Deviation (MSD) of the system is a measure of how freely the particles in the system can move to a new position (see Figure 9). The MSD is calculated thus:
Hence, as time progresses in a system with diffusion, the sum of MSD over all time intervals will be increasing. As , the rate of increase of MSD is approximately constant. The diffusion coefficient, , is defined as:
This equation is true as ; at small values of , there are few or no collisions, and the increase in . can thus be estimated by fitting a straight line to the linear portion of a plot of against time. Figures 10, 11, 12 and 13 show the calculation of the diffusion coefficient from the plots. Table 2 records the values of - a clear trend of increasing values of diffusion coefficients with decreasing density can be seen from the data. Atoms in gases can therefore diffuse 20 times as fast as atoms in solids.
-
Figure 10: The MSD of the particles at at all states. The values increases with relation to time - the fastest increase is for the gas phase, followed by the liquid phase, and the solid phase is the slowest.
-
Figure 11: The MSD of the particles in the solid phase. As the particles' movements are restricted and not averaged, the plot is not smooth.
-
Figure 12: The MSD of the particles in the liquid phase. The plot is linear, indicating .
-
Figure 13: The MSD of the particles in the gas phase. Initially, , but as .
State | Diffusion Coefficients, | |
---|---|---|
Solid | 1.3 | |
Liquid | 0.8 | |
Gas | 0.1 |
JC: Would you expect the MSD to increase for a solid? Did you remember to change the lattice type to fcc in the script? Good explanation that MSD is proportional to t^2 at short times, this is especially clear in the gas phase plot.
The above simulations were performed with thousands of particles, and this can be considered as a relatively small amount - not even a fraction of a femtomole of atoms. To simulate a larger system, a set of simulations were run with 1 million atoms. The difference in the MSD plots (see Figures 14, 15, 16 and 17) is most marked in the solid state - whereas in the smaller system, there was a definite increase in MSD over time for all timesteps, the larger system oscillates slowly oscillates around . Physically, this observation shows that most of the particles in the solid are vibrating and colliding into each other very often. In the smaller system, the collisions are much less frequent, so that is larger for each atom. The diffusion coefficients of the million atoms in the three states are tabulated in Table 3.
-
Figure 14: The MSD of the 1 million particles at at all states.
-
Figure 15: The MSD of the particles in the solid phase. This plot is jagged, and the gradient is almost : indicating virtually no diffusion in solid state.
-
Figure 16: The MSD of the particles in the liquid phase. The plot is linear from .
-
Figure 17: The MSD of the particles in the gaseous phase. The plot is linear from .
State | Diffusion Coefficients, |
---|---|
Solid | |
Liquid | |
Gas |
JC: Figure 15 is what you would expect for a solid phase.
Velocity Autocorrelation Function
The diffusion coefficient, , can also be estimated from the velocity autocorrelation function (VACF), , if at large [3]:
Below, the normalised velocity autocorrelation function is evaluated for a 1D harmonic oscillator.
Given , and :
Simplifying,
Using the trigonometric identity , the following can be surmised:
Hence,
Rearranging ,
Simplifying,
However, as this is an even function.
Thus, :
JC: Correct result, the derivation could have been simplified by realising that the function sin(x)*cos(x) is an odd function and so the integral is zero.
This result shows that for a simple harmonic oscillator, the VACF is a sinusoidal function that depends on the time passed, as well as the frequency of the oscillator.
The VACF of the solid and liquid states were calculated during the simulations. In addition, the analytical solution to the VACF of a particle doing simple harmonic motion with frequency, was also calculated. These are all plotted in Figure 18.
-
Figure 18: The plots of velocity autocorrelation functions with for atoms in a solid, a liquid, and for a simple harmonic oscillator. At large , for the solid and liquid systems.
-
Figure 19: VACF of atoms in the gaseous phase decay much more slowly owing to the much weaker interatomic forces.
From Figure 18, it can be observed that the VACF of the simple harmonic oscillator is sinusoidal, whereas the liquid and solid VACF are best described as damped sinusoidal. The solid's VACF tends to 0 faster that that of the liquid.
The global minima in the plots for the solid and liquid indicate when all the particles have had at least one collision. By this point, each of the atoms have a different velocity vector associated with it. Hence, the VACF rebounds towards 0. As the simple harmonic oscillator is a lone particle's motion, with no interactions with any other atoms, hence its VACF is very different to the Lennard-Jones solid and liquid. Its velocity vector also changes in a cyclic manner, and does not change from one oscillation to another. Hence, the amplitude of the VACF does not change as time increases.
In the solid, the particles are in close contact due to the high density - the atoms are arranged so that the repulsive forces are minimised, and the attractive forces maximised. This is the distance at which the LJ-potential is at a minimum. Here, the atoms are very stable, and are reluctant to leave the locations they are at.Their motion is therefore a vibration around their eqiulibrium positions, with a reversal of velocity at the end of each oscillation. This explains the oscillatory behaviour of the VACF. However, the damping is explained by perturbative forces acting on the atoms that disrupt the oscillations. Liquids are similar to solids - however, the density here is lower, and diffusion is faster. Here, the diffusive forces are the perturbative forces, and hence the VACF decays much more rapidly than the solid's VACF.
In contrast, the VACF from a system in the gaseous state (see Figure 19) decays much more slowly. The large separation distances between particles in the gaseous phase mean the forces are weaker. Hence, the inter=particle forces between them only affect their velocities very slowly, over a long time. For this reason, the VACF decays much more slowly than the liquid and the solid VACF.
JC: What are the perturbative forces in the solid? Collisions between particles randomise particle velocities and cause the VACF to decorrelate, but there are no collisions in the harmonic oscillator.
-
Figure 20: Cumulative integral of VACF against time for all phases as an approximation to the diffusion coefficient.
-
Figure 21: Cumulative integral of VACF against time for solid and liquid phases.
The area under the VACF, and thus the diffusion coefficient, , was estimated by using the trapezium rule, by using the following formula:
The cumulative integral is plotted in Figures 18 and 19. The gas has a very large , compared to the liquid and the solid; the diffusion coefficient of the liquid is approximately 100 times as large as that of the solid. The trend of lower with higher density is as found earlier in Tables 2 and 3.
-
Figure 22: Cumulative integral of VACF against time for all phases for 1 million atoms.
-
Figure 23: Cumulative integral of VACF against time for solid and liquid phases for 1 million atoms.
State | Diffusion Coefficients (MSD), | Diffusion Coefficients (VACD), |
---|---|---|
Solid | ||
Liquid | ||
Gas |
A larger system with a million atoms was also simulated to simulate a system more akin to a real-life system. These plots (see Figures 22 and 23) are much smoother and give a more accurate value of the diffusion coefficient, . The values of acquired for the 1 million atom simulation from the VACD is compared to that of the values acquired from the MSD in Table 4. The table shows values gotten from the VACD values are much higher than those derived from the MSD values. The largest source of errors of calculation of from VACF is from the use of trapezium rule to approximate the area under the graph.
JC: Calculating D from the VACF relies on the integral of the VACF reaching a plateau within the simulation time, is this the case here? Do you think the MSD or VACF derived values for the diffusion coefficient are more accurate?
References
Template loop detected: Template:Reflist
- ↑ Godehard Suttman (2002). "Classical Molecular Dynamics". NIC Series 10: 211-254. >
- ↑ Karplus, Martin (2002). "Molecular dynamics simulations of biomolecules". Nature Structural Biology 9: 646-652. doi: 10.1038/nsb0902-646.
- ↑ 3.0 3.1 3.2 3.3 Allen, M.P., Tildesley, D.J. (1987). "Computer Simulation of Liquids". Oxford: Clarenden Press 1: 27-29. Cite error: Invalid
<ref>
tag; name "RDF" defined multiple times with different content - ↑ Dinsdale, A.T. (1991). "SGTE data for pure elements". CALPHAD 15(4): 317-425.