The Fabulous Particles

The particles applet is an exercise in the use of Java threads, pieces of code which run simultaneous to each other. In this applet, each particle owns its own thread, and the program environment considers and calculates the action of each particle simultaneously (or as close to simultaneity as can be achieved on whatever hardware the applet runs.)

Each particle has its own mass and charge. The mass determines the size of a particle, and how easily it moves, while the charge determines how the particle will react to other particles. Particles with similar polarity (for example, two particles with positive charges or two particles with negative charges) will repel each other, while particles with opposite polarity will attract each other. The greater the charge, the greater the strength of the repulsion or attraction. To see these principles in action, try creating some sample particles, following the instructions below:

  1. The particles program is set up by default to create particles with a mass of 1000 and a charge of 1, particles I think of as "protons". Click the "Create a particle" button to make one of these protons.
  2. The particle will manifest itself as a sizable red dot (all positively charged particles are red) in the large rectangular window. The dot is placed at a random location in the window. You may notice some flicker -- this is due to the fact that the dot is continually considering where it should be, and redrawing itself there.
  3. The dot is totally motionless at the moment, since no other particles are acting upon it. Let's make another particle to affect the first. Enter "1" in the Mass field and "-1" in the Charge field, then click the "Create a particle" button.
  4. A small blue particle (all negatively charged particles are blue), which I call an "electron" shows itself, again placed initially at a random location in the window. The electron, however, is much more active than the proton, since its mass is far less and the opposite charge and greater mass of the proton is attracting it. The electron will circle around and bounce off the proton for a while, and may even get it moving.
  5. To crank up the action, create several more electrons and protons. Soon you should have all the particles in motion. Because they are encoded as threads, all the particles consider each other at the same time. Depending on the speed of your machine, you may notice a significant slowdown as you accumulate more and more particles -- each time a new particle is created, it has to take all the others into account at every moment, and vice versa. This can get to be quite a computational burden!
  6. Experiment with different masses and charges, and by changing the values in the slide bars. These values, along with the equations used to move the particles, are explained below the applet.

Factors and Calculations

Creating a Particle

The first thing that happens when a particle is created is that the program chooses its color: blue for negative particles and red for positive or neutral particles.

Then the particle's diameter and speed limit are calculated as follows:

Finally, the particle is placed at a random location within the graphics rectangle and given a speed of 0.

Calculating the Forces

Note that the Particles applet does some calculation to determine the size of the rectangular graphics area, and if the browser window is resized in such a way as to exclude a particle, that particle is randomly repositioned inside the resized box. Those calculations are not listed below.

All the particles are placed in a vector, and each thread loops through the vector determining the effect of all the other particles according to the following equations:

These equations and calculations are from a specification written by Michael Main. The implementation of the program and its interface design were done by me. -==--==--==--==--==-
The Fabulous Particles Applet / Paul O'Brian / obrian at colorado.edu / Revised April 1999
Return to my home page