Last edited May 5th, 2005 by David Burghoff
Find this document at

PyIon: A Simulation of the Behavior of Ionized Gas Particles


PyIon is program designed to visualize the behavior of ionized gas particles. It was originally modified from Gregory Stanton's PyBounce and is written in Python. Furthermore, it implements the pytree pyszg bindings, so it should run without modification in the Beckman Institute's CAVE or CUBE. The program allows the user to place particles of arbitrary charge in the system, which then move according to the partial differential equations which govern the laws of electromagnetism. Additionally, when the particles collide with each other or with the walls of the simulation, they do so elastically, and energy is conserved. For interactivity, the six joystick buttons can be used to change the system in a multitude of ways.

Running PyIon

PyIon currently has four basic modes of operation, each of which describes a different system of fundamental constants (though none of them describes the constants as they are in the actual universe). Nevertheless, each system has a demo associated with it that shows some interesting aspect of the program. The modes and demos are as follows:

  1. Regular Mode: This is the default mode. As in real life, electric fields are much stronger than magnetic fields. The demo shows two positively-charged particles interacting with each other.
  2. Gas Mode: All electric and magnetic fields are turned off, so the particles just act as a regular, neutral gas. The demo just shows several neutral particles bouncing around.
  3. Inductor Mode: All electric fields are turned off, and the magnetic field is made very strong. The demo shows two negatively-charged particles moving in a spiral shape, due to their respective magnetic fields.
  4. Orbit Mode: The magnetic field is turned off, and the electric field is made very strong. The demo shows a negatively-charged and a positively-charged particle orbiting one another. Because charged particles obey an inverse square law, just as classical gravity does, this is analogous to two planets orbiting each other.

The different particles in the system can be distinguished by their color. Positively-charged particles are blue, negatively-charged particles are reddish-orange, and neutral particles are grey. To add a particle to the system, one should push button 0 on the CUBE wand. Particles are placed in the center of the system with a random velocity, unless that position is currently occupied by another particle (in which case a random position is selected). Similarly, to remove a particle, one just pushes button 1. The first particles added are the first ones removed. Whether a positive, negative, or neutral particle is added/removed depends on a flag set by button 2. Pressing this button toggles between adding/removing positive and negative particles. In order to select a neutral particle, one holds down Button 2 while pushing the appropriate add/remove button.

It is also possible to change the size of the simulation, using buttons 2 and 3. Button 3 will change the size of the simulation by a factor of 1.5, while button 2 will select whether you are increasing or decreasing it. (When you have selected a positive charge, you will increase the size by 50%, and when you select a negative charge, you will decrease the size by 33%.) Finally, modes can be selected by pressing button 4. Each press will select the next demo to be loaded, and button 5 will load that demo.


Regular Mode Demo:

Gas Mode Demo:

Inductor Mode Demo (in a small system):

Orbit Mode Demo:


The main limitation of this program is its inability to handle large numbers of particles. On most systems, it can only handle up to four, and on some, even that is pushing it. However, I believe that much of this is due to the unavoidable complexity of the math involved. To calculate the forces on each particle requires an algorithm with quadratic running time, and when combined with the fact that each iteration of the Runge-Kutta fourth-order approximation is very substantial, it causes the running time to get very large very quickly. Some research revealed that many plasma simulations are done on supercomputers, which make sense.