# Message Boards

Answer
(Unmark)

GROUPS:

9

# Designing and building the world's largest (amateur) electromagnet

Posted 27 days ago

Designing and building the world’s largest (amateur) electromagnet by Robert Mendelsohn In this post, I’ll walk you through how I built what I believe to be the world’s largest amateur electromagnet with the Wolfram Language. I needed this large, strong electromagnet to continue studying highly magnetized (collisionless) plasmas. After examining the requirements of the plasma process, I determined that a highly homogenous magnetic field region with a strength of 160mT, diameter of about an inch and a length of about 2 feet would be sufficient. As you can imagine, an electromagnet requires a lot of wire, and wire is not cheap. In fact, the prices of copper have really climbed in the last few months. So the difficulty is not really how to build such a magnet, but how to achieve the needed parameters while being cost-effective. Fortunately, we have the Wolfram Language, and we can use real wire prices and component prices and let the Wolfram Language find the best option, including the power supply. In this post, we’ll briefly consider the theory behind electromagnets, as well as the practicalities of building one. Then we will let the Wolfram Language consider many thousands of different designs and tell us the best option. Finally, I’ll share some photos of the built system as well as some helpful tips for anyone thinking of building a large electromagnet.
The Theory of Electromagnets This is a very deep and complex topic, but we will stick to the bare minimum theory required to design an electromagnet. If you aren’t interested, feel free to scroll down for photos of big electromagnets. When an electron moves, it creates a magnetic field that rotates around that electron: If you have a lot of electrons moving in the same direction, as in a current-carrying wire, you amplify that effect: If you then loop that wire around, you can direct the magnetic field lines in an axial direction: And there’s basically your electromagnet. We’re not done yet - how do you create fields that are really uniform? In the next section we will consider several different coil configurations that improve the homogeneity of an electromagnet. Some resources to dive deeper: Great place for beginners: http://hyperphysics.phy-astr.gsu.edu/hbase/magnetic/magfie.html#c1 For advanced learning: https://press.princeton.edu/books/hardcover/9780691159027/modern-classical-physics
Multi-Coil Homogenous Electromagnets If a “multi-coil like above (commonly called a solenoid) is infinitely long, then the field within it is uniform. When a solenoid has a finite length, the field is stronger in the middle then at the end: One of the earliest solutions was to use two current carrying loops that were spaced a special distance apart. This was called a Helmholz coil (or Helmholz pair) and you can try out various configurations with this Manipulate: In[]:= Manipulate[Module[{coilresistance=(coilturns*Pi*Quantity[coilradius,"Inches"]*2.0)*WireResistance[wiretype]},Module[{maxratedcurrent=Min[{Quantity[maxi,"Amperes"],UnitConvert[Quantity[maxv,"Volts"]/coilresistance,"Amperes"]}],coilind=UnitConvert[(mu0*coilturns^2*Pi*(WireThickness[wiretype]/2)^2)/(WireThickness[wiretype]*coilturns),"Nanohenries"]},{{"Coil Resistance:",coilresistance},{"Maximum Coil-Limited Current:",UnitConvert[Quantity[maxv,"Volts"]/coilresistance,"Amperes"]},{"Maximum Coil-And-Switch-Limited Current:",maxratedcurrent},{"Driving Voltage:",UnitConvert[maxratedcurrent*coilresistance,"Volts"]//N},{"Center Field",2*coilturns*UnitConvert[(mu0/(4Pi))*((2Pi*Quantity[coilradius,"Inches"]^2*maxratedcurrent)/((Quantity[coildistance/2,"Inches"]^2+Quantity[coilradius,"Inches"]^2)^(3/2))),"Milliteslas"]},{"B-Field Pulse Width",UnitConvert[Quantity[20*0.00182293,"Milliteslas"*"Seconds"]/(2*coilturns*UnitConvert[(mu0/(4Pi))*((2Pi*Quantity[coilradius,"Inches"]^2*maxratedcurrent)/((Quantity[coildistance/2,"Inches"]^2+Quantity[coilradius,"Inches"]^2)^(3/2))),"Milliteslas"]),"Microseconds"]},{"85% Homogeneity Capacitance Required",UnitConvert[((-UnitConvert[Quantity[20*0.00182293,"Milliteslas"*"Seconds"]/(2*coilturns*UnitConvert[(mu0/(4Pi))*((2Pi*Quantity[coilradius,"Inches"]^2*maxratedcurrent)/((Quantity[coildistance/2,"Inches"]^2+Quantity[coilradius,"Inches"]^2)^(3/2))),"Milliteslas"]),"Microseconds"])/Log[0.85])/coilresistance,"Farads"]},{"Coil Inductance:",coilind},{"Coil Cost",2*2Pi*Quantity[coilradius,"Inches"]*coilturns*WireCost[wiretype]},{"95% Rise Time",UnitConvert[3*(coilind/coilresistance),"Microseconds"]}}//Grid//Panel]],{{maxi,2640,"Maximum Pulsed Current (A)"},0.5,4000},{{maxv,40,"Maximum Voltage (V)"},1,200},{{coilradius,5,"Coil Radius (in)"},1,24},{{coildistance,5,"Coil Distance (in)"},0.5,24},{{coilturns,1,"Coil Turns"},1,100,1},{{wiretype,"0","Wire Type (AWG)"},{"12","10","4","0","00","000","0000"}},SaveDefinitionsTrue] Out[]= What if we need higher levels of homogeneity? There is an improved version of the Helmholz coil, called a Maxwell coil, that uses 3 rather than 2 loops, and those loops are placed on the surface of a virtual sphere: Extending this, if you were to add more and more loops on the surface of a sphere, you would eventually get a perfectly homogenous field. The issue is that field has a very large and isotropic volume, and many applications including mine require a longer field with a small radius. The standard practice here is to use a solenoid with certain parts spaced out. This is optimized numerically using a program like Mathematica. After playing around with that kind of optimization I realized that it greatly increased the complexity of construction: I’d have to very precisely space wraps of wire, and doing do did not lead to a large improvement in performance. So I decided to use a traditional solenoid, and if I used enough turns and the working volume was sufficiently in the interior, there should be a very homogenous field. I spent a lot of time looking at optimized geometries for producing a homogenous field before realizing the “juice wasn’t worth the squeeze”. At least it resulted in a lot of nice-looking plots of the magnet homogeneity: In[]:= DensityPlot[(solenoid3/.{yy2,z2z})/0.282,{y2,-0.045,0.045},{z,0.-0.16,0.16},PlotRange{0,2},PlotLegendsAutomatic,AspectRatio3.55,ColorFunctionColorData["TemperatureMap"]] Out[]= I may write a later post about optimizing electromagnet geometries with the Wolfram Language. If anyone is interested in the code (and optimization methods, of which there are plenty) let me know in the comments. Here’s a graphic (code way too long and slow) looking at the homogeneity in the central region of two very optimized coils (full coil on left, then a zoomed in section for the region inside the box, two coils being compared): Out[]=
Manipulate Code In[]:= mu0=Quantity[1.256*10^-6,"Henries"/"Meters"]; In[]:= WireResistance=Map[#[[1]]Quantity[#[[2]],"Milliohms"/"Meters"]&,{"0000"0.1608,"000"0.2028,"00"0.2557,"0"0.3224,"4"0.8152,"10"3.277,"12"5.211}]//Association; In[]:= WireThickness=Map[#[[1]]Quantity[#[[2]],"Inches"]&,{"0000"0.46,"000"0.4096,"00"0.3648,"0"0.3249,"4"0.2043,"10"0.1019,"12"0.0808}]//Association; In[]:= WireCost=Map[#[[1]]Quantity[#[[2]],"USDollars"/"Feet"]&,{"0000"4.62,"000"2.87,"00"2.30,"0"1.88,"4"0.87,"10"0.38,"12"0.27}]//Association; In[]:= LoopInductance[diameter_,wirediameter_]:=UnitConvert[mu0*(diameter/2)*(Log[(8*diameter)/wirediameter]-2),"Microhenries"]
Coil Cost Optimization, Part 1 Here’s a Manipulate I built for optimizing a Maxwell coil; it gives a user a good feel for the performance tradeoffs: In[]:= Manipulate[Module[{resistance=TotalWireResistance[cooling,wratio,Quantity[smalld,"Inches"],Quantity[wirea,"Millimeters"^2]]},Module[{coilcur=Min[{UnitConvert[Quantity[variac/tratio,"Volts"]/TotalWireResistance[cooling,wratio,Quantity[smalld,"Inches"],Quantity[wirea,"Millimeters"^2]],"Amperes"],Quantity[(variac*20)/(variac/tratio),"Amperes"]}]},{Labeled[{{"Varic Voltage:",Quantity[variac,"Volts"]},{"Step-Down Transformer Ratio:",tratio},{"Input Power:",Quantity[variac*20,"Watts"]},{"Electrical Resistivity:",cooling},{"Wraps on Small Coil:",wratio},{"Minimum Bore Radius:",Quantity[smalld,"Inches"]}}//Grid,Style["Settings",FontSize24],Top]//Panel,Labeled[{{"Transformer Voltage:",Quantity[variac/tratio,"Volts"]},{"Max. Transformer Current:",Quantity[(variac*20)/(variac/tratio),"Amperes"]}}//Grid,Style["Transformer",FontSize24],Top]//Panel,Labeled[{{"Total Magnetic Field:",MagneticFieldAtCenter[coilcur,wratio,Quantity[smalld,"Inches"]]},{"Field Variation:",((Round[wratio*(2.0/Sqrt[7])]-(wratio*(2.0/Sqrt[7])))/(wratio*(2.0/Sqrt[7])))//PercentForm},{"Coil Resistance:",resistance},{"Coil Current:",coilcur},{"Coil Cost:",WireCost[wratio,Quantity[smalld,"Inches"],wirea]},{"Coil Wire Diameter:",UnitConvert[Sqrt[(wratio*Quantity[wirea,"Millimeters"^2]*(1/0.9069))/Pi],"Inches"]*2},{"Coil Power Dissipation:",UnitConvert[coilcur^2*resistance,"Watts"]}}//Grid,Style["Coils",FontSize24],Top]//Panel}//Row]],{{variac,120,"Variac Voltage:"},5,125},{{tratio,64.0,"Step-Down Transformer Ratio:"},1,200},{{cooling,Quantity[1.692*10^-8,"Ohms"*"Meters"],"Cooling Option:"},{Quantity[1.692*10^-8,"Ohms"*"Meters"]->"Room Temperature",Quantity[1.543*10^-8,"Ohms"*"Meters"]->"Ice/Ethanol Bath Cooling",Quantity[1.006*10^-8,"Ohms"*"Meters"]"Dry Ice/Ethanol",Quantity[1.956*10^-9,"Ohms"*"Meters"]->"Liquid Nitrogen"}},{{wratio,25,"Turns"},{4,12,16,25,37,41,86,127,295,717,1012,2512,3981,6310,9403}},{{smalld,2.25,"Mimimum Bore Radius:"},1,24},{{wirea,53.5,"Wire Area (mm^2)"},{107"0000AWG",85"000AWG",67.4"00AWG",53.5"0AWG",33.6"2AWG",5.26"10AWG",3.31"12AWG",0.0810"28AWG"}},SaveDefinitionsTrue] Out[]= After playing around with it, you can see one of the big issues is power dissipation. Highly resistive electromagnets will necessarily dissipate a lot of power, whereas using more conductor volume will decrease power dissipation and consumption but greatly increase the cost. If the major driver of cost is the conductor volume, what about using a different conductor? My first thought was making the electromagnet out of hollow copper pipe and running liquid nitrogen through the coil. When at liquid nitrogen temperatures, copper is about 10x more conductive, and liquid nitrogen is orders of magnitude cheaper than copper... I happen to have a 50 liter liquid nitrogen dewar, but ultimately I decided against this route; it would be much more convenient to have no consumables. Just flip a switch on, and the electromagnet goes on. The next idea: is copper the most cost-effective conductor of electricity?
Manipulate Code
Coil Conductor Optimization What about using aluminum as the conductor? In[]:=
Out[]= 0.6 Okay, so aluminum has 60% of copper’s electrical conductivity, what about its price? Looking at Home Depot’s website for 0AWG copper vs. aluminum wire, you’ll find that the copper wire is $2.34/ft, and the aluminum wire is $0.75/ft (as of the time of this writing). In[]:= 2.34/0.75 Out[]= 3.12 So aluminum is the clear winner; it’s almost half as conductive but is three times cheaper. A strange quirk of wire manufacture is that some gauges are cheaper. Since the driving factor for cost is conductor volume, what gauge aluminum wire is cheapest per unit conductor volume? In[]:= SortBy[{{"4AWG",UnitConvert[Quantity[0.35,"USDollars"/"Feet"]/Quantity[21.2,"Millimeters"^2],"USDollars"/("Inches"^3)],Quantity[21.2,"Millimeters"^2]},{"2AWG",UnitConvert[Quantity[155.38/500,"USDollars"/"Feet"]/Quantity[33.6,"Millimeters"^2],"USDollars"/("Inches"^3)],Quantity[33.6,"Millimeters"^2]},{"1/0AWG",UnitConvert[Quantity[0.75,"USDollars"/"Feet"]/Quantity[53.5,"Millimeters"^2],"USDollars"/("Inches"^3)],Quantity[53.5,"Millimeters"^2]},{"4/0AWG",UnitConvert[Quantity[1.20,"USDollars"/"Feet"]/Quantity[107,"Millimeters"^2],"USDollars"/("Inches"^3)],Quantity[107,"Millimeters"^2]},{"2/0AWG",UnitConvert[Quantity[0.77,"USDollars"/"Feet"]/Quantity[67.4,"Millimeters"^2],"USDollars"/("Inches"^3)],Quantity[67.4,"Millimeters"^2]},{"6AWG",UnitConvert[Quantity[0.29,"USDollars"/"Feet"]/Quantity[13.3,"Millimeters"^2],"USDollars"/("Inches"^3)],Quantity[13.3,"Millimeters"^2]}},#[[2]]&]//Grid Out[]=
So 2AWG aluminum wire is the cheapest, by a considerable amount (at this time). So that’s what we’ll use for the electromagnet. Here’s the delivered #2AWG aluminum wire:
Modelling Electromagnets in the Wolfram Language First, let’s define the actual equation for a magnetic field in three dimensions: In[]:= MagneticFieldAnalytic= currentmu0x 2 radius 2 x 2 y 2 z 4radius 2 x 2 y 2 2 x 2 y 2 z 2 radius+ 2 x 2 y 2 z 4radius 2 x 2 y 2 2 x 2 y 2 z 4radius 2 x 2 y 2 radius+ 2 x 2 y 2 z 2 radius+ 2 x 2 y 2 z 2 Abs[x] 2 Abs[y] currentmu0y 2 radius 2 x 2 y 2 z 4radius 2 x 2 y 2 2 x 2 y 2 z 2 radius+ 2 x 2 y 2 z 4radius 2 x 2 y 2 2 x 2 y 2 z 4radius 2 x 2 y 2 radius+ 2 x 2 y 2 z 2 radius+ 2 x 2 y 2 z 2 Abs[x] 2 Abs[y] currentmu0 2 radius 2 x 2 y 2 z 4radius 2 x 2 y 2 2 x 2 y 2 z 2 radius+ 2 x 2 y 2 z 4radius 2 x 2 y 2 2 x 2 y 2 z 4radius 2 x 2 y 2 radius+ 2 x 2 y 2 z 2 radius+ 2 x 2 y 2 z In[]:= VacuumPermeabilityUnitless=VacuumPermeability//Unitless; The equations come from “Some Useful Information for the Design of Air-Core Solenoids”, by D. Bruce Montgomery, and here’s an illustration of what the variables refer to: Here’s a function version: In[]:= MagneticFieldFromCurrentLoopCartesian[current_,radius_,x_,y_,z_]:=Modulebrho=UnitConvert ( 2 radius 2 x 2 y 2 z 4radius 2 x 2 y 2 radius+ 2 x 2 y 2 z 2 radius+ 2 x 2 y 2 z 4radius 2 x 2 y 2 radius+ 2 x 2 y 2 z 4radius 2 x 2 y 2 radius+ 2 x 2 y 2 z 2.513274124`*^-6 H/m 2 radius+ 2 x 2 y 2 z ( 2 radius 2 x 2 y 2 z 4radius 2 x 2 y 2 radius+ 2 x 2 y 2 z 2 radius+ 2 x 2 y 2 z 4radius 2 x 2 y 2 radius+ 2 x 2 y 2 z 4radius 2 x 2 y 2 radius+ 2 x 2 y 2 z 2.513274124`*^-6 H/m 2 radius+ 2 x 2 y 2 z Which we can immediately start using to visualize a magnetic field generated by a current loop, for instance: In[]:= VectorPlot3D[QuantityMagnitude[MagneticFieldFromCurrentLoopCartesian[Quantity[100,"Amperes"],Quantity[2,"Inches"],Quantity[x,"Inches"],Quantity[y,"Inches"],Quantity[z,"Inches"]]],{x,-1.9,1.9},{y,-1.9,1.9},{z,-1.9,1.9}] Out[]= Of course, since a solenoid is just a lot of current-carrying loops, we can use this function (with some kind of iteration) to model solenoids: In[]:= solenoid1=Map[(MagneticFieldAnalytic//Last)/.{current2200,mu0VacuumPermeabilityUnitless,x0,z(z2-#),radius0.1524}&,{0.0254`,0.0508`,0.07619999999999999`,0.1016`,0.127`,0.15239999999999998`,0.17779999999999999`,0.2032`,0.2286`,0.254`,0.2794`,0.30479999999999996`,0.3302`,0.35559999999999997`,0.381`,0.4064`,0.43179999999999996`,0.4572`,0.4826`,0.508`,0.5334`,0.5588`,0.5841999999999999`,0.6095999999999999`}]//Total; In[]:= DensityPlot[solenoid1 |