Optimizing a Gauss Gun
A Gauss gun is a type of linear magnetic accelerator in which projectiles (here ball bearings) interact with an array of magnets. The magnets are shown as red/green spheres, fixed in position. A ball bearing introduced on the left is attracted to the first magnet and undergoes a rapid acceleration that increases its kinetic energy. Upon colliding with the magnet, this energy is transferred through the magnet and a chain of stationary ball bearings, releasing the rightmost bearing. See how the final velocity varies as you change the ball radius, air gap, number of stages, and balls per stage.
The force between a spherical magnet and a steel ball bearing can be approximated as the force between two aligned dipoles
Here the magnet radius is and ball bearing radius is , the center-to-center separation is , the magnetic separation is , and the vacuum permeability is . For simplicity, replace other parameters with the constant , which is constant for a given magnet and ball bearing. This constant is easily measured by suspending the magnet from a string, attaching a light bucket to the ball bearing, and adding weights to the bucket until the ball bearing separates.
Moving a magnet and ball bearing from distance to generates potential energy
Under frictionless conditions, this potential energy is converted to kinetic energy as the ball bearing is attracted to the magnet. If the initial velocity at distance is 0 m/s, at distance the velocity is
When the ball bearing collides with the magnet, the momentum of the ball bearing is transferred through the magnet and then transferred to any ball bearings attached to the other side of the magnet. The final ball bearing rolls freely. Multiple stages of magnets and ball bearings can be coupled together, with each stage adding energy to the system.
 J. A. Rabchuk, "The Gauss Rifle and Magnetic Energy," The Physics Teacher, 41(3), 2003 pp. 158–161.
 D. Kagan, "Energy and Momentum in the Gauss Accelerator," The Physics Teacher, 42(1), 2004 pp. 24–26.