The Brazil Nut Effect

Modern computer gaming systems come with built-in physics engines. Can we use a physics engine to simulate real phenomena?

Educational objective

Understand self-organization: how high level behaviours can arise from low level interactions.


This material was presented to a group of high school students (grades 9-11) with varying computer experience.


A number of packages need to be installed on the machine before the students can run the simulation.

  1. Python 2.5 - the python interpreter.
  2. Numeric 24.2 - array calculations needed for pygame (0.4M)
  3. Pygame 1.7.1 - graphics engine (1M)


The file must be expanded on the students machine. The student will run the program by clicking on

A variety of clear plastic containers with lids (e.g., drinking cups). Containers should hold a mixture of two types of hard candies, such as M&M(R) plain and peanuts. We used different colours for the large and small candies, some containers with many large and a few small, and others with mostly small and a few large.

A can of mixed nuts fresh from the supermarket.


  1. Open a can of mixed nuts and start pulling the brazil nuts from the top. (You may want to check this at home first). Talk about the industrial importance of mixing things and keeping them mixed.
  2. Hand out containers of candies (we were competing with liquid nitrogen ice cream in another class 8-); have the students shake their containers and report what happens.
  3. Run the liquids program; instructions on the keystrokes are in README.txt.
  4. Have students construct various configurations of light/heavy and large/small 'nuts' and press the shake button.
  5. Show the students the source code which defines the different objects so that they have more control over the weights.
  6. Depending on the duration of the class.
  7. In the remainder of the class, the students played with the demo, creating e.g., water waves by dropping heavy objects in a 'pool' of light objects. We also did some simple crystal packing demonstrations; depending on the size and shape of the container, and the uniformity of the 'atoms' you can show various crystal defects.