Designing magnets with prescribed magnetic fields

We present a novel design method capable of finding the magnetization densities that generate prescribed magnetic fields. The method is based on the solution to a simple variational inequality and the resulting designs have simple piecewise-constant magnetization densities. By this method, we obtain new designs of magnets that generate commonly used magnetic fields: uniform magnetic fields, self-shielding fields, quadrupole fields and sextupole fields. Further, it is worth noting that this method is not limited to the presented examples, and in particular, three-dimensional designs can be constructed in a similar manner. In conclusion, this novel design method is anticipated to have broad applications where specific magnetic fields are important for the performance of the devices.


Introduction
Specific magnetic fields are required in many diffrent applications, ranging from humble refrigerator magnets, industrial applications such as ac motors [1,2] and magnetic recording media [3], through high-tech applications such as NMR/MRI devices [4,5], electron storage, high-speed maglev trains [6], wiggler magnets used in particle accelerators, free electron lasers [7,8] and to new areas of drug delivery [9] and image-guided therapy [5,10]. In these applications, a challenging design problem is how to arrange permanent magnets or currents to realize a certain feature of the magnetic field, e.g. a high-quality uniform field in a subdomain. The difficulty of this design problem arises from the non-local dependence of the magnetic field on the magnetization densities. For a given magnetization density, we can solve the Maxwell equation to find the magnetic field. But there is no efficient method for addressing the problem in the opposite direction: to find a magnetization density that gives rise to a prescribed field. In spite of the rich design experience accumulated, e.g. the Halbach arrays [11] and their variants [12], a systematic and rational method that can generate designs with any prescribed magnetic field will be critical for existing and emerging applications utilizing specific magnetic fields.
In this paper, we present a novel design method capable of finding the magnetization densities that generate specific magnetic fields. In this method, it is the magnetic field that is a priori given. From the given magnetic field, we first construct the 'obstacle' for a simple variational inequality. By solving the variational inequality, we obtain the magnetization density generating the desired magnetic field. Further, translations, orthonormal transformations and superpositions can be used to produce a variety of designs with interesting and useful magnetic fields. For example, we construct designs that generate the following four kinds of magnetic fields: (i) a magnetic field that is nearly uniform in a subdomain, (ii) a magnetic field that is uniform in a subdomain and vanishes outside the magnet, i.e. self-shielding, (iii) a precise quadrupole field and (iv) a precise sextupole field. The magnetization densities in these designs are piecewise constant, which is an advantage from the viewpoint of fabrication.
We remark that the presented design examples have many potential applications. The applications of (i) include compact permanent magnets for magnetic measurements and mobile NMR/MRI devices [14]; the applications of (ii) include supermagnetic shields and selfshielding magnetic devices [15]; and the applications of (iii) and (iv) include magnetic lenses for particle accelerators and free electron lasers [11,16]. Apart from the potential broad applications of these examples, we emphasize that the cutting edge of the presented method lies in the capability of generating designs for arbitrarily prescribed magnetic fields, and it will be useful in improving existing designs and producing new designs for numerous industrial and academic applications.

