Rep:AL1913
Introduction to molecular dynamics simulation
Velocity Verlet Algorithm
The velocity verlet algorithm is being used to model the behavior of the classical harmonic oscillator. The file related to the Velocity-verlet algorithm and relating it to the classical harmonic oscillator is found here
The analytic section relies on

The position and potential energy agree with the harmonic oscillator model which is not too shocking due to the Verlet algorithm using Hooke's Law ().
However, from the bottom plot, the absolute error of the system increases over the oscillations. As can be seen by the graph above, this is a linear plot implying that the algorithm carries errors forward from previous oscillations.

It was seen from the graph above that the smaller the timestep, the smaller the error. When the timestep is 0.20, the error was 0.1 % meaning that the any timestep below 0.20 will give an error less than 0.1 %. The first law of thermodynamics states that energy must be conserved and hence the total energy of an isolated system must be conserved. This means that the system with the smaller error in the energy will be the most accurate state of the ensemble.
Atomic Forces
Using the single Lennard-Jones potential interaction, the separation can be found where the potential energy is zero. The working out is shown below.
Using the single Lennard-Jones potential interaction, the equilibrium separation can be found and using this the well depth can be found. The working out is shown below.
The following integrals are considered and have been worked out in a similar way. The working out is shown below.
When
When
When
Periodic Boundary Conditions
The density of water is 1.0 g/mL, the molar mass of water is 18.01 g/mol. The moles of water per mL can be found by doing . This number can be multipled by Avogadro's number to give the number of molecules per mL. There are 3.343 x 1022 molecules in one mL.
Using this number, the volume that 10000 molecules take up can be found.
If an atom starts at position (0.5, 0.5, 0.5) and moves (0.7, 0.6, 0.2) in a single step, the atoms ends up in (0.2, 0.1, 0.7) due to the periodic boundary condition of the box the atom is in. In vector form, this is shown below.
Given that , that r* = 3.2 and = 0.34 nm , it can be found that r = 1.088 nm.
As the well depth, , in reduced units,
Given that :
This can be multiplied by Avogardo's number and the Joules part can be converted to kilojoules:
Given that , that T* = 1.5 and that , it can be found that
Equilibration
Creating the simulation box
A system could initially start with a very high energy system if two atoms are close together as the potential energy would be very high. They would move away from each other with a very high velocity with the system having an improbably high energy.

There is one atom per unit cell. The volume of the unit cell can be found by calculating . The length can be found by taking this result and taking it to the power of a third. Hence for a simple cubic lattice with a density of 0.8, length =
The number of atoms per unit cell for a face centered cubic lattice is 4 (). The length of this cubic unit cell is
The create_atoms command would make 4000 atoms; 4 atoms per unit cell with 1000 unit cells being produced.
Setting the properties of the atoms
mass 1 1.0 pair_style lj/cut 3.0 pair_coeff * * 1.0 1.0
The mass of atom 1 is set to be 1.0 pair_style sets the type of energy interactions between each pair of atoms, which in this case is the Lennard-Jones potential with any interactions beyond being discounted. The pair_coeff relates to and respectively. The * * means these are considered for the whole system, with 1.0 1.0 meaning the values of these are 1.0.
Given that we are specifying , the velocity Verlet algorithm is going to be used.
Running the simulation
By considering the lines below, the code can be understood quite easily.
### 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 The first line defines the timestep used, which is 0.001 in this case. The duration of the simulation is kept constant, with 100 time units being used in this case. ### RUN SIMULATION ### run ${n_steps} run 100000
We can not just write:
timestep 0.001 run 100000
This set of codes requires the changing of all lines related to timestep manually if the timestep is to be changed.
In the first code, the modifications can be made more easily.
Checking equilibrium



For the 0.001 timestep, the system reaches the equilibrium state within 0.25 seconds (250 timesteps) This is also the same for the pressure and temperature seen below. The largest of the timesteps to give reasonable results for the energy is 0.01 seconds. However, the largest result with the lowest energy is 0.0025 seconds, so it is the best to be used for finding subsequent results. The poorest result is 0.015 seconds for each timestep as the simulation does not reach equilibrium, which is impossible due to the first law of thermodynamics.
Running simulations under specific conditions
Thermostats and Barostats
By using the following two equations, a relationship for can be found.
Examining the Input Script
### MEASURE SYSTEM STATE ### thermo_style custom step etotal temp press density 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 fix aves all ave/time 100 1000 100000 v_dens v_temp v_press v_dens2 v_temp2 v_press2 run 100000
The importance of the three numbers 100 1000 100000 in the input script need to be considered.
The importance of the number 100 is that the input values are used every 100 timesteps. The importance of the number 1000 is that it is the number of times to use the input values to calculate averages. The importance of the number 10000 is the number of timesteps it takes to calculate the averages. Every 10000 steps, the average will be sampled. 1000 steps will contribute to the average. It will run for 10000 steps for the simulations.
Plotting the Equations of State

