Simulating and testing solenoids

Cremona, September 2020.
Back to the home page.

Solenoids are very simple devices, and they are crucial in plasma experimentation. In this page, we discuss the magnetic field generated by a couple of solenoids, in particular in the so-called "magnetic bottle" configuration. First, we will introduce the topic, then we'll see how one can compute and plot the magnetic field generated by a set of coils (with a simple Octave/MATLAB script). Finally, we will build a couple of solenoids and measure the magnetic field by using an SS495B Hall sensor.
Index: QUICK LINKS:
Octave/MATLAB SCRIPT for computing the magnetic field generated by a set of solenoids;
Arduino SCRIPT for reading the SS495B Hall sensor.

A glimpse at the theory: solenoids, magnetic bottles and magnetic mirrors

So, everyone knows what a solenoid is about. Take some loops of wire, pass a current in them, and you'll create a magnetic field. By using a number of coils and playing with their orientation it is possible to optimize the topology of the magnetic field. A noteworthy example is the magnetic bottle configuration, that is obtained by placing two solenoids in a line (see figure below).

magnetic_bottle_schematic

This configuration is particularly interesting for doing experiments in plasma physics. Once the charged particles that compose a plasma meet a magnetic field, they get deflected and they tend to spiral around it. Therefore, magnetic fields can be used to confine plasmas (this is actually the working principle of magnetic confinement fusion). Electrons are much more easily trapped by the magnetic field than ions, due to their lower mass. Indeed, if you solve the Newton's equation for the dynamics of a charged particle in a magnetic field, you can find that the radius at which particles spiral around magnetic field lines (called the Larmor radius) is:
R = m v / (|q| B)
where "m" is the mass of the charge, "v" its velocity (in the direction perpendicular to the magnetic field "B") and |q| the absolute value of its electrical charge (1.602E-19 Coulombs for electrons or singly charged ions). Therefore, large mass implies a large Larmor radius. Large magnetic field implies smaller Larmor radius.
The take-home message here is: you need strong magnetic fields to confine heavier particles, and smaller fields are enough to confine electrons.

There is yet another interesting phenomenon that often arises in magnetic bottles, and it's called magnetic mirror.
Consider again the formula for the Larmor radius. If you imagine the magnetic field B to grow unbouded to infinity, then you would have a gyration radius that decreases towards zero. However, from basic physics, conservation of angular momentum tells us that the particle would start spiraling faster and faster as the radius goes to zero (try to google "ballerina angular momentum").
So, what happens is that inside the coils, the magnetic field lines are squeezed together, and the intensity of the magnetic field increases. If this increase is enough, electrons start spinning so fast that in place of exiting the bottle, they get reflected back into the bulk of the bottle! From there, they start spiraling towards the other end of the bottle, and when they reach the other coil, they get reflected back and so on.

So, lateral confinement of the plasma together with mirror effect at the extremes of the bottle make this device a simple yet effective plasma confinement device.
Keep in mind that in a real device however, the presence of a residual background neutral gas has the effect of scattering electrons around, and reducing the efficiency of the magnetic bottle.

Numerical computation of the magnetic field

So, solenoids are simple, right? But what about actually simulating the field produced by a number of them?
It is actually quite simple to compute numerically the magnetic field generated by some coils (see for example Griffiths, Introduction to Electrodynamics). The idea is:
  1. Divide the wire composing a coil into a number of pretty short straight line segments (in theory, with infinitesimal length - the more the better, but practically speaking 20 or 40 wire elements could be enough);
  2. Compute the field generated by each segment and sum them up (superposition of effects holds for this problem).
Consider a small segment "i" at position ri:
ri = (xi, yi, zi)
and assume this wire segment is percurred by a current Ii. The field generated by such wire segment at the position r=(x,y,z) reads:
Bi(ri) = μ0/(4 π) Ii Li × (r - ri)/|r - ri|3
And the field generated by all segments of one or more coils at a given position is simply the sum of all fields. You can find HERE AN OCTAVE/MATLAB SCRIPT that implements this method for a set of coils. Beware, I wrote this on the fly and there may be some bug; results seem reasonable, though.

