Strap-on magnets: a framework for rapid prototyping of magnets and beam lines

We describe a framework to assemble permanent-magnet cubes in 3D-printed frames to construct dipole, quadrupole, and solenoid magnets, whose field, in the absence of iron, can be calculated analytically in three spatial dimensions. Rotating closely spaced dipoles and quadrupoles in opposite directions allows us to adjust the integrated strength of a multipole. Contributions of unwanted harmonics are calculated and found to be moderate. We then combine multiple magnets to construct beam-line modules: chicane, triplet cell, and solenoid focusing system.


Introduction
Various types of magnets play important roles in many physics laboratories. Unfortunately, they are often expensive and require a long lead times to order. Here we propose a complementary method: we construct multipole magnets from standard-size permanent-magnet cubes, which are reasonably inexpensive and easy to obtain. Moreover, we suggest to hold them in 3D-printed frames or CNC-machined aluminum frames that can be produced in most small workshops. By constructing the frames in two halves they can be wrapped-around or strapped-on to circular pipes and easily fixed with non-magnetic screws, which makes retrofitting them to existing beam lines very simple. Figure 1 illustrates the frames for a dipole and a quadrupole constructed from eight cubes, each.
The orientation of the cubes in the frames follows the Halbach method [1], adapted to square [2] instead of trapezoidal magnet segments. In an M -magnet dipole, subsequent magnets along the azimuth are rotated by 2 × 360 o /M . The left-hand image in Figure 1 illustrates this for a dipole made of eight cubes. In the frame for an eight-magnet quadrupole, shown on the right-hand image in Figure 1  In order to calculate the magnetic fields from the cubes in three dimensions we use the closed-form expressions from [3], which allow us to prepare MATLAB scripts to determine the relevant field quantities and the multipole contents of the magnets in parameterized form. This proves very convenient to adapt the design to different sized cubes, different geometries, and other multipolarities.
The organization of this report is as follows: after we discuss the design of the frames with the OpenSCAD software, we characterize eight-magnet dipoles, quadrupoles, and solenoids made of 10 mm cubes. Then we combine two dipoles or quadrupoles to produce dipoles and quadrupoles whose field strength can be varied. In order to illustrate their use, we combine several magnets to beam-line modules.

Frames
We use OpenSCAD to prepare solid models of the frames to hold the permanentmagnet cubes, because this CAD software is easily scriptable, such that parameters for different-sized magnets of multipoles only require changing a few parameters. The frame can then be exported in a format that is compatible with 3D printers or CNC milling machines, which allows for short prototyping cycles.
The frame consists of a cylinder with an outer radius of r o = 28 mm, a 1 mm notch and a groove on its outer periphery to tell up from down, and 5 mm square holes to later attach handling rods. Furthermore there are rectangular solids to later hold screws-the horizontal circular holes shown in Figure 1. Moreover a circular hole with a radius of r i = 10 mm is removed from the center. The holes for the 10 mm cubes are then "stamped out" from this base frame. Each of the holes is born at the center, receives the little notch, and is rotated by an angle mφ, where m is the multipolarity of the magnets and φ is the azimuthal position of the cube in the frame. Then it is moved outwards by o = 18 mm along the x-axis before rotated once again by φ, which puts the hole in place. We point out that the notches on the holes are only for orientation, in the magnets we use that direction to indicate the "feather" (an not the "tip") of the arrows that indicate the easy axis of the magnets. Typically the square holes for the cubes are 0.1 mm larger than the magnet cubes themselves, which makes inserting the cubes easier. Inside the holes they are then easily fixated with super-glue.
Note that these frames have semi-circular holes with a diameter of 2r i = 20 mm in their center. Again, in order to account for finite tolerances of the frame and the pipe, normally the diameter needs to be increased a little, say by 0.1 mm. This makes it easy to wrap the frames around a circular pipe, align the holes for the screws, insert the screws and tighten them. This fixes the frame in place. Moving it along the pipe or rotating it only involves loosening the screws, moving the frame with the magnets, and tightening the screws again.
Let us now investigate the properties of the magnetic field generated by cubes in such frame-first out are dipoles.

