Rep:Mod:Tfy286
Introduction to molecular dynamics simulation
Task
1. 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).
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.
2. 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 energy is 0.5. If the total energy does not change by more than 1%, the minimum energy should be 0.5*(1-1%)=0.495. Therefor the timestep is required to change to 0.2 (or less than 0.2). Here is the new diagram when timestep equals to 0.2.
3. For a single Lennard-Jones interaction, , find the separation, , at which the potential energy is zero. What is the force at this separation? Find the equilibrium separation, , and work out the well depth (). Evaluate the integrals , , and when .
1). when potential energy=0,
=0. So,= .
2). energy is zero, so net force is zero as well.
3). at , potential energy is minimum, = 0,
=
So, =
4). =
=
=
4. Estimate the number of water molecules in 1ml of water under standard conditions. Estimate the volume of 10000 water molecules under standard conditions.
1). density of water is , no.(water)= =
2). =, so volume of 10000 water molecules is
5. 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?
The new position .
However it follows the periodic boundary condition, so it should be .
6.The Lennard-Jones parameters for argon are . If the LJ cutoff is , what is it in real units? What is the well depth in ? What is the reduced temperature in real units?
1) r= 0.34* 3.2 nm = 1.088nm
2)
3) T= 120* 1.5 K = 180K
Equilibration
task
1. 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?
If two atoms are too close together, there will be a huge repulsion existing between them. In order to calculate the huge energy change, the timestep should be very small. Therefore the computation process will be much more difficult.
2. Satisfy yourself that this lattice spacing corresponds to a number density of lattice points of 0.8. 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?
there are four lattice points per volume per unit cell in a face-centred cubic.
3. 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?
4*(10*10*10) = 4000 atoms will be created.
4. Using the LAMMPS manual, find the purpose of the following commands in the input script:
mass 1 1.0:
1 indicates the atom type, here is type 1.
1.0 indicates the atom mass, here is 1.0
pair_style lj/cut 3.0:
pair_style lj/cut means cutoff Lennard-Jones potential with no Coulomb,
3.0 is the arguments used by a particular style
pair_coeff * * 1.0 1.0:
asterisks here are used in place of or in conjunction with the I,J arguments to set the coefficients for multiple pairs of atom types.
1.0 and 1.0 here are the coefficients for the atom types
5. Given that we are specifying \mathbf{x}_i\left(0\right) and \mathbf{v}_i\left(0\right), which integration algorithm are we going to use?
velocity-Verlet algorithm
6. 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
If the timestep is fixed at 0.001, once the timestep is required to change, all the timesteps will change into other values by hand.
However, if the timestep is set as a variable, only the first line is required to change, and the rest of them will change automatically.
7.1) make plots of the energy, temperature, and pressure, against time for the 0.001 timestep experiment (attach a picture to your report).
2) Does the simulation reach equilibrium? How long does this take?
Yes, the simulation reaches equilibrium when time= 0.43
3) make a single plot which shows the energy versus time for all of the timesteps (again, attach a picture to your report).
4)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?
0.01 is the largest to give acceptable result. And 0.015 is a particular bad choice because there is a big deviation from the others.
Running simulations under specific conditions
Task
1. Choose 5 temperatures (above the critical temperature T^* = 1.5), 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 \left(p, T\right) 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.
Pressure | Temperature |
---|---|
2.7 , 2.8 | 1.8 , 1.9 , 2.0 , 2.1 , 2.2 |
2. We need to choose so that the temperature is correct if we multiply every velocity . We can write two equations:
. Solve these to determine .
So,
3. 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?
100 stands for the number of input values every this many timesteps
1000 stands for the number of times to use input values for calculating averages
100000 stands for calculate averages every this many timesteps
Therefore the value of temperature will sampled for 1000 times. And there are 1000 measurements contributing to the average.
4. 1). 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. Does the discrepancy increase or decrease with pressure?
The higher the pressure the discrepancy increases.
2). 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.
according to the ideal gas law,
, (reduced unit)
The simulated density is lower than the ideal density. Because there are interaction forces existing among particles. When the pressure is applied, the repulsion between particles becomes dominant, and the distance between particles will be larger, so the density will be lower than the ideal situation.
Calculating heat capacities using statistical physics
Task
1. input script
### DEFINE PARAMETERS ### variable D equal 0.2 variable T equal 2.8 variable timestep equal 0.0075 ### DEFINE SIMULATION BOX GEOMETRY ### lattice sc ${D} 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 ### 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 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 atomss equal atoms variable etotal equal etotal variable etotal2 equal etotal*etotal fix aves all ave/time 100 1000 100000 v_dens v_temp v_press v_dens2 v_temp2 v_press2 v_etotal v_etotal2 run 100000 variable avedens equal f_aves[1] variable avetemp equal f_aves[2] variable avepress equal f_aves[3] variable errdens equal sqrt(f_aves[4]-f_aves[1]*f_aves[1]) variable errtemp equal sqrt(f_aves[5]-f_aves[2]*f_aves[2]) variable errpress equal sqrt(f_aves[6]-f_aves[3]*f_aves[3]) variable energyvariance equal (f_aves[8]-f_aves[7]*f_aves[7]) variable heatcap equal ${atomss}*${avedens}*${energyvariance}/(f_aves[5]) print "Averages" print "--------" print "Density: ${avedens}" print "Stderr: ${errdens}" print "Temperature: ${avetemp}" print "Stderr: ${errtemp}" print "Pressure: ${avepress}" print "Stderr: ${errpress}" print "heatcap per volume: ${heatcap}"
2. Plot C_V/V as a function of temperature
Structural properties and the radial distribution function
Task
1. perform simulations of the Lennard-Jones system in the three phases. When each is complete, download the trajectory and calculate g(r) and . Plot the RDFs for the three systems on the same axes, and attach a copy to your report.
2. 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?
g(r) shows several peaks in the liquid state, which means the probability at these radial distances will be much higher than the others. Secondly, there are much more peaks observed in solid phases. The peak differences are caused by the different interaction forces. In liquid phases, the attractive force is dominant, and in the solid phase, the structure is regular and periodic, the interaction is stronger than in liquid phase, and the repulsive force is dominant. For face centred cubic, regarding (0,0,0) as a center, the first three peaks correspond to (1/2,1/2,0), (1,0,0) and (1,1,0). The difference from 0 to the second peak is the lattice point, 1.475.
Dynamical properties and the diffusion coefficienT
Task
1. 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 D 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.
MSD(SOLID) | MSD(LIQUID) | MSD(GAS) |
---|---|---|
Because ,
For solid, D = 0.0273/(2*0.016991) = 0.803
For liquid, D = 2.81/(2*1.67448) = 0.839
For gas, D = 12.9/(2*7.74)= 0.8333
2. 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!):
Be sure to show your working in your writeup.
For a 1D harmonic oscillator
Therefore
and
Because
For the upper integration:
For the lower integration:
So,
from to ,
2). On the same graph, with x range 0 to 500, plot with and the VACFs from your liquid and solid simulations.
3). 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.
The minima represents the starting points of self-diffusion. The origin of the differences is the interaction force difference. The interaction is larger , so the diffusion coefficient is smaller, which can be also observed by the area difference under the VACF(r) curve of two different phases.