Using this method, we can easily plot the field generated by a couple of coils in the magnetic bottle configuration (see figure-Left, below). It is clear that magnetic field lines generated by a coil enlarge greatly, and then re-compacify and enter the second coil.
A simple modification of this setup allows to obtain a pretty nice magnetic bottle, showing a uniform field. This is obtained by introducing additional larger coils, as to create a sort of long solenoid. The current and number of turns of such coils can be designed as to obtain the required magnetic field topology or can be optimized for the best uniformity (try to google "Helmholtz coil"). In the next figure-Center and -Right, you can see a simulation of such a configuration, obtained with the above script. I'm using 150 turns for the smaller side coils, with a radius of 14 mm, placed at 100 mm distance, and three additional coils of radius 30 mm, and some 20 turns. The current in the simulation is 1 Amp.

magnetic field line numerical

Building the coils and measuring the magnetic field

Ok, so let's start building the coils. I wanted to have some fun with the 3D printer, so I prepared some support for the coils in PLA (see image below). The material melts easily, so these coils are not really intended for prolonged operation at sustained currents, nor are very suitable for exposure to the plasma. However, they will be perfectly suitable for testing out the theory explained above and the Octave/MATLAB script.

The plastic support has an inner diameter of 24 mm and a 2 mm thickness. The width to accommodate the coil was set to 10 mm. Therefore, the coil itself has an inner diameter of 28 mm. I wound 150 turns of enameled copper wire (diameter 0.5 mm, 24 AWG). With such diameter, tables suggest a maximum current of 0.5 Amps. We can exceed it in a quick experiment, but not for a long time (also, if you are going to use this in a vacuum, remember withoug air there is no convection cooling!!!) The outer diameter of the coil ends up being 32 mm, and the width is 10 mm.

coils for the magnetic bottle

So, time to measure the magnetic field! I have glued the coils in place and put a piece of cardboard between them, together with a millimeter graph paper. This will help me to probe the field at reasonably accurate locations (a couple of millimeters accuracy is enough for this test).

setup measuring SS495B

The sensor that I used to probe the field is a Honeywell SS495B Hall effect sensor. It has a full scale of +-65 Gauss and is perfectly suitable for this experiment. If you look at the datasheet you'll see that the output is linear and this allows to map directly the output voltage of the sensor to the magnetic field.
One can read quickly the sensor by using Arduino. Here is the Arduino SCRIPT. The +5V and GND of the SS495B Hall sensor are connected to the Arduino +5V and GND pins. The output pin of the SS495B is connected to the analog pin A0 of Arduino. I'm using an Arduino nano for this test. Once you upload the script, you can read the values (in Gauss) through the serial monitor.
Keep reading to see the results.

Comparing Software and Measurements

So, time to compare the magnetic field predictions (obtained with the code above) to measurements from the SS495B. The current for the data that you will see was set to 765 mA in each of the two coils.

The numerical setup was modified a bit as to account for the finite dimension of each coil. Ideed, in place of only simulating one single loop for each physical coil, I divide the coil in four loops, two with the coil inner radius and the other two with the outer radius. The axial position of the loops is placed 1 cm apart, as to reproduce the length of the physical coils. Actually, it would probably be enough to use the average radius and average axial location, though. Anyway, here are the numerical simulation (left) and the experimental results (right)!

axial B verification

I'd say results are completely satisfactory, considering the experimantal error (mostly, placing the Hall sensor manually and forgetting about the scatter in the magnetic field readings).

Hope you enojoyed this page!
Stefano

Where to go now?
Check out the VACUUM DIARIES page,
...or you can GO BACK TO THE HOME PAGE, or to the EXPERIMENTATION PAGE.