Dipole
In [3] we calculated the field generated by a rectangular current sheet, which proved useful to describe permanent-magnet cubes that can be modeled by four rectangular sheets. In the top-left image in Figure 2 we see that each of the eight magnets consists of four blue sheets with the green line indicating the direction of the current, such that we can visualize the cube as a square solenoid that generates a magnetic field in its inside that is represented by the yellow arrow, which coincides with the direction of the easy axis of the magnet. In all our simulations we assume the remanent field of all cubes to be B r = 1.47 T. Inside the ring-shaped assembly with the eight cubes we see red arrows indicating the direction of the field in the mid-plane. The vertical field B y along the dotted black line is shown on the top-right plot, which shows a magnitude of about 0.24 T with a curved dependence in the x-direction, indicating some higher multipole components. The plot on the bottom right shows B y along a line in the zdirection. We observe that the fringe fields roll off slowly and extend far beyond the ±5 mm physical size of the magnets. Finally, we determine the multipoles of the assembly by integrating the field in the range |z| < 40 mm along lines perpendicular to the cyan circle which has a radius of 5 mm. We then Fouriertransform the component of the field that is tangential to this circle and show it on the upper panel on the bottom-left in Figure 2. This algorithm, which is explained in [3], gives us the magnitude and angle of the multipole coefficients of the assembly shown on the middle panel. We see that the integrated field strength is 5.72 Tmm and the lower panel indicates that the relative magnitude of other multipoles is around 6 × 10 −3 with the decapole contribution (m = 5) being the largest.
We conclude that the eight-cube dipole magnet reaches a peak field of 0.24 T, has an integrated field strength of 5.72 Tmm and the relative magnitude of un- wanted multipoles on a circle with a 5 mm radius is below 6 × 10 −3 .

Quadrupole
The field of the quadrupole assembly corresponding to frame from the right in Figure 1 is shown in Figure 3. The top-left image shows the eight cubes with the red arrows indicating the field in the mid-plane, the black dotted line and the cyan circle on which the multipoles are calculated. The top-right plot shows B y along the black dotted line and indicates a linearly rising field along the x-axis that is characteristic for a quadrupole. From the slope we determine a gradient in the mid-plane of 32.7 T/m. The gradient along the z-axis in the middle of the assembly is visible on the bottom-right plot. We observe that even the fringe fields of the quadrupole extend beyond its physical size of ±5 mm, but decays faster than those of a dipole. The image with the three panels on the bottom-left shows the tangential field component around the azimuth, which clearly displays two oscillations, indicating a quadrupolar field. This is also verified on the middle panel, which shows an integrated field 3.13 Tmm, which, when dividing by the 5 mm radius of the circle, results in an integrated gradient of 0.63 T. The lower panel shows that all other multipoles contribute less than 4 × 10 −3 in magnitude.

Solenoids
It turns out that the frame for the quadrupoles can also be used to construct both axial and radial solenoids; for an axial solenoid we only have to insert all cubes with their easy axis pointing along the z-axis. The top-left image in Figure 4 illustrates this. Note also the black dotted line and the cyan circle in the midplane as well as the solid magenta line to illustrate the z-axis. The top-right plot shows the z-component B z of the magnetic field in the midplane along the black dotted line visible on the top-left image. We see that is has a parabolic shape-the magnitude of the field closer to the permanent magnets is higher. We see that B z points opposite the direction of the easy axis of the cubes and reaches about −0.16 T in the center of the assembly. On the lower-right plot we also observe that B z , after being negative in the center of the assembly, becomes positive with a magnitude of 0.03 T around z = ±20 mm. On the three-panel image on the bottom-left we explore the impact of approximating the solenoid by eight cubes. The upper panel shows B z in the midplane of the assembly around the cyan circle which has a radius of 5 mm. We observe eight oscillations as we move around the azimuth φ, whose amplitude, however is rather small, less than 10 −4 time the magnitude of the average B z , which is 0.185 T at r = 5 mm. We conclude that, even though the field quality is limited, constructing solenoids is feasible within our framework.
Likewise we can construct a radial solenoid by rotating the cubes such that their easy axis either points inwards or outwards and construct one solenoid from two rings, as shown in Figure 5. The easy axes of the left eight-cube rings point inward and those of the right ring point outward. The magnetic field is illustrated by the red arrows and points from the right towards the left assembly along the negative z-axis in the intermediate region. The plot on the right-hand side in Figure 5 shows B z along the z-axis, where z = 0 corresponds half way between the two assemblies whose position is indicated by the blue dashed boxes. We see that the maximum value exceeds 0.2 T in the center and and reaches about 0.12 T just outside the two assemblies. The homogeneity of the field is comparable to that of the axial solenoid close to the cubes, and better in the intermediate region.