The design method
This novel design method follows from two observations on the Laplacian. We first note that for a constant vector e ∈ IR n and a scalar density ρ, the magnetic field induced by the magnetization density m = eρ and the Newtonian potential of the density ρ are related by 3 where the magnetostatic potential ξ is the solution to the Maxwell equation [17] ∇ · [−∇ξ + m] = 0, m = eρ, (2) and the Newtonian potential u of the source ρ is the solution to The relation (1) can be conveniently established by Fourier transformations or the integral formulations of (2)-(3) (see [18]). Secondly, we can a priori prescribe the second gradient of the Newtonian potential and then construct the source of the Newtonian potential by solving a variational inequality [19,20]. More precisely, if the desired second gradient of the potential coincides with ∇∇φ on some domain for a given function φ, then for a function f 0 and under some hypotheses that will be described in detail shortly, the minimizer u to the variational inequality 1 where χ V is the characteristic function of domain V and is called the coincident set (respectively non-coincident set). The variational inequality (4) is also called an obstacle problem or a free-boundary problem, and the given function φ is referred to as the obstacle. Roughly speaking, to visualize the minimizer u and the coincident set of the variational inequality (4), one may imagine pushing down an elastic membrane on the obstacle given by the graph of φ. Then the profile of the membrane is the graph of the minimizer u, and where the membrane contacts the obstacle defines the coincident set . Now recall that the Maxwell equation (2) determines the magnetic field −∇ξ induced by the magnetization density m = eρ. Comparing (3) with (5), by (1) and (6) we conclude that the magnetic field induced by the magnetization density m = eρ = −e φχ − e f χ C is exactly given by −∇ξ = ∇(e · ∇u) = ∇(e · ∇φ) on the coincident set .
Since the obstacle φ is a priori given for the variational inequality (4), by solving (4) we in effect determine the minimizer u, the coincident set and the magnetization density m that generates the desired magnetic field (7) on . As mentioned before, there are two hypotheses for the identity (7), which are listed below: 1. The obstacle φ is Lipshitz continuous (i.e. C 0,1 ), bounded from above, and max x∈IR n φ > 0.
2. There exists a constant C > 0, such that φ + 1 2 C|x| 2 is convex on IR n . The necessity of the above two hypotheses arises from the general theory of variational inequality and, in particular, the regularity theorem concerning the minimizer u, which enables us to conclude that the minimizer of (4) is indeed the solution to (3) in the usual sense. See the 4 monographs [19,20] and our recent works [21] for mathematical details. Further, the second hypothesis makes the construction of a qualified obstacle a little bit technical; examples of obstacles for various desired fields are given below.
In summary, to find a magnetization density generating a prescribed magnetic field, we first construct the obstacle φ such that ∇(e · ∇φ) agrees with the desired magnetic field in some domain. Then solving the variational inequality (4), we obtain the minimizer u, the coincident set , the non-coincident set C and, finally, the design of magnetization density m = eρ, ρ = − φχ − f χ C , which exactly gives rise to the desired magnetic field −∇ξ = ∇(e · ∇φ) on the coincident set . Further, the principle of linear superpositions and the invariance of the Laplacian under orthonormal transformations and translations can be used to manipulate the obtained results and produce a variety of useful designs.
Following the above procedure, we present four design examples of magnets with commonly used magnetic fields. The key step in computing these examples is to construct the obstacle 'φ' having the desired magnetic field '∇(e · ∇φ)' and not violating the required hypotheses. In the design examples, the obstacles are constructed by the following procedure. First, we conceive an obstacle of polynomial with ∇(e · ∇φ) having the desired feature of the magnetic field. For example, to obtain a uniform magnetic field, upon integrating we naturally choose obstacles φ to be quadratic functions. In general, to obtain a multipole field of degree 2N , we shall consider obstacles of polynomials of degree N + 1. However, a non-concave polynomial cannot satisfy the above hypotheses (i) and (ii) on the entire space IR n . Therefore, we need to truncate the polynomial in such a way that only one or a few small concave and nonnegative 'humps' are in effect (small compared with our computation domain). These humps are then extended continuously to the entire space by taking the maximum of the polynomial and zero on an appropriately chosen domain. A theorem proved in [21] guarantees that the obstacle so constructed satisfies the required hypotheses (i) and (ii). In this way we construct the obstacles for the following examples satisfying the required hypotheses and realizing the prescribed fields, whose verifications, although involving only basic calculus, are tedious and will not be presented here. The reader is invited to carry out the detailed calculations. Further, the design examples are verified by directly solving the Maxwell equation (2).
The numerical method used to solve both the variational inequality (4) and the Maxwell equation (2) is based on the finite element method. In the finite element model, the variational inequality (4) is converted into a quadratic programming problem. A computational advantage of the present method is that the mesh is fixed in the course of solving the variational inequality (4). For the examples below, we use a uniform mesh with around 10 5 nodal points in the unit circle x 2 1 + x 2 2 1 and the iterations are terminated when the relative difference between the computed energies of two consecutive iterations is less than 10 −10 . With these parameters, the iterations converge within a few minutes on a personal computer. See our recent work [21,22] and the textbook [23] for more details of the numerical method.
Finally, we remark that the design of magnets with prescribed fields is conventionally addressed by optimization methods, e.g. the method based on the continuum design sensitivity analysis [13], which have proved efficient for many applications. We point out that this method does not require such an optimization procedure. The design and the actual field are computed in one step by solving the variational inequality (4) as soon as the obstacle is appropriately constructed. Further, the method is particularly convenient for producing designs with complicated fields, e.g. a sextupole field. The magnetization density is equal to e = (1, 0) on 1 ∪ 2 . The lines are the contours of the magnetostatic potential ξ determined by the Maxwell equation (5). The normalized standard deviation of the magnetic field on D is 0.03, whereas the normalized standard deviation of the magnetic field on the same area is 0.07 for a standard design of rectangular magnets with the same aspect ratio (shown in the bottom right corner).

