Talk:MOD:ZYH1018
JC: General commentsː All tasks answered and plots look good. Some of your written explanations are quite unclear though, try to make your writing more focused and concise.
Running your first simulation
This part introduces us the procedures to run simulations with a software package called LAMMPS on the High Performance Computing (HPC) systems and five example simulations with different timesteps were performed for following sections.
Introduction to molecular dynamics simulation
Numerical Integration
The Classical Particle Approximation states that in a collection of atoms, each one of them behaves as aclassical particle and will interact with others and experience a force which causes accelaration according to Newton's second law. Thus,the atomic positions and velocities at any time can be determined if the force, is calculated as a fuction of time . By applying those theories as well as Taylor expension to "classical Verlet Algorithm", if we denote the position of an atom,, at time by , the positions of the atoms at next time step, can be calculated by:
However, we cannot acquire any information about the velocities which is needed for calculating the kinetic energy by classical Verlet Algorithm. Therefore, a modified one called "velocity-Verlet Algorithm" is used instead and expressed as:
From figure 1 and figure 2 we can find that the error between "ANALYTICAL" and the velocity-Verlet solutions is quite small and the function of the error versus time is kind of "periodic" with increasing amplitudes and a half period compared to that of the position of a classical harmonic oscillator, which is given by , as the error comes to zero when the reaches a minimum or maximum. And the maximum value of error in each period increases linearly with time as a function of .
JC: Why does the error fluctuate?
The energy contains the total energy of the oscillator for the velocity-Verlet solution, which is composed of kinetic energy and potential energy. Therefore,
in this case, so:
From figure 3 to figure 6 above, it can be seen that the maximum percentage change in total energy (fluctuation) increases as timestep increases. When timestep is around 0.20, the maximum change in energy is 1%. Thus, the timestep should be no more than 0.20 to ensure that the total energy does not change by more than 1%. Besides, it is important to monitor the total energy of a physical system that does not change or fluctuate too much so that the total of potential and kinetic energy is always conserved if there is no extra force applied on the system.
JC: Good, thorough analysis..
Atomic Forces
For a single Lennard-Jones interaction, the potential energy is zero when:
Rearrange to get:
The force acting on the atom is determined by the potential it expierences:
When :
The equilibrium will be reached when the resultant force equals zero (the potential energy reaches a minimum):
Rearrange to get:
Therefore,
And the well depth is:
when ,
Therefore,
JC: All maths correct and well laid out.
Periodic Boundary Conditions
Under standard conditons, the density of water , and the total mass of water molecules in of water . Therefore, the number of moles of water molecules is .
The number of water molecules in of water is .
The volume of water molecules is .
The atom at initial position moves along the vector and will reach at the final position = under classical conditions. But by applying the periodic boundary conditions, the atom moves in a cubic simulation box which runs from to , and when it crosses the boundary of the box,one of its replicas enters the box through the opposite site. Therefore, the final position that the atom ends up should be .
Reduced Units
When the LJ cutoff is , The distance in real units should be:
The well depth is:
The reduced teperature in real units is :
JC: All calculations correct, except for the well depth. You have already shown that the well depth is just epsilon, so you just need to convert the value of epsilon given into kJmol-1.
Equilibration
Creating the simulation box
As it mentioned before, we need to specify the starting position of each atom before staring a simulation. However, it is quite hard to determine a point of reference for atoms in a liquid because there is no ordered crystal structures or unit cells. We could generate a random starting position for each atom, but this would probably cause a situation that two atoms are too close or overlapped together. And according to the Lennard-Jones potential relationship:
When the distance between two atoms are small, the potential energy will be infinitely large, which could cause a large error in simulation.
Consider a simple cubic lattice which consists of one lattice point on each corner of the cube, each atom at a lattice point is shared equally between eight adjacent cubes. So there is totally atom in each unit cell. When the number density is ,
,
Consider a face-centered cube which consists of one lattice point on each corner and face of the cube, each atom on the face is shared equally between rwo adjacent cubes. It gives totally atoms in each unit cell. If the number density is 1.2,
,
For the face-centered cubic lattice, each unit cell contains 4 lattice points or atoms as calculated before. Therefore, in a box that contains unit cells of this lattice, there are atoms in total.
JC: Correct.
Setting the properties of the atoms
mass 1 1.0
this defines the mass of the single atom of type 1 is 1.0
pair_style lj/cut 3.0
The lj/cut styles computes the standard 12/6 Lennard-Jones potential, given by:
is the cuttoff, it equals to 3.0 in this case, which means the LJ interaction over separating distance 3.0 is negligible.
pair_coeff * * 1.0 1.0
It specifies the pairwise force field coefficients for one or more pairs of atom types, in this case. An asterisk means all types of atoms from 1 to N, and then the two asterisks indicate that the coefficients apply to LJ potential between any two atoms.[2]
If initial conditions with and are specified, then we will apply velocity-Verlet Algorithm to run the simulation.
JC: Correct, why is a cutoff used for the potential?
Running the simulation
### 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
Here we define a variable called "timestep" and thus we can just type ${timestep} in the following parts instead of the exact number. The advantage of this is that when we need to change the timestep, we only need to change the timestep number in the second line and the ${timestep} in the following parts will be changed automatically. However, if we just write:
timestep 0.001 run 100000
Once we need to change timestep, we need to change every timestep in the whole text manually.
JC: Correct.
Checking equilibration
From figure 7 to figure 9 above, it can be seen that the energy, temperature and pressure reaches constant with small fluctuations after a short time, which indicates that the simulation reaches equilibrium. The fluctuations(error) in energy is the smallest compared to those in temperature and pressure. From the thermodynamic data of the simulation, it takes about 0.22 and 0.18 to reach the equilibrium for temperature and pressure respectively. And it takes around 0.28 for energy to reach the equilibrium just after the equilibrium of temperature and pressure.
From figure 10 we can notice that the simulations of energy at timesteps at 0.001 and 0.0025 after the equilibrium is reached are almost overlapped, and the simulations of energy at 0.0075 and 0.01 reaches equilibrium as well but with relatively higher energies compared to those at timesteps 0.001 and 0.0025, which cause larger errors or fluctuations.Therefore, the largest timestep that gives acceptable results is 0.0025. The one with the largest timestep 0.015 is a particularly bad choice because the energy increases as time increases with relative large fluctuation(error) and never reaches equilibrium. Therefore, the total energy will not be conserved.
JC: Good choice of timestep, the average total energy should not depend on the timestep.
Running simulations under specific conditions
Temperature and Pressure Control
Ten npt input files with different combinations of five tempreatures(1.6, 1.8, 2.0, 2.5, 3.0) and two pressures(2.6, 2.7) in reduced units are modified to run simulations on the HPC portal.
Thermostats and Barostats
In the system with atoms, each with three degrees of freedom, according to the equipartition theorem, we can obtained that:
After each velocity is multiplied by a constant factor , the temperature is corrected to , so:
Divide by :
Therefore,
JC: Correct.
Examining the Input Script
The number "100" corresponds to , which means using input values every 100 timesteps. The number "1000" corresponds to , which means number of times to use input values for calculating averages. And the number "100000" corresponds to , which means calculating averages every this timestep. The , and arguments specify on what timesteps the input values will be used in order to contribute to the average. The final averaged quantities are generated on timesteps that are a multiple of . The average is over quantities, computed in the preceding portion of the simulation every timesteps.[3] Therefore, in this case values on timesteps , , , , ..., will be used to compute the final average on timestep , which means every timesteps, values of the temperature, etc., be sampled for the average. And totally measurements(the same as ) will contribute to the average. Because we need to run the simulation until reaching the final timestep , if we assume the timestep is , and then the total time we need to simulate is .
JC: Good.
Plotting the Equations of State
According to the ideal gas law and reduced units conversion:
The density in reduced units can be obtained by:
We use this derivation of the density in reduced units to plot graphs of density versus temperature. And it is shown from figure 11 and 12 that the simulated densities in both cases are lower that calculated by ideal gas law. This is because the ideal gas law assumes that there is no interactions between particles. But in this simulation case, there are LJ interactions between atoms, which means there could be a repulsion between atoms that repel them further apart. And the density is the number of atoms per unit volume, therefore, the simulation density is always lower than the ideal density because of the longer distances between atoms due to LJ interactions(repulsion). And as temperature increases, the density decreases. This is because the volume of the system will increase as temperature increases when pressure is constant according to the ideal gas law. Therefore, the density decreases with temperature as the total number of atoms remains the same but the volume increases.
As shown in figure 13, the density at pressure 2.7 is always higher than the density at pressure 2.6, we can consider at a given temperature and number of atoms, when pressure increases, volume will decrease according to ideal gas law, which indicates that atoms pretend to be closer and suffer greater repulsion forces due to LJ interaction, thus it will deviate more from the ideal one. Besides, the trend of the discrepancy decreases as temperature increases, this is because as temperature increases, volume increases as well if the pressure and number of atoms are constant. Therefore, atoms becomes further apart from each other and affected less from the LJ interaction, and the increased volume caused by it is less and less significant compared to the total volume, which increases as temperature increases.
JCː Explanations are correct, but a bit unclear, try to make them more concise. Joining the ideal gas data points with straight lines is misleading because the ideal gas law does not follow these lines in between data points.
Calculating heat capacities using statistical physics
below is the input script with and to run the simulation for heat capacity under conditions:
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 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 ### MEASURE SYSTEM STATE ### thermo_style custom step etotal temp vol atoms density variable dens equal density variable temp equal temp variable temp2 equal temp*temp variable volume equal vol variable N2 equal atoms*atoms variable E equal etotal variable E2 equal etotal*etotal fix aves all ave/time 100 1000 100000 v_dens v_temp2 v_E v_E2 v_N2 v_temp unfix nvt fix nve all nve run 100000 variable avetemp equal f_aves[6] variable heatcapacity equal ${N2}*(f_aves[4]-f_aves[3]*f_aves[3])/f_aves[2] variable CperV equal ${heatcapacity}/${volume} print "Averages" print "--------" print "heatcapacity: ${heatcapacity}" print "heatcapacity/volume: ${CperV}" print "Temperature: ${avetemp}"
The heat capacity can be calculated by the equation:
In this case, the volume is constant under conditions, and we will be in density-temperature phase space, rather than pressure-temperature phase space. Therefore, density is defined as a variable rather than pressure .
It can be seen that the heat capacity per volume decreases as temperature increases for both densities, which is consistent with the equation . This is because as temperature increases, more atoms absorbs enough energy to reach the excited states or higher energy levels in a constant volume, which means fewer atoms on the ground state can absorb extra energy from outside. Therefore, fewer energy can be taken by the atoms in the system with constant volume and the heat capacity per volume decreases as well as temperature increases. Besides, the heat capacity per volume at density 0.8 is always higher than that at density 0.2. According to the equation: , the pressure will be greater for a larger density if the temperature is constant. And the larger pressure and density means that atoms are closer and larger amount of atoms in a constant volume. Therefore, we can choose a constant temperature at x-axis in figure 14 and find its corresponding y values of heat capacity per volume at both densities, the one with a higher density 0.8 has a larger value because there are more atoms per unit volume that can absorb energy and be excited to higher levels, which leads to a higher heat capacity. And according to the equation , the variance in energy increases as density increases, so the heat capacity increases.
JC: Correct explanation of the trend in heat capacity with density, the trend with temperature is harder to explain and would need more analysis beyond the scope of this experiment.
Structural properties and the radial distribution function
Phase | Density (reduced unit) | Temperature (reduced unit) | Characters and differences in RDF |
---|---|---|---|
Vapour | 0.05 | 2.2 | There is only one peak in RDF, which means atoms in vapour state are disordered and moving randomly. So there is no extra peaks which shows long or short rang order. |
Liquid | 0.8 | 1.2 | There are three main peaks with decreasing amplitudes, and the decay rate is faster compared with that of solid. This is because the atoms in liquid phase has a short range order and has a higher degree of freedom, which means the velocity or VACF is influenced more by the distance . |
Solid | 1.2 | 0.5 | In solid states, atoms are highly ordered and packed closely due to the large density, and this leads to relatively high values of RDF. There are many peaks with shorter widths and decreasing amplitudes, and the decay rate is slower than that of liquid state. This is because the atoms in solid state only vibrate and have lowest degree of freedom. Therefore, the RDF is affected the least by the increasing distance. And the first three peaks correspond to short range order, the following small peaks correspond to long range order. The widths between the peaks is corresponding to the distances between atoms in the first coordination shell, second coordination shell and etc. |
JC: Good, but what do you mean by "...the velocity or VACF is influenced more by the distance r."?
The graph of integral of in the solid state versus distance is shown as below:
And according to the FCC structure[4]:
The first peak corresponds to the 12 atoms (colored in blue orange and green) located at the center of the faces of unit cells, which adjacent to the central reference atom(red one). The second peak corresponds to atoms (pink), which are secondly nearest to the central reference atom and located at the corners that are the most close to the reference atom. The third peak corresponds to atoms, which are located at the rest of all grey points at the center of each face of unit cell. Because these points are closer to the reference atom than those at the corner. And the lattice spacing is just the same as the distance between any one of pink atoms and the central red atom according to the FCC lattice above, therefore, the lattice spacing is equal to the distance of the second peak which as shown in the figure 16.
JC: Good diagram to show which atoms are responsible for the first 3 peaks. Could you have calculated the lattice parameter from the first and third peaks as well and then averaged it, how does it compare to the lattice parameter of the initial structure of your simulation?
Dynamical properties and the diffusion coefficient
Mean Squared Displacement
From simulations of my relatively small system, we can get the relationships between MSD and timestep for different phases:
Acoording to the equation :
Diffusion coefficient can be calculated if the gradient (first derivative) of the line part in each diagram of MSD versus timestep is known, as the linear relationship needs a little time to be established. And the gradient can be calculated by any two points on the linear part.Therefore:
In vapour phase,
In liquid phase,
In solid phase,
From the data calculated above, it can be seen that the diffusion rate decreases from vapour phase to solid phase as expected. Atoms in the solid state are almost fixed in the lattice points with relative large density, which means the atom will experience much repulsion forces if it diffuses through the structure. Therefore, For atoms in the solid state, they can hardly diffuse due to the large energy barrier and the diffusion rate is almost zero. Besides, the diffusion rate of atoms in the vapour state is larger than that in the liquid state. Because the density for gas is much smaller, which means the interactions between atoms is quite small, and atoms can move as random motion, which are less restricted by others. Therefore, the atoms in the vapour state have the largest diffusion coefficient.
From the one million atom simulations, we can we can get the relationships between MSD and timestep for different phases:
Diffusion coefficient can be calculated by similar methods above:
In vapour phase,
In liquid phase,
In solid phase,
The diffusion coefficients for the larger system have similar magnitudes and trends as before, the graph of MSD in solid state seems more accurate with fewer error than that of the smaller system.
JC: It is more accurate to fit the linear part of the graph to a straight line to calculate the gradient, rather than calculating the gradient from only 2 data points. Why does the vapour MSD take longer to become linear - initial motion is ballistic.
Velocity Autocorrelation Function
The position of a classical harmonic oscillator is given by:
The velocity can be obtained by the first derivative of the position function:
Therefore, simply by substitution we can get:
The function can be further split by applying :
Because and are constant, they can be taken out directly:
Because :
Since is an odd function, the integration from negative infinity to positive infinity should be zero. Therefore:
JC: Correct, sin(x)cos(x) is also an odd function (even x odd = odd), so you don't really need to do the last step.
According to the velocity autocorrelation function:
It can be seen that is the dot product of the velocities at time and . And the minima correspond to the particle collides with another with an angle () which maximize the dot product and changes its direction after . The initial value of VACF at for liquid is greater than that for solid. This is because the atoms in liquid state can move more freely with larger initial velocity, but atoms in solid state can only vibrate around fixed position with much lower velocity.
The simple harmonic oscillator behaves differently because there is no collision and the total momentum and energy are conserved all the time. But for the Lennard Jones solid and liquid, the velocity will keep decreasing as time increases because of the loss of kinetic energy or momentum during the collision.
JC: Kinetic energy is not lost in the Lennard-Jones simulations, but collisions randomise particle velocities which causes the decay in the VACF.
The integral under the velocity autocorrelation function can be estimated by applying the trapezium rule, the relationships between the integral and time for my small gas, liquid and solid simulation can be obtained:
Accoording to the velocity autocorrelation function:
The simulations are all started from initial time , therefore:
And accoording to the diffusion coefficient equation:
The integrals of VACF from time to have been calculated from figures above, because VACF converges to as time increases, therefore:
In vapour phase,
In liquid phase,
In solid phase,
For the one million atom simulations:
In vapour phase,
In liquid phase,
In solid phase,
Th diffusion coefficients for three phases from the two simulations are calculated as expected, because they decrease from vapour phase to solid phase.
The diffusion coefficient should be calculated by integration of VACF from zero to infinity, however in this case we only calculate from zero to ten. Besides, we use the trapezium rule to estimate the integral with a , it is not infinitely small and so the estimated area under the function by many small trapezoids is not perfectly matched with the actual area, which means the integral may be underestimated.
JC: Good, the running integral needs to plateau for this estimate of D to be accurate.