## Using Open-Source Java Applets for Teaching Statistical Physics

### August 5, 2002 AAPT meeting, Boise State University

#### Peter Sibley, Clark University

http://stp.clarku.edu/

National Science Foundation PHY-9801878

## Important Ideas in Statistical Physics

• A system in a nonuniform macrostate will change in time on the average so as to approach its most random macrostate where it is in equilibrium (except for especially prepared initial conditions).

• Importance of fluctuations in equilibrium.

• Concept of temperature, entropy, and chemical potential.

• The canonical probability distribution for a system in equilibrium with a heat bath.

• Students have many problems with understanding basic concepts such as pressure, temperature, and potential energy in terms of the motion of molecules.

• Many conceptual problems associated with probability.

• There are a wealth of applications in thermal physics. The only ways to go beyond the ideal gas in an undergraduate course is to consider mean-field theory, the one-dimensional Ising model, and simulations.

## Nature of Simulations in Statistical Mechanics

• Solve Newton's equations of motion for a system of interacting particles and sample microstates in the microcanonical (constant energy) ensemble.

Students can see that particles exert forces on piston causing it to move and that particles don't slow down due to friction.

• Directly sample the microstates with the desired probability for a given ensemble. For example, microstates in the canonical ensemble (constant temperature) are sampled with a probability proportional to exp(-E/kT).

MC methods make ensembles more concrete and can illustrate probability ideas that are too tedious to work out by hand.

## Java Applets and the Open Source Physics Library

• Ideally, students should develop simulations themselves, but this development is not practical.

• Need to develop environment in which programming is straightforward and the graphics statements and algorithm are clearly separated.

• Implication is that development environment should be object oriented.

• Two possibilities are VPython, vpython.org, and the Open Source Physics Library based on Java, www.opensourcephysics.org

## Java Applets for Statistical and Thermal Physics

In the talk a copy of stp.clarku.edu/simulations was made. Because it has since been updated, I have include a link to the updated page.

During the talk I discussed the Demon algorithm and showed some results.

I also showed some results for a Lennard-Jones gas approaching equilibrium. result

## Sample Code

A big advantage of the Open Source Physics Library is that we don't have to spend any time setting up a graphical environment, a plotting environment, and an input/output environment. Thus, the only serious thinking needs to go into the algorithm that does physics.

Source code can be found at stp.clarku.edu/simulations/source.