Adjustable dipole
Inspired by the observation that the fields of two very short magnets with opposite polarity almost cancel and the fact that the fringe fields of the dipole from Section 3 extend far beyond the physical length of the magnet, we place two dipole rings very close to each other (2 mm between the cubes) and then rotate one with respect to the other. The images on the left-hand side in the top and middle row of Figure 6 illustrate the geometry of these assemblies. On the top left the two eight-cube rings are aligned and on the one below the upper ring is rotated by ψ = 30 o counter-clockwise while the lower ring is rotated by 30 o clockwise.
The three-panel images towards the right of the respective geometries illustrate the integrated multipole content of the assemblies. In the upper panel on the top-right image we see that the tangential field component of the field integral shows a sinusoidal pattern that is responsible for dominant dipole component visible on the middle panel. The integrated strength of 11.4 Tmm of this assembly is twice that of the single magnet from Figure 2, because the fields superimpose linearly in ideal permanent-magnet assemblies. Furthermore, the lower panel shows that the dominant higher multipole is the decapole (m = 5) component whose contribution is 6 × 10 −3 smaller than the main component. The right-hand image in the middle row shows the integrated field of the assembly with the two rotated magnets. The tangential field shown on the upper panel is also sinusoidal, albeit with a reduced amplitude of 9.88 Tmm, which is also given in the legend of the middle panel with the Fourier-harmonics. Even in the rotated geometry the dipole contribution is dominant and the relative contributions of the unwanted harmonics, shown on the lower panel are below 6 × 10 −3 .
That the dominant effect of rotating two eight-cube magnets with opposite angles ψ only changes the integrated field from 11.4 to 9.88 Tmm but does not adversely affect the unwanted multipoles encourages us to explore the dependence of the field integral for different rotation angles ψ. The image on the left-hand side in the bottom row shows the vertical field B y along the z-axis on the lower panel for ψ = 0 o , 30 o , 60 o , and 90 o . We see that rotating the two eight-cube rings reduces the peak field in the center of the magnet from 0.37 T down to zero. The upper panel shows B y on the x-axis along the black dotted line and we see that the field is rather constant, only the amplitude is different for different values of ψ. The lower panel shows the fringe fields of B y along z for the four values of ψ.
Finally, we systematically vary ψ in steps of 10 o and show the integrated field component (or the amplitude of the Fourier harmonic for m = 1) as a function of ψ on the upper panel in the image on the right-hand side in the bottom row of Figure 6. We observe that the integrated field decreases in a smooth curve from 11.4 Tmm down to zero at ψ = 90 o , where the easy axes of cubes on top of each other have opposite polarities and cancel one another. On the lower panel we show the same data, but plot versus cos ψ instead. We find that now the integrated field strength shows a linear dependence on cos ψ, which indicates that the integrated field is given by twice the integrated field of one eight-cube ring times cos ψ. But this is just the projection of the maximum field of the rings onto the vertical axis. The field components along the vertical axis add, but along the horizontal axis they cancel. This will make tuning and setting up of such double-dipole assemblies rather straightforward.

