Magnets — how do they work?

Water, fire, air, and dirt

Magnetic fields cause electrons to spiral
Helmholtz coils producing cyclotron motion photo by Marcin Białek

Most magnetic fields used in scientific instruments are generated with either permanent magnets or an arrangement of Helmholtz coils. Helmholtz coils are made from two identically-sized loops of wire wound in the same direction. The loops are separated by a distance of exactly each loop’s radius. When electricity is passed through the loops, a mostly homogenous magnetic field is generated between the two loops. The image above shows the effects that a beam of electrons experiences inside the magnetic field generated by a Helmholtz coil. The electrons are accelerated using high voltage and are made visible by their impinging some residual gas, causing it to fluoresce. As can be seen, the electrons arc in a circle.

Unlike electric fields, magnetic fields do not have a particularly intuitive way of explaining how they work in relation to ions. In short, they work by causing a charged particle’s trajectory to curve, known as the Lorentz force. The Lorentz force is calculated by the following equation — sometimes known as the Lorentz law:

F = qE + qv × B

where F is the force on a particle as a function of its charge, q, the electric field, E, the magnetic field, B, and its velocity, v. The “×” in this case means to take the cross product of the magnetic field vector and the velocity vector. Two differences are apparent from the equation. First, the effect of the magnetic field on the charged particle is a function of the particles’s velocity — the slower it moves the less force it feels. If it stops moving, it feels no magnetic force at all. Second, the cross product of the magnetic and velocity vectors means that the force is applied perpendicularly to those two vectors. The second one is, to my less-than-mathematically-inclined brain, difficult to intuitvely grasp. Some version of following diagram is often provided, and it helps explain the picture above of the circle of electrons:

Diagram of Lorentz force on building
“Lorentz force — a charged particle deflects in a magnetic field” photo by Vysotsky

In the photo of the diagram above, the magnetic field is depicted as travelling “into” the wall. This is shown by the cross-in-circle symbol ⊗. If the magnetic field were travelling “out” from the wall, the symbol would be a circle with a dot in its center ⊙. A mnemonic for remembering the two symbols is to think of an arrow flying toward or away from you, with the feathers of the arrow seen in a cross as it flys away and the point seen as it comes towards.

Implementing a rigorous simulation of magnetic fields is extremely difficult, as charged particles themselves will generate magnetic fields as they travel. SIMION has a limited ability to simulate magnetic fields. The Simulation Playground is even more limited and only allows magnetic fields travelling exactly “into” or “out from” the viewing plane — the direction is indicated by a repeated pattern of the cross or dot symbols and requires “painting ”an electrode that is then turned into a magnet using a side button.

With such a simple magnetic field of homogenous strength and known orientation, it is rather easy to add it to the kinematics equations we have been building up:

dt = 1E-9 # Conversion from seconds to nanoseconds
position_log = []
position = [initial_x_position, initial_y_position]
for time in range(1, 400_001): # Keep going for 400,000 steps
    electric_vector = get_electric_vector(electric_field_map, position)
    # ======= Added code =======
    magnetic_vector = get_magnetic_vector(electric_field_map, position, velocity)
    force = charge * (electric_vector + magnetic_vector)
    # ====== /Added code =======
    acceleration = force / mass # Roll the golfball down the hill
    velocity += acceleration * dt
    position += velocity * dt
    position_log.append([position, time]) # Log position at each time
    if ion_has_splatted(position, electrode_map, boundaries):
        print('SPLAT!')
        break # We've hit something, stop the simulation

It is really just adding a line of code that calls the “get_magnetic_vector” function — which in turn uses the position to find the magnetic field at a location and then calculates the cross product of the velocity and magnetic field vectors. We then simply add the two vectors and multiply (scale them) both by the charge.

Let’s try out a

In progress & unfinished

—−’