1The main assignment¶
Molecular dynamics code integrate Newton’s equations to follow the dynamics of a systems made of components interacting with each other through a well-defined set of potentials. The mandatory part of this assignment is to write a molecular dynamics code that can be used to simulate a 3D Lennard-Jones system at a given temperature and density , where is the number of particles and is the volume of the simulation box. Use the algorithms discussed in class and implemented here. The code should
- Take as input at least the number of particles, temperature, density and the integration time step, .
- Initialise the system, for instance by using a function that places the particles on a cubic lattice, as done in the notebook linked above. Do not forget to also initialise the velocities as discussed during the lectures.
- Use the Velocity-Verlet integrator for the equations of motion.
- Take into account periodic boundary conditions (see below for details).
- Make it possible to optionally couple a thermostat to the system. The simplest to implement is the Andersen thermostat.
To make this assignment self-contained, I report here the expression for the LJ potential acting between two particles and :
where σ is the particle diameter, ε is the depth of the attractive well, and is the distance between and . As discussed in class, non-bonded interactions such as this one are cut off at some distance for performance reasons. A common choice for the LJ potential is , but you should use a larger value (e.g. to ensure that the correct scaling of the energy fluctuations is observed). When computing the energy (for instance to compare yours results with the values reported below to test your code) don’t forget to also shift the potential: the interaction energy for the pair should be:
By taking the gradient of the expression above with respect to and changing the sign we obtain the force acting on due to , which is
where . As a consequence of Newton’s third law, .
My advice is to make use of reduced units: the particle diameter is σ, the depth of the LJ well is ε, and the mass of a particle is , so that time is measured in units of .
The documentation accompanying the code should contain a plot that shows that the fluctuations of the total energy is proportional to [1].
2Possible extensions¶
- Add neighbour lists to speed up computation.
- Add a routine to calculate the pressure of the system. See below for values you can use to check your code.
- Extend your code to also support Lennard-Jones dumbbells. Now your basic particle is made of two spheres connected by a bonded interaction. You can check that your code works by comparing the pressure as a function of temperature and density to Fig. 2 of this paper[2], where the bonded interaction acting between the two spheres that compose a dumbbell is , with .
3Additional details¶
3.1Reference energy data¶
First of all, check that the average kinetic energy per particle is compatible with the equipartition theorem, i.e. that .
If the first test is passed, here I report the average and standard deviation of the potential energy per particle, , of some systems you can use to check that your code works. This data has been generated by running simulations of systems composed of particles for 106 time steps, with time step , cut-off , and computing the energy every 1000 time steps.
[] | ρ [] | [ε] | Std. dev. [ε] |
---|---|---|---|
1.5 | 0.4 | -2.24 | 0.09 |
1.5 | 0.6 | -3.32 | 0.10 |
2.0 | 0.4 | -2.10 | 0.10 |
2.0 | 0.6 | -3.11 | 0.13 |
You should not expect to match exactly these numbers, but if you run for the same number of time steps (which could take several minutes, or even tens of minutes, depending on your implementation), you should not observe differences larger than a few percent.
3.2Periodic boundary conditions¶
Applying the periodic boundary conditions in a cubic box with side means that the distance between two particles with coordinates and is
where is a function that rounds its argument to the nearest integer.
3.3Pressure in a Lennard-Jones system¶
There are many (mostly old) papers dealing with estimating the equation of state of a Lennard-Jones fluid. In most of them, the pressure computed in an MD simulation is corrected by the following term, which takes into account the truncated tail of the potential in a continuous way:
With this in mind, you can try to evaluate the pressure, correct it by applying the shift of Eq. (5), and compare the results with those reported in Johnson et al. (1993). However, note that in the paper a large cut-off () was used.
If you feel that your code is not fast enough, you can use the following values, obtained with , , and simulations of 106 time steps:
[] | [] | [3] [] |
---|---|---|
2.0 | 2.2 | 1.8 |
3.0 | 4.0 | 3.6 |
4.0 | 5.7 | 5.3 |
- Venkatareddy, N., Lin, S.-T., & Maiti, P. K. (2023). Phase behavior of active and passive dumbbells. Physical Review E, 107(3). 10.1103/physreve.107.034607
- Johnson, J. K., Zollweg, J. A., & Gubbins, K. E. (1993). The Lennard-Jones equation of state revisited. Molecular Physics, 78(3), 591–618. 10.1080/00268979300100411