Adjustable quadrupole
It is certainly no surprise that the same idea also works with quadrupoles.  Figure 7. We see that the gradient changes from 45.8 T/m for ψ = 0 o to zero at ψ = 45 o . On the right-hand image on the bottom row we plot the integrated gradient (dB y /dx)dz as a function of ψ in the upper panel. We see that it moves smoothly from 6.26 Tmm/5 mm= 1.25 T for ψ = 0 o to zero at ψ = 45 o . On the bottom panel we plot the same data versus cos 2ψ and find a linear dependence of the integrated gradient on cos 2ψ, which will make tuning and setting up double-quadrupole assemblies straightforward.

Some applications
Here we discuss three examples where the strap-on magnets might prove useful: a small chicane, a triplet cell, and a solenoid lens. Let's start with the chicane.

Chicane
Four-dipole chicanes are frequently used in accelerators to provide an energydependent path length for a beam, which helps to compress beams longitudinally [2,4]. The figure of merit for a bunch compressor is the so-called R 56 ≈ −2Lφ 2 , where L is the distance between the outer and the inner two dipoles,  and φ is the deflection angle of one dipole. This angle is given by the ratio of the integrated field B y dz of the dipole and the momentum of the beam, often expressed through its rigidity Bρ. For a beam with momentum 300 MeV/c, the rigidity is about 1 Tm, such that the variable two-magnet dipole from Section 6 with an integrated field of 11.4 Tmm deflects a 300 MeV beam by 11.4 mrad. With L = 0.4 m between the dipoles we therefore deflect the beam by about 5 mm and stay within the region shown on the bottom left in Figure 6. Furthermore, we find R 56 = −0.10 mm. Since we can adjust the magnetic field by rotating the two adjacent dipoles we can adjust the R 56 between the maximum value and zero. Figure 8 illustrates such a chicane with four variable dipoles wrapped around the grey beam pipe. One of the magnets is colored light blue and has a handle attached sticking out to the top right, while the other magnet is colored yellow and has a handle sticking out towards the top left. The handles are attached to the 5 mm square holes on the periphery of the frames that is also visible on Figure 1. Moreover, careful inspection shows that the two middle assemblies have opposite polarity (the central ones have a notch sticking out at the top, while the outer ones have a groove), such that they deflect a beam in opposite directions. Connecting all yellow handles with a rod, allows to change the rotation angle of all yellow magnets by the same amount, while a rod connecting the light blue handles rotates all light blue magnets by the same amount, which permits to change the excitation of all dipoles synchronously. Small variations in the excitation of different magnets can be compensated by placing small plates between the handles and the connecting rod. Note that for the illustration in Figure 8 the distance L was reduced to 0.2 m.

Triplet cell
In beam lines where long stretches of free space between magnets as well as round beams are required, often so-called triplets are used. They are combinations of three closely-spaced quadrupoles where the first and third quadrupole are excited equally and the center quadrupole has opposite polarity and twice the excitation. Figure 9 shows the magnet lattice with the three thin-lens quadrupoles and the horizontal beta function β x in the upper panel and the vertical beta function β y in the lower panel. The black lines show the beta functions for the thin lens model with a betatron phase advance per cell of 60 o in both planes. Note that the magnets are only located over a distance of 0.6 m such that there is almost 4 m free space available between magnets of adjacent cells.
Our quadrupole rings are particularly attractive to realize such triplets; we use a single ring for the two outer quadrupoles and two rings, rotated by 90 o for the double-strength center quadrupole with opposite polarity. The lower image in Figure 10 shows the two outer rings located near z = ±300 mm and the inner double-ring near z = 0 mm. The magenta line denotes the axis on which beam travels. We point out that adjusting the relative rotation angle ψ between the two center quadrupoles gives us some tunability. The upper image in Figure 10 shows the gradient along the beam axis. Note the opposite polarity of the outer We then empirically adjust ψ, calculate the gradient along the beam axis and automatically write a beam-line description, consisting of many 1 mm long quadrupoles, and calculate the beta function with software from [2]. With ψ = 7 o we found that the phase advances are close to the 60 o for the thin-lens lattice. The red lines in Figure 9 show β x and β y for the gradients produced by our quadrupole rings, which agree very well with those of the thin-lens model, shown in black.

