The Lennard-Jones potential describes the behavior of neutral intermolecular movements. At close distances the particles have a severe repulsive force. When nearby they experience an attractive force. The potential is:
The force is:
This program uses the velocity Verlet algorithm to update the positions and velocities:
The components of the force are calculated by:
Where
This program follows these steps.
1. A desired amount of particles are initialized with positions and velocities from a distribution. The forces on each particle are calculated from these positions. The kinetic, potential, and total energy of the system are calculated and stored for graphing later. These particles are confined to a box of user set length.
2. The particle positions are visually represented on a JPanel that will be updated for animation.
3. A step forward in time is taken.
4. The positions are updated from the forces and velocities.
5. Boundary conditions are checked to ensure that particles stay within the defined box size.
6. The forces are updated from the new positions.
7. The velocities are updated from the new forces and the last set of forces.
8. The kinetic, potential, and total energy are calculated and stored.
9. The JPanel is updated with the new positions.
10. Returns to step 3 until the total time is reached.
The kinetic, potential, and total energy values are exported to lennard.csv and can be graphed in python with lennard-jones.py
For more details see the wikipedia articles on the Lennard-Jones potential, and the velocity Verlet algorithm.
Here is a video that has two different runs next to each other.
Below are the energies of two different runs with 12 particles with initial velocities.