The simulated density is much lower than that predicted by the ideal gas law. The ideal gas law assumes that there is no interaction between gas molecules. This means that the molecules can approach each other, even to very small distances, with no penalty. The discrepancy decreases as the temperature increases. The ideal gas law implies that as T approaches zero, the density can approach infinity. In the simulation, using Lennard-Jones potential, this is not possible as the atoms cannot approach each other as easily due to the high potential energy caused by the nuclei approaching too closely. The discrepancy increases as pressure increases. Molecules will experience a larger repulsive force as the molecules are closer together and so the density will be lower. Due to the ideal gas law not taking these forces into account, the discrepancy increases as pressure increases.
Calculating heat capacities using statistical physics

As the temperature increases, the heat capacity decreases. so it would be expected that if Q was not dependent on T than it would stay constant. This is not the case as can be seen by the graph and so as T increases, Q must decrease leading to the graph shown.
At higher densities, the heat capacity per unit volume increases. This means the heat capacity increases with the number of atoms. This is expected because the heat capacity is an extensive property therefore it is proportional to the size of the system.
An input file for the density at 0.2 and temperature at 2.0 is provided here
Structural properties and the radial distribution function
The radial distribution function (RDF), g(r), describes how the density of particles varies as a function of distance from a reference particle.

Between the value of r = 0 to 0.825, all of the RDF graphs have a value of 0. This is due to repulsive forces dominating in this region.
When g(r) approaches 1, it means there are no significant numbers of atoms found and so no predictable arrangement of atoms at this distance.
The RDF graphs oscillate around the value of 1. The solid oscillates for a longer distance than the liquid. At the peaks of the graphs, atoms will be found. This suggests that the solid has a more ordered structure which are packed more closely.
In the liquid there are a few peaks which are further apart, with no more oscillations after 4 units with g(r) approaching 1. In the vapour, there is one peak prior to 2 units with g(r) approaching 1 after this point. This suggests that the liquid has atoms further apart than the solid and the gas has atoms further apart than the liquid, and so solid. Another way of putting this is that the solid has the most atomic shells and the gas has the least atomic shells in a given distance.
The Solid Lattice
By using the face-centred lattice and a number density of 0.8 the length of one side of the unit cell is 1.49. The peaks of the solid RDF have been found to give the distance of the nearest neighbours. The integration of each peak gives the coordination number of that atom.


Red is the atom specified in this case, Black is the nearest neighbour. Blue is the 2nd nearest neighbour. Green is the 3rd nearest neighbour.
Distance | Comparison to unit,cell length (A) | Integration Values
(nearest whole number) of Troughs beside peak |
Coordination Number |
---|---|---|---|
1.025 | Approximately, | 0 and 12 | 12 |
1.475 | Approximately A | 12 and 18 | 6 |
1.825 | Approximately | 18 and 42 | 24 |
More distances in this region need to be solved for this to be more accurate, hence leading to slight inaccurate results being produced.
Dynamical properties and the diffusion coefficient
Mean Squared Displacement
The atoms follow Brownian motion which is random meaning the position probability density diffuses out over time. Brownian motion would only be expected for liquid and gaseous systems and hence a non-zero diffusion coefficient in liquid and gaseous systems is also expected.

The graphs shown do not use time but rather the number of time steps. Hence D = 1/6 x gradient x 1/time step for these graphs. The time step used is 0.002 s. The gradient is only found for the region where the graph seems to be a straight line. For the gaseous MSD functions there is an initial non-linear relationship due to the atoms’ initial velocity dominate the function before collisions with other atoms lead to the linear function to dominate. The higher density of liquid lead to this non-linear region to be much smaller, so much so that it is unnoticeable in this work. As reduced units are used for the distance, the units of D in this case is s^-1.
D () | 8000 atoms | Million Atoms |
---|---|---|
Solid | ||
Liquid | ||
Gas |
The solid has a slight non-zero value due to slight errors which would be caused by not using a long enough timeframe. The million atom systems has higher diffusion constants than the 8000 atom systems.
Velocity Autocorrelation Function
The evaluation of the normalised velocity autocorrelation function for a 1D harmonic oscillator is shown below:
Let and
due to symmetry of the function.
So

As can be seen by the graph, the simulated system differs majorly from the harmonic oscillator velocity autocorrelation function (VACF). There is damping evident in the simulated systems, where the gaseous system is significantly damped and the solid system is the least damped of the three states. The harmonic oscillator does not take into account this damping. This is due to the lack of potential energy with relation to other atoms in the system. The gaseous state is less viscous than the liquid state which means the gaseous system needs more time for atoms to collide with each other, as there are less atoms per unit volume and so more time is needed correlate the velocity. The liquid state has more collisions within the same time than the gas state meaning the velocity correlates much more quickly. It ‘overshoots’ slightly which is likely due to some inertia from the initial system conditions. The solid is most similar to the harmonic oscillator due to the atoms’ positions being well defined. Any change to this position is corrected more quickly due to the highly sensitive distance dependent in the solid state. It does dampen however.
As the gaseous does not reach a stable value, D cannot be found in this case. The solid will be assumed to have reached a stable value after 1000 time steps. The liquid seemed to be stable by 150 time steps. Again, the number of time steps were used, but this time it was a product and so the time step (0.002 s) should be multiplied with the trapezium rule guesses.

D (s) | 8000 atoms | Million Atoms |
---|---|---|
Solid | ||
Liquid | ||
Gas | - | - |
The biggest source of error in estimating D is that the convergence must be guessed by eye. The actual convergence may take much longer. Furthermore, the random motion of the atoms lead to oscillations which may be significant to the integral.