Solenoid focusing
The radial solenoid from Section 5, whose geometry and field are shown in Figure 5, is suitable to focus round low energy beams. In the upper panel of Figure 11 we show the beam envelope of a 5 MeV electron beam with a normalized emittance of ε n = 10 −6 m rad passing through two such radial solenoids spaced 1.75 m apart. On the lower panel we recognize B z from the right-hand image in Figure 5; once near z = 0 and once near z = 1.75 m. The envelope is calculated from B z by numerically integrating the paraxial-ray equation [5]. The initial beam is parallel Figure 11: The longitudinal field B z created by two radial solenoids located at z = 0 and z = 1.75 m (bottom) and the beam envelope of a 5 MeV electron beam with a parallel beam with radius 1 mm entering from the left (top). We see that the first solenoid focuses the beam to a waist near z = 0.87 m and the second one makes the beam parallel again. and has a radius of 1 mm, but then develops a focus near z = 0.87 m, which is consistent with the focal length f calculated from 1/f = B 2 z dz/(2Bρ) 2 ≈ 0.87 m, where we have B 2 z dz = 1.3 × 10 −3 T 2 m and Bρ = 0.0169 Tm for the 5 MeV beam.
Making the solenoid stronger is a simple matter of repeating multiple copies of the radial solenoids, as shown in Figure 12, where six copies of the solenoid from Figure 5 follow with equal distance between consecutive rings. Note that the polarity alternates from one ring to the next. The upper panel shows the beam axis in magenta together with the twelve radial solenoids with alternating polarity, whereas the lower panel shows the longitudinal component B z on the beam axis. Note that the rings are placed every 30 mm and the amplitude of B z reaches ±0.2 T. The integrated focusing strength B 2 z dz is 8.8 × 10 −3 T 2 m for this configuration. This configuration would work for a 13 MeV electron beam (Bρ ≈ 0.044 Tm) where it leads to a comparable focal length close to 0.9 m.

Scaling
We point out that changing the value of the remanent magnetic field B r will just scale the field values reported in the remainder of this report accordingly. Figure 12: Assembling the six two-ring radial solenoids with alternating polarity, shown in the upper panel, creates the longitudinal field B z shown in the lower panel. It has a larger focusing strength than the two ring solenoid used in Figure 11 and can be used for higher energy beams.
Moreover, changing the linear dimensions, the size of cubes w, their radial position o, and the size of the frame, will keep all quantities, whose dimension is Tesla, unchanged. For example, the field in a dipole made of 5 mm cubes equals that of a dipole made of 10 mm cubes, but its fringe field does not extend as far as that of the bigger dipole. Therefore the integrated field of the smaller magnet is a factor two smaller. Likewise, the integrated gradient of a quadrupole made of 5 mm cubes is the same as that made of 10 mm cubes. In the smaller magnet the gradient is doubled, but the total length is halved.

Conclusions
Based on the analytic results for the magnetic fields from permanent magnets from [3] we explored the use of permanent-magnet cubes to create dipoles, quadrupoles, and solenoids. All examples are based on the frames for 10 mm cubes, shown in Figure 1, but are easily scalable to use cubes of a different size, to include more cubes, or produce other multipoles. We found that the magnets have reasonably good field qualities; the amplitudes of the harmonics at a radius of 5 mm in all cases are less than a fraction of a percent and often better.
An attractive feature is the possibility to retrofit these magnets to existing beam lines without having to open the vacuum system; the two magnet halves are simply strapped-on to the beam pipe. A second attractive feature is the possibility to combined two closely spaced rings to obtain dipoles and quadrupoles whose strength is continuously adjustable, while their field quality is comparable to that of a single ring.
Finally, we found these magnet rings suitable to construct beam-line modules for chicanes, a triplet cell, and solenoids focusing a low-energy beam.