University of Maryland Physics Education Research Group

Resources on the Web for Teaching Physics

Physics Software from the UMd PERG:
Thermo -- A Gas in a Box Simulation

E. F. Redish, G. Norkus, and J. B. Harold
University of Maryland, College Park

Download File (165 KB)

Brief description

THERMO is a statistical mechanics simulation that allows you to investigate a wide variety of equilibrium and non-equilibrium phenomena. You can display the motion of up to 1100 particles in a box moving under a variety of forces: hard sphere collisions with each other, external fields, and friction when they collide with the wall.

Pedagogical utility

THERMO lets students visualize the motion of particles in a gas. The initialization choices allow the student to see how the system naturally evolves from a regular pattern into the most probable (Maxwell-Boltzmann) distribution. The view of the velocity (or energy) distribution shows that the distribution is not static, but fluctuates in time.

The program allows a wide variety of investigations with different circumstances. In addition, position and velocity data can be written out to files to be analyzed off-line. This makes THERMO valuable as a tool for student independent explorations or projects.

Appropriate for

Screen view

Fig. 1: A screen view of THERMO with display of the distribution of particle speeds.


The code may be downloaded by clicking here. (165K)

The file is a zip file. Unpack it using WinZip. You will then find the following files in your directory:

If you are running under Windows, be certain the computer knows where the file is and what directory it is in. To check this, right click on the program icon and choose "Properties." On the tab "program" make sure the full address of the program is correct. The "start-up directory" should be the directory containing the program.

Technical information

The program follows the paths of up to 1100 particles moving in a box. When particles enter the same pixel, they are transformed to their CM frame and their velocities are rotated by a random angle. They are then transformed back to the lab frame.

A variety of "mean field" forces may be applied, including gravity, electric, and magnetic. All the field only act on the individual particles. The particles do not interact with each other by any except contact forces. (So particles are assumed to be charged for their interaction with the electric and magnetic fields, but the particle-particle interactions are ignored.)

The path of a single particle can be displayed while all the others remain present but invisible, This is useful for demonstrating the meaning of the mean free path. The mean free path may also be calculated, but the calculation is done by noting at each collision the distance each particle has traveled and averaging. This biases the calculation at the beginning since only one side of the distribution is seen. The MFP approaches the true value from below.

An "ergodic" average may be taken by writing out the velocity data repetitively at times separated by long enough intervals that the distribution re-randomizes itself. The resulting time average shows fluctuations characteristic of the total number of velocities rather than the total number of particles. The distribution may be read from the saved data using the program HISTOGRAM. Note that the Maxwell-Boltzmann distribution in two dimensions has a phase space factor of v instead of v^2!

The left and right sides of the box may be identified to simulate flow in a tube. The parameter FRICTION can be set so that each collision with an upper or lower wall reduces in a loss of some fraction of the particle's horizontal momentum.

Associated materials

A microlab is available that uses THERMO for a one or two hour session. There are also a number of homework problems available that use THERMO. These will be made available through the Web in the near future. In the meantime, contact the

Contact person

E. F. Redish, University of Maryland, College Park, MD 20742; phone: 301-405-6120, fax: 301-314-9531, e-mail:

Program help

You can get help by pressing < F1 > . If a menu or submenu item is selected, the help will give information on that item. Otherwise, it will give general help information.

Select the menu bar at top by using the cursor keys, the highlighted letter, or by clicking on the entry using the mouse.

Select a menu entry or toggle its value by highlighting it and pressing < enter > or by clicking on it with the mouse.

The environmental status (forces, etc.) is displayed on the Status bar at the bottom of screen.

The running of the simulation is started and stopped by pressing < spacebar > .

Use < esc > or click mouse off the menu - to step back off menus.

When a number is needed by a menu or submenu item

  1. Press < enter > to get the value-entry window.
  2. Key in your value.
  3. Press < enter > to set it, or < esc > to cancel and return to original value.

Menu entries:

Indents indicate menu level.