Design examples
The first example consists of two identical magnets generating uniform fields inside the magnets and a nearly uniform field between them. By (7), the magnetic field −∇ξ would be constant on if φ is quadratic on . We are therefore motivated to choose a piecewise quadratic obstacle such as Upon solving the variational inequality (4) on a unit ball with f = 0 and boundary condition u(x 1 , x 2 ) = 0 if r 2 = x 2 1 + x 2 2 = 1, we find the coincident set = 1 ∪ 2 in the square [−0.2, 0.2] 2 , as shown in figure 1. We observe that the boundaries between the coincident sets 1 and 2 are nearly flat and that the magnetic field is uniform inside 1 and 2 . By the continuity of the magnetic flux line, we infer that the magnetic field between 1 and 2 must be nearly uniform as well. Indeed, by directly solving the Maxwell equation (2) for magnetization density m = eχ , e = (1, 0), we obtain the magnetostatic potential ξ whose contours are shown in figure 1, where it can be seen that the magnetic field is uniform inside 1 ∪ 2 , and the magnetic field between the two magnets 1 and 2 is also nearly uniform in the box D. The uniformity of the magnetic field may be quantitatively measured by the normalized standard deviation of the magnetic field (the standard deviation divided by the mean). Numerically, we find that the normalized standard deviation of the magnetic fields on nodal points in D is 0.03 for the new design, whereas the normalized standard deviation of the magnetic field in the same box is 0.07 for the usual design using rectangular magnets with the same aspect ratio (shown in the bottom right corner of figure 1). The strength of both magnetic fields on D is around 1/6 of the magnetization density. We remark that a stronger and more uniform magnetic field can be obtained by tuning the obstacle; the trade-off is larger magnets, smaller area of uniformity or more complicated magnetization profiles.
The second example is a magnet generating a uniform magnetic field in the core and zero field outside the magnet (self-shielding). To achieve these field features, the obstacle is chosen as where φ 0 = max{φ 0 + 6, 0}, and Upon solving the variational inequality (4) for f = 40 and the obstacle (8), we find that the coincident set consists of four separate domains: = ∪ 4 i=1 i , as shown in figure 2. The non-coincident set, labeled C = IR 2 \ , is bounded, and, by (5), u = f = 40 on C . On the 7 coincident set i , by (6) and (9) By (7), note that, for any vector e = (e 1 , e 2 ) ∈ IR 2 , the magnetic field induced by the magnetization That is, the generated magnetic field is uniform in the core area 1 and vanishes on 4 . The stated magnetic field is verified by directly solving the Maxwell equation (2) for the magnetization density given by (10) with e = (0, 1), as shown in figure 2, where the lines are the contours of the magnetostatic potential ξ . A noteworthy peculiar property associated with the density ρ given by (10) is that all of its multipoles vanish since the solution to the Newtonian potential problem (3) is constant on the exterior domain 4 ( [17], page 145).
The third and fourth examples are magnets generating precise 2N -multipole fields in the bore. In two dimensions, a magnetic field in the neighborhood of the origin is a 2N -multipole field if it can be written as [11,16] where a, b ∈ IR are two constants and z = x 1 + ix 2 . From (11), note that the design (10) achieves an ideal dipole (i.e. uniform) field in 1 . To find a design with quadrupole field (i.e. a field with constant gradient), we choose the obstacle (Re( We then solve the variational inequality (4) Therefore, by (7), note that, for any vector e ∈ IR 2 , the magnetic field induced by the magnetization densities m = e φ(χ 1 − χ 2 ) satisfies on 1 ∩ 2 . Since the obstacle given by (13) (14), note that the magnetic field generated by the magnetization density m is a perfect quadrupole field on D for any vector e. This is verified by directly solving the Maxwell equation (2) for the magnetization density m = e(χ 1 − χ 2 ), e = (0, 1). The contours of the solution ξ are shown on the right of figure 3, which illustrates that the magnetic field in the bore area D = 1 ∩ 2 is a quadrupole field.
The fourth example is a sextupole magnet obtained by a superposition of the solution of the variation equality (4) for the following obstacle φ 1 and the negative of the solution of (4) for the obstacle φ 2 , where (r 2 = x 2 1 + x 2 2 ) and q(x 1 , x 2 ) = Re(z 4 ) = x 4 1 − 6x 2 1 x 2 2 + x 4 2 is a harmonic polynomial of degree four. The domain 1 (respectively 2 ) on the left of figure 4 is the coincident set of the variational inequality (4) for the obstacle φ 1 (respectively φ 2 ) given by (15). By a linear superposition, we see that, for any vector e ∈ IR 2 , the magnetic field induced by the magnetization densities m = e φ(χ 1 − χ 2 ) satisfies on D = 1 ∩ 2 . Since the obstacles given by (15) (14) one sees that the magnetic field generated by The domain 1 (respectively 2 ) is the coincident set of the variational inequality for the obstacle φ 1 (respectively φ 2 ) given by (15). The magnetization density is equal to e = (0, 1) on 1 \ 2 , −e on 2 \ 1 and zero otherwise. The lines are the contours of the magnetostatic potential ξ determined by the Maxwell equation (5)  the magnetization density m = e(χ 1 − χ 2 ) is a perfect sextupole field on D for any vector e. This is again verified by directly solving the Maxwell equation (2) for the magnetization density m = e(χ 1 − χ 2 ), e = (0, 1). The contours of the solution ξ are shown in the right part of figure 4, which illustrates that the magnetic field in the bore area D = 1 ∩ 2 is a sextupole field. Compared with the classical designs of Halbach arrays generating multipole fields [11], the new designs shown in figures 3 and 4 have the advantage of smaller magnets, larger bore areas, simpler magnetization profiles, and more precise multipole fields.

Conclusion
In conclusion, we present a novel design method capable of finding the magnetization densities for prescribed magnetic fields. We used this method to obtain designs of magnets that generate uniform magnetic fields, self-shielding uniform fields, quadrupole fields and sextupole fields. Apart from the potential applications of these examples, we stress that the applications of this method are diverse and not limited to constructing the presented examples, and, in particular, three-dimensional designs can be obtained by a similar procedure.