Optional checkpoint 6.

This checkpoint requires that you examine the effect of having many particles. This is the type of thing computers are much better than humans at, repeating the same operation over and over. It also lends itself to parallelisation, where many different processors work on the same problem.

Add a field Particle.box to your particle class to specify how the particle is constrained. This variable should take the following meanings:

Negative values mean the particle is constrained by elastic walls to move in a cube of length Particle.box . The class should ensure that if the particle attempts to move outwith this region, it is reflected back. e.g. if at t+dt it attempts to move to position (-x,y,z) outside the box then its position is converted to (x,y,z) inside the box, and the x component of its velocity changes sign.

Zero value of particle.box means the particle is free to move anywhere, as before.

Positive values mean the particle is subject to periodic boundary conditions in a cube of length Particle.box . The class should ensure that if the particle attempts to move outwith this region, it reappears at the opposite face e.g. if at t+dt it attempts to move to position (-x,y,z) outside the box then its position is converted to (Particle.box-x,y,z) inside the box, without changing velocity.

Write a program to instantiate an array of N particles, which all interact with each other via the Lennard Jones potential and move in 2D (you already have this method from Checkpoint 5), and integrate their equations of motion in time assuming them to be constrained in a cube (negative particle.box).

Make a movie of the the simulation using the ParticleFrame class .

More options

Write a class which evaluates the pressure of this gas from the momentum change of the particles striking the boundary, and examine the relation between pressure, density and temperature (kinetic energy). Note that to get good results from this you will need a timestep which conserves energy well, and runs which are long enough to get good statistics. Your code may take a while to run, so you should ensure that the "inner loop" contains only essential operations. The solution to Checkpoint 3 illustrates the use of an inner integration loop and an outer analysis loop.