Molecular dynamics simulation of a 3D Lennard-Jones liquid

Demonstration:

LJ3MDApp

You can use mouse to rotate the structure.

Downloads

Java version

The above applet: LJ3MDApp.java

Command-line version: LJMD.java (no GUI).

C/OpenGL version

LJ3 C version

The C program (a snapshot is shown on the right) uses OpenGL for better 3D rendering. It also has better keyboard support. The source code is here: lj3.c (needs -lglut -lGLU to compile).

A command-line version: ljmd.c (no GUI simpler).

Precompiled executables:

  1. Windows version (lj3.exe) (it needs a free DLL from free GLUT or GLUT)
  2. Mac version (lj3mac) (to use the executable, you need to first save a copy of the file, open a command line terminal switch to the directory of the file, then type chmod +x lj3mac then run it as ./lj3mac or double-click it.)

Contrary to my speculation, the C version is only marginally faster than the Java one. With optimal flags (icc -O3, gcc -O3 -march=pentium4 -mfpmath=sse, and Java -O) the relative speed for Intel C/GCC/Java is 1.0/0.9/0.76. Note, GCC could make a terribly slow version without the -mfpmath=sse flag.

Explanations

The potential between two particles is given by

u(r) = 4(r−12r−6),

where r is the distance between the two particles. The potential energy of the system is the sum of potentials from all pairs.

To reduce the finite-size effect, we have used the periodic boundary conditions,

The potential is truncated at the half-box size, at which point the force becomes discontinuous (a minor artifact, usually negligible).

The pressure is computed from the sum of the ideal gas part ρkT and virial divided by 3V.

The tail corrections are applied to the potential energy and pressure.

Utail = (8/9) πρN ( rc−9 − 3 rc−3),
ptail = (16/3) πρ2 ( (2/3) rc−9rc−3),

Questions

Many people would choose to simulate a system of 108, 256 or 500 particles (N), especially at a low temperature. Is there is a reason? (Hint: N = l3/2).

Does the use of a thermostat make a difference?

Compare the simulation results with those in: The Lennard-Jones equation of state revisited, J. Johnson, J Zollweg and K. Gubbins, Mol. Phys. 1993, Vol 78, No. 3, 591-618