1 Introduction

The invention of rare-earth magnets (typical properties are summarized in Appendix A) in the 1970s to 80s changed the way magnets could be designed, because they have much higher coercivities (magnetic “hardness”) than formerly used AlNiCo or ferrite-permanent magnets. This fact allowed assembling magnetic flux sources similar to “toy blocks”, because the magnets hardly impair their magnetic properties. Their high remanence and their low permeability permitted to design very strong but compact permanent magnets using analytical approaches. One of the pioneers in this field was John C. Mallinson, who together with Klaus Halbach invented what nowadays is referred to as “Halbach arrays”. Their concept is based on a spatially oscillating magnetization in rare-earth magnets that produces enhanced magnetic flux only on one of their sides. Generalization then led to cylinders, spheres etc. with extremely strong and homogeneous magnetic fields of variable polarity, which naturally found many applications in various fields.

The properties and uses of Halbach magnets have already been reviewed several times [1,2,3]. However, there has been only little focus on practical aspects in magnet construction. It is the aim of this work to show, how the magnetic fields of Halbach multipoles can be estimated and which design criteria are critical, how they can be built and what further options can be implemented. All this is done with emphasis on applications in magnetic resonance. During the last two decades Halbach dipoles have developed from tinkered lab-instruments to full commercial productsFootnote 1 for benchtop NMR-relaxometry and spectroscopy. They work at magnetic fields from 1 to 3 T with homogeneities in the ppb-regime. Nevertheless, this field is still quite active in research, particular in developing portable MRI-scanners for the human head [4,5,6,7] for point-of-care application and to provide more affordable instrumentation for developing countries [8]. On the other hand, they have also been designed for EPR [9, 10], and DNP [10,11,12].

For magnetic resonance applications the interest in generating multipolar magnetic fields is typically limited to dipolar (for homogeneous magnetic fields) and quadrupolar (for homogeneous field gradients) arrangements. For completeness, however, higher polarities are touched at some points, but lengthy details are placed in appendices. The design of multipoles is interesting for particle traps in fundamental physics [13, 14], accelerators [15,16,17,18], motors [19], bearings [20], and linear machines [21]. Recently, they have also found use in techniques to guide magnetic nanoparticles remotely [2, 22] and in the emerging field of magnetic particle imaging, MPI [23].

This review is structured as follows: The concept of single-sided flux is introduced with Mallinson’s planar array (Sect. 2), which is then intuitively generalized to cylindrical Halbach multipoles (Sect. 3). After their principal field is introduced, this ideal case is step by step applied to more realistic structures. Each of these steps is accompanied by analytical expressions for the consequences on the magnetic flux inside them. The discussion of possible demagnetization concludes this section, which allows a basic design and choice of suitable materials. Section 4 deals with various strategies to homogenize the field in the plane of the magnet and along its axis using passive, mechanical and active shim strategies. Finally, Sect. 5 introduces concepts to open Halbach multipoles without force, combine them for variable field sources, achieve temperature compensation and give some practical hints for manually assembling such magnets.

2 Planar Halbach Arrays

In 1973 Mallinson [24] published the idea of what he considered a magnetic curiosity then, a planar permanent magnet with a magnetization pattern that results in single-sided flux. The conceptual idea is illustrated in Fig. 1, in which magnets with quadratic cross sections are arranged such that their flux cancels on one side and increases on the other. An analytical expression for this one-dimensional magnetization pattern along x is also given in the original publication

$${\varvec{M}}(x) = \;\left( {\begin{array}{*{20}l} {M_{x} } \\ {M_{y} } \\ {M_{z} } \\ \end{array} } \right) = M_{0} \;\left( {\begin{array}{*{20}c} {\sin (k^{\prime}{\kern 1pt} x)} \\ {\cos (k^{\prime}{\kern 1pt} x)} \\ 0 \\ \end{array} } \right)\;\;\;\;{\text{with}}\;\;\;\;k^{\prime}\; = \;\;\frac{2\pi }{\lambda },$$
(1)

where \(k^{\prime}\) is the wave number (spatial frequency) or \(\lambda\) the wavelength of the pattern (cf. Fig. 2a). The resulting field above the surface (y > 0) of such a structure of thickness d (and infinite length in z) is then

$${\varvec{B}}(x,y) = \left( {\begin{array}{*{20}l} {B_{x} } \\ {B_{y} } \\ \end{array} } \right)\; = \;B_{{\text{R}}} \;\left( {1 - e^{{ - k^{\prime}{\kern 1pt} d}} } \right)e^{{ - k^{\prime}{\kern 1pt} y}} \;\left( {\begin{array}{*{20}l} {\sin (k^{\prime}{\kern 1pt} x)} \\ {\cos (k^{\prime}{\kern 1pt} x)} \\ \end{array} } \right),$$
(2)

where BR is the remanence of the magnetic material (for typical values see Appendix A). The magnetic field components Bx and By are harmonic functions outside the magnet material. As a consequence, the sinusoidal variation in the horizontal direction goes together with an exponential decay in the vertical direction. Nowadays, many household magnets (see Fig. 2b) and magnetic foils have such magnetization patterns. This has the advantage that the holding force is roughly doubled per magnet weight and magnetic foils can be made thinner and more flexible. Other applications of such magnetization patterns are in the inductrack magnetic levitation [21] or wigglers and undulators to generate synchrotron radiation [25].

Fig. 1
figure 1

Schematic illustration of how magnets can be arranged to result in single-sided flux. a A single magnet with its magnetization direction downwards (indicated by the white arrow or the red and green color specifying north and south pole). The resulting dipolar magnetic field is represented by two field lines for the same field strength but different directions (blue = clockwise and gold = counterclockwise). b Several of the magnets from a arranged with a gap of the same size and alternating vertical magnetizations. c Same as b but now with alternating magnetization in horizontal direction. d Combination of the two arrangements in b and c gives a simplified planar Halbach array. It can clearly be seen how the flux cancels below the array and doubles on the other side (color figure online)

Fig. 2
figure 2

Linear, one-dimensional Halbach arrays: a a continuous version of the discrete scheme of Fig. 1d. The magnetic material (gray) has a magnetization (red arrows) pattern, which varies according to Eq. (1) along x and is constant along y over a thickness d, while it is infinite in the third dimension. This produces a recurring magnetic field (blue flux lines) on one side with wavelength \(\lambda\). b Photograph of iron filings on a household magnet with ca. 3\(\lambda\) illustrating the flux pattern of a. The magnetic flux on the opposite side is negligible. c If a \(\lambda\)/2 section of such a magnet is rotated around an axis at some distance parallel to its surface, a hollow cylinder with axial field is produced. Under certain conditions this field can be quite homogeneous but is limited to certain aspect ratios. Note that this is NOT a typical Halbach cylinder as discussed in Sect. 3, since its field direction points in axial direction (color figure online)

If half a wavelength of such a pattern is rotated parallel to an offset axis, permanent magnets with axial fields can be generated (cf. Fig. 2c). However, the end effects will be strong and have to be compensated e.g. by material thickness [26, 27]. Halbach then later generalized this concept to cylindrical [28] and spherical [29] arrangements to create multipolar magnetic fields. Due to his pioneering work in this area, these arrangements are usually all named after him. The pattern shown in Figs. 1 and 2 will typically be referred to as a 1D, linear or planar Halbach array.

3 Cylindrical Halbach Multipoles

If a planar Halbach array of length \(\lambda\) is now wrapped around a cylinder like illustrated in Fig. 3a, the variable x in Eq. (1) needs to be replaced by a position angle \(\theta=2\pi\) x/\(\lambda\) or x = \(\theta\) \(\lambda\)/(\(2\pi\)). However, the fact that the magnetization is now lying on a cylinder at an angle \(\theta\) must be taken into account by adding this angle to the magnetization position (cf. Fig. 3a). Hence, the magnetization of a cylindrical magnet with one wavelength, i.e. \({\varvec{M}}(\theta ) = M_{0} \;\left( {\sin 2\theta ,\;\cos 2\theta } \right)\), yields a homogeneous (dipolar) field. If two wavelengths of a planar Halbach array are bent to a cylinder (cf. Fig. 3b) the same arguments then result in \({\varvec{M}}(\theta ) = M_{0} \;\left( {\sin 3\theta ,\;\cos 3\theta } \right)\) and so forth.

Fig. 3
figure 3

Sketch on how the planar Halbach magnet is converted into a Halbach ring by rolling it up. a If one wavelength, \(\lambda\), is wrapped around an imaginary cylinder of radius \(\lambda/2\pi\), one gets a dipole with homogeneous field. b Wrapping \(2\lambda\) gives a quadrupole. See text for more details (color figure online)

If this concept is generalized in rolling planar Halbach arrays of length k\(\lambda\) up this way, multipolar fields of polarity \(p = 2\left| k \right|\) are produced (dipole for \(\left| k \right|\; = 1\), quadrupole for \(\left| k \right|\; = 2\), etc.). The basic design idea is illustrated in Fig. 4a, where the coordinate system has been changed in order to have \(\theta\) = 0 along the x-axis. It is still an idealized magnet with the shape of a hollow cylinder or ring of infinite length and continuously varying magnetization direction. The angle of the magnetization direction, \(\varphi\), depends on the position angle, \(\theta\), (cf. Fig. 4a) as

$$\varphi \; = \;\left( {k + 1} \right)\;\theta \;\;\;\;{\text{with}}\;\;\;k\; \in \;{\mathbb{Z}}.$$
(3)
Fig. 4
figure 4

Conceptual construction of cylindrical ideal Halbach multipoles: a the magnet (gray) consists of a hollow cylinder. Its magnetization M (red arrow) continuously changes with position Rc (defined on a central circle with radius \(\left| {{\varvec{R}}_{{\text{c}}} } \right| = R_{{\text{c}}} \; = \;(R_{{\text{o}}} + R_{{\text{i}}} )/2\)). If the position makes an angle \(\theta\) with the x-axis, M is rotated by an angle \(\varphi\). This angle \(\varphi\) is an integer multiple of \(\theta\) depending on the polarity and (inside/outside) location of the magnetic field of the final arrangement (Eq. (3)) as given by the index k. The polarity of such rings is then increased from left to right: b, e display dipolar \((\left| k \right| = 1)\), c, f quadrupolar \((\left| k \right| = 2)\), and d, g hexapolar fields \((\left| k \right| = 3)\). The magnetic field is completely inside the cylinder for k > 0, i.e. in b, c, d and zero outside. The opposite is the case for k < 0. For k = 0 the magnetization has radial orientation and no transverse field (only axial, z-direction) field is produced then (color figure online)

Figure 4b–g illustrate how the modulus of k determines the polarity, \(p = 2\left| k \right|\), and its sign the location of the produced magnetic field. For k > 0 the field is exclusively inside the ring (as shown in Fig. 3) and for k < 0 exclusively on its outside (that would be the case if in Fig. 3 the planar array is bent down and rolled up). The magnetization M [A/m] of such a hollow cylinder changes with respect to the position angle \(\theta\) as

$$\begin{aligned} {\varvec{M}}({\varvec{r}})\;\; & = \;\;\left| {\varvec{M}} \right|\exp \left( {i\,\varphi } \right) = \left| {\varvec{M}} \right|\exp \left( {i\left[ {k + 1} \right]\theta } \right)\;\; \\ & = \;\;\frac{{B_{{\text{R}}} }}{{\mu_{0} }}\exp \left( {i\left[ {k + 1} \right]\theta } \right)\;\; = \;\frac{{B_{{\text{R}}} }}{{\mu_{0} }}\left[ {\begin{array}{*{20}l} {\cos \left( {\left[ {k + 1} \right]\theta } \right)} \\ {\sin \left( {\left[ {k + 1} \right]\theta } \right)} \\ \end{array} } \right], \\ \end{aligned}$$
(4)
$${\text{with}}\;\;{\varvec{r}} = r\;\exp (i\theta )\;\; = \;r\left[ {\begin{array}{*{20}l} {\cos \theta } \\ {\sin \theta } \\ \end{array} } \right].$$

Here, the vectors in the magnet plane are represented in complex and cylinder coordinates, because both are used in the literature. It is also more practical to use the remanent flux density (or remanence) of a permanent magnet instead of its magnetization \(M\; = B_{{\text{R}}} /\mu_{0}\) with \(\mu_{0}\approx 4\pi\) · 10–7 kg m/(A s)2 , the permeability of vacuum.

For this work only magnetic structures are relevant which encase the magnetic flux density, B, they produce. This limits the discussion to k > 0 with the following general expression (the asterisk indicates the complex conjugate) (Eq. (21) in [28])

$${\varvec{B}}^{*} ({\varvec{r}})\; = \;B_{x} ({\varvec{r}}) - iB_{y} ({\varvec{r}}) = \left[ {\begin{array}{*{20}r} {B_{x} ({\varvec{r}})} \\ { - B_{y} ({\varvec{r}})} \\ \end{array} } \right]\;\; = f(k)\;\;{\varvec{r}}^{k - 1} \;\;\;\;\;\;{\text{with}}\;\;\;\;\;\;{\varvec{r}}\; = \;x\; + \;iy = \left[ {\begin{array}{*{20}l} x \\ y \\ \end{array} } \right].$$
(5)

This results in multipolar magnetic fields of amplitude f(k), which is given by

$$f(k)\;\; \equiv \;f^{{{\text{ideal}}}} (k) = \;\;\left\{ {\begin{array}{ll} {B_{\text{R}} \ln \frac{R_{\text{o}}}{R_{\text{i}}} } & {\text{for}\quad k\;=\;1} \\ {B_{\text{R}}\frac{k}{k-1}}\left({\frac{1}{R_{\text{i}}^{k-1}}\;-\;\frac{1}{R_{\text{o}}^{k-1}} }\right) & {\text{for}\quad k\;>\;1} \\ \end{array} } \right.,$$
(6)

where Ri and Ro are the inner and the outer radius of the hollow cylinder (cf. Fig. 4a), respectively. This amplitude f(k) is the \((k - 1)^{\text{th}}\) derivative of the generated flux, which is constant for each polarity. Hence, an ideal dipole (k = 1) generates a perfectly homogeneous magnetic field and a quadrupole (k = 2) perfectly homogeneous magnetic field gradients, which are orthogonal and have opposite signs.

The fact, that the flux of Halbach rings (k ≥ 1) is concentrated completely inside, makes them extremely efficient magnets. The efficiency of magnets is defined as the ratio of the energy stored in the accessible region to the maximally storable energy in the magnetic material [30, 31]. Halbach magnets reach a maximum efficiency for dipoles with Ro = 2.21 Ri.

These equations are only valid for ideal Halbach rings, which implies that they are continuously magnetized and infinitely long. Therefore, several steps have to be undertaken to convert these ideal Halbach multipoles to more realistic structures (cf. Fig. 5). This will be included in the Eq. (5) of the ideal system by modifying the amplitude of the generated magnetic flux by additional factors, f. Equation (5) describes the entire spatial flux distribution of the magnetic structure, which will be altered by discretizing and truncating it. Depending on the number of discrete parts, their shapes and distances, this will result in much more complicated field patterns, which cannot be generalized. The following simple equations will only be an estimate of the central field amplitude and say nothing about deviations at larger distances, i.e. about homogeneity. However, they are extremely useful at the planning stage of a magnet design and will give a good estimate about the achievable field/gradient strength.

Fig. 5
figure 5

Illustration of discretizing the ideal Halbach ring in a which has continuously changing magnetization and is infinitely long, into a real system. b First the magnet is discretized into N cylinder-segments with a single homogeneous magnetization direction (here N = 16). c The cylinder segments can be replaced by identical magnets (here squares) which are rotated to the appropriate magnetization direction. d Finally, the arrangement is truncated to finite length. e Shows another version of d using cylindrical magnets. In the top row a sketch of the geometry is displayed, while the central row shows FEM simulations for BR = 1.4 T, the length of the N magnets in d and e is twice the size. The bottom row is identical to the central one but using a logarithmic color scale to improve the visibility of the inner field distribution (color figure online)

3.1 Permeability

Permanent magnets are usually characterized by their B(H) dependence in the second quadrant, where the most prominent features are their remanent induction B(0) = BR, and the coercitivity field strength Hc, for which B(Hc) = 0. Typical values in the case of NdFeB permanent magnets are BR = 1.3 T and Hc = 1 MA/m. The relative permeability of the magnetic material \(\mu\)r is described as the slope of this line, i.e. \(\mu_{{\text{r}}} \; = \;{{\partial B(H)} \mathord{\left/ {\vphantom {{\partial B(H)} {\partial H}}} \right. \kern-0pt} {\partial H}}\).

Usually, the structural materials in the construction are diamagnetic or slightly paramagnetic (aluminum, copper) and can be described by the linear relationship \(B=\mu_{0}\,\mu_{r}\) H, with values of \(\mu\)r differing from unity by only about 10–5 (which can be also expressed as, \(\mu\)r = 1 + \(\chi\), with \(\chi\) the magnetic susceptibility). For this reason, these materials can be neglected compared to permanent magnets (“neodymium magnets” or Nd2Fe14B typically have \(\mu\)r = 1.05, and “samarium-cobalt magnets” SmCo5 or Sm2Co17 have \(\mu\)r = 1.03–1.11, cf. Appendix A). In order to estimate the effect of these not quite negligible permeability values we treat a Halbach ring like a continuous shell which shields the field of a larger ring surrounding it. Thus, an ideal Halbach ring can be treated like a cylindrical shield with an inner field reduced by a factor (Eq. (72) in [32])

$$f^{\mu } = \;\;\frac{{4\mu_{{\text{r}}} }}{{\left( {\mu_{{\text{r}}} + 1} \right)^{2} - \left( {\mu_{{\text{r}}} - 1} \right)^{2} \left( {\frac{{R_{{\text{i}}} }}{{R_{{\text{o}}} }}} \right)^{2} }}.$$
(7)

If we imagine the magnetized hollow cylinder as a superposition of very thin cylindrical shells, the field generated by the outermost shell is shielded by all the inner shells, while the innermost is only shielded by the sample volume. The solution for this scenario is given by (Eq. (31) in [33])

$$f^{\mu } = \;\frac{{\left( {1 - \Lambda } \right)\Lambda \;R_{{\text{o}}}^{2} }}{{R_{{\text{i}}}^{2} - \Lambda^{2} R_{{\text{o}}}^{{2}} }}\;\;\;\;\;\;{\text{with}}\;\;\;\;\;\Lambda \;\; \equiv \;\;\frac{{\mu_{{\text{r}}} + 1}}{{\mu_{{\text{r}}} - 1}}\;\;\;{\text{and}}\;\;\mu_{{\text{r}}} \ne 1.$$
(8)

Simulations for the relevant range of the permeability show that Eq. (8) can be approximated by (with an error smaller than 1% for \(<1.35\))

$$f^{\mu } = \;\;\frac{1}{{\sqrt {\mu_{{\text{r}}} } }}.$$
(9)

If more than one Halbach ring is used to construct a (nested) system, the shielding of the field originating from the outer rings by the permeability of the inner rings must also be taken into account (e.g. by using Eq. (7)).

3.2 Segmented Rings

Unlike for planar Halbach arrays there is no accurate technique available yet to magnetize a hollow cylinder of permanent magnet material with the desired continuous magnetization patterns as demanded by Eq. (4). A real Halbach ring is therefore always an approximation of the ideal Halbach multipole by constructing it from N segments each with a single magnetization direction (cf. Fig. 5b). This type of segmentation reduces the inner field by (Eq. (24b) in [28])

$$f^{{{\text{seg}}}} (k)\; = \;\frac{{\sin \left( {(k + 1)\;\pi /N} \right)}}{(k + 1)\;\pi /N}.$$
(10)

This correction becomes mainly important for small N and high k (e.g. for k = 1 and N = 8,  f seg= 0.6366, but for N = 16, seg = 0.9745). It is trivial that the level of discretization must be at least the number of poles (N ≥ 2 k), an equivalent of Nyquist’s theorem of “sampling” the theoretical magnetization wave that defines the multipole (cf. Figs. 2 and 3). At this limit the magnetization vectors of neighboring segments point in opposite radial directions.

3.3 Non-cylindrical Segments

Replacing the cylindrical segments of Fig. 5b by N identical magnets with a polygonal, round or trapezoidal footprint (as shown in Fig. 5c exemplarily by squares) can be advantageous in terms of costs but also for strategies to optimize homogeneity (see Sect. 4.1). This concept is also named Mandhalas [34] and the pros and cons of differently shaped sub-pieces are discussed in [35]. Obviously, the reduction of magnetic volume by this approach reduces the magnetic flux density additionally. If the footprint of the sub-pieces covers an area AM, the strength of the resulting magnet is reduced by the ratio to the area of the ideal Halbach (i.e. \(\pi \left( {R_{{\text{o}}}^{2} - R_{{\text{i}}}^{2} } \right)\)).

$$f^{{\text{M}}} = \;\;\frac{{N\;A_{{\text{M}}} }}{{\pi \left( {R_{{\text{o}}}^{2} \; - \;R_{{\text{i}}}^{2} } \right)}}.$$
(11)

The geometry (calculation of vertices and distances) of dense arrangements of polygonal pieces is described in Appendix B.

3.4 Finite Length

So far, the magnets were described only in two dimensions, corresponding to an infinite length in the third or z-dimension. Obviously, a real magnet must be truncated to a certain length, L. Zijlstra gives an analytical expression (Eq. (49) in [36]) for the reduction factor, \(f^{\text{L}}(k)\), of the field in the center of such a truncated Halbach dipole

$$\begin{gathered} f^{{\text{L}}} (1) = 1\;\; + \;\;\frac{1}{{\ln \left( {{{R_{{\text{o}}} } \mathord{\left/ {\vphantom {{R_{{\text{o}}} } {R_{{\text{i}}} }}} \right. \kern-0pt} {R_{{\text{i}}} }}} \right)}}\left( {\frac{L}{2I}\;\; - \;\;\frac{L}{2O}\;\; - \;\;\ln \frac{L + O}{{L + I}}} \right) \hfill \\ \;\;\;\;\;\;\;\;\;\;\;\;\;\;{\text{with}}\;\;I\; = \;\sqrt {L^{2} + 4R_{{\text{i}}}^{2} } \;\;\;\;{\text{and}}\;\;\;\;O\; = \;\sqrt {L^{2} + 4R_{{\text{o}}}^{2} }. \hfill \\ \end{gathered}$$
(12)

In order to generalize this for multipolar Halbach rings, they are constructed by a continuous distribution of dipoles on the circumference of a circle with radius Rc. Then the decay along the third dimension (for k = 1 see Eq. (8) in [37]) is given by

$$\begin{gathered} B_{xy} (z)\; = \;\frac{{R_{{\text{c}}}^{2k + 3} }}{{\left( {R_{{\text{c}}}^{2} + \left( {z - z_{0} } \right)^{2} } \right)^{k + 3/2} }}\;\;B_{xy} (0)\;\;\;\;\;{\text{for}}\;\;k\; \ge \;1\;\;\; \hfill \\ \;\;\;\;\;\;\;\;\;\;\;\;\;{\text{and}}\;{\text{for }}\;\;\;x,y\; = \;0\;\;\;\;\;\;{\text{with}}\;\;\;\;\;R_{{\text{c}}} \; = \;\frac{{R_{{\text{i}}} + R_{{\text{o}}} }}{2}. \hfill \\ \end{gathered}$$
(13)

In order to account for the length, L, of the magnet, Eq. (13) is integrated over z0 = ± L/2 and set in relation to the integral for the infinitely long ideal cylinder (z0 = ± ∞). The reduction factor, \(f^{{\text{L}}}\), is then found for z = 0. For the two relevant cases (i.e., k = 1 and k = 2) the following simple expressions can be found (for k = 1 see Eq. (A.5) in [23]) at z = 0.

$$f^{{\text{L}}} (k) = \;\;\;\frac{{\int\limits_{ - L/2}^{L/2} {B_{xy} (k,z = 0,z_{0} )\;dz_{0} } }}{{\int\limits_{ - \infty }^{\infty } {B_{xy} (k,z = 0,z_{0} )\;dz_{0} } }}\; = \;\left\{ {\begin{array}{ll} {\frac{L(L^{2} + 6R_{{\text{c}}}^{2})}{\left( {L^{2} + 4R_{{\text{c}}}^{2} }\right)^{3/2}}} & {\text{for}\;\;k\; = \;1} \\ {\frac{{L(L^{4} + 10L^{2} R_{{\text{c}}}^{2} + 30R_{{\text{c}}}^{4} )}}{{\left( {L^{2} + 4R_{{\text{c}}}^{2} } \right)^{5/2} }}} & {\text{for}\;\;k\; = \;2} \\ \end{array} }\right.. $$
(14)

The solutions for higher k values and a general equation are listed in Appendix C. Note that it is still the field components in the xy-plane whose decay in z-direction is described here. The expression in Eq. (14) for k = 1 can be found from Eq. (12) for a very thin ring by expressing Ro = Rc + δr and Ri = Rc−δr as the zeroth order expansion in δr.

In Sect. 4.3 it is shown how the decay ~ z−5 for k = 1 along the central axis can be avoided by using multiple rings with gaps in between them [37].

As already mentioned in the introduction, for most magnetic resonance experiments dipolar (k = + 1) and quadrupolar (k =  + 2) Halbach magnets are of interest only. Therefore, the effects discussed in the previous sections can be summarized as

Dipole: (k = 1)

$$\begin{aligned} {\varvec{B}}_{{\text{D}}} (x,y,0)\;\;\; & = \;\;\;\;\;\left( {\begin{array}{*{20}c} {B_{x} } \\ 0 \\ 0 \\ \end{array} } \right)\;\;\;\;\;\;\;\;{\text{with}}\;\;\;\;\;\;B_{x} \; = \;B_{{\text{R}}} \;\ln \frac{{R_{{\text{o}}} }}{{R{}_{{\text{i}}}}}\;f^{\mu } f^{{{\text{seg}}}} (1)\,f^{{\text{M}}} f^{{\text{L}}} (1) \\ B_{x} (x,y,0)\;\;\; & = \;\;\;\frac{{B_{{\text{R}}} }}{{\sqrt {\mu_{{\text{r}}} } }}\;\ln \frac{{R_{{\text{o}}} }}{{R{}_{{\text{i}}}}}\;\;\frac{{\sin {2\pi /N} }}{{ {2\pi /N} }}\frac{{N\;A_{{\text{M}}} }}{{\pi \left( {R_{{\text{o}}}^{2} - R_{{\text{i}}}^{2} } \right)}}\;\frac{{L(6R_{{\text{c}}}^{2} + L^{2} )}}{{\left( {4R_{{\text{c}}}^{2} + L^{2} } \right)^{3/2} }}. \\ \end{aligned}$$
(15)

Quadrupole: (k = 2)

$$\begin{aligned} {\varvec{B}}_{{\text{Q}}} (x,y,0)\;\;\; & = \;\;\;\;\;\left( {\begin{array}{*{20}c} {B_{x} } \\ { - B{}_{y}} \\ 0 \\ \end{array} } \right)\;\;\;\;\;\;\;{\text{with}}\;\;\;\;\;B_{x} \; = \;G_{{\text{Q}}} x\;\;\;\;{\text{and}}\;\;\;\;B_{y} \; = \;G_{{\text{Q}}} y \\ G_{{\text{Q}}} \;\;\; & = \;\;\;\frac{{2B_{{\text{R}}} }}{{\sqrt {\mu_{{\text{r}}} } }}\;\left( {\frac{1}{{R_{{\text{i}}} }} - \frac{1}{{R_{{\text{o}}} }}} \right)\;\;\frac{{\sin {(3\pi /N)} }}{{ {3\pi /N} }}\frac{{N\;A_{{\text{M}}} }}{{\pi \left( {R_{{\text{o}}}^{2} - R_{{\text{i}}}^{2} } \right)}}\;\frac{{L(L^{4} + 10L^{2} R_{{\text{c}}}^{2} + 30R_{{\text{c}}}^{4} )}}{{\left( {4R_{{\text{c}}}^{2} + L^{2} } \right)^{5/2} }}. \\ \end{aligned}$$
(16)

Equations (15) and (16) are very helpful for first estimations of field strengths of magnet geometries. A table in Appendix D compares the quality of the terms with the more accurate results from FEM simulations. The agreement is very good (discrepancies are less than a percent, except for the last two factors).

3.5 Demagnetizing Field

If a certain geometry is found that produces the desired magnetic flux density, B, inside the magnet system one has to check if the chosen material is magnetically hard enough. Inside the magnetic material the magnetic field, H, is not in the same direction as the magnetization, M. If in certain regions the component of H in the direction opposite to M exceeds the coercivity, Hc, the local magnetization will be quenched or demagnetized (for Halbach systems [31, 38]). Otherwise, permanent magnets could be built that generate virtually any field strength by adding more magnetic material. Hence, simulations that account for the full BH- or MH-curve are needed. Alternatively, calculations of the magnetic field inside the magnetic material can be inspected if the coercivity is exceeded (typical values and their dependence on temperature are listed in Appendix A). The intrinsic coercivity, Hc, is the magnetic field, which is needed to reduce the magnetization to zero, but the magnetization starts to deviate from its initial slope even earlier. However, in rare-earth magnets this transition is very steep. The magnetic field, H (see Fig. 6c), can be calculated from the flux density, B (see Fig. 6b), and the magnetization of the material, M (cf. Eq. (4) and Fig. 6a)

$${\varvec{H}} = \frac{{\varvec{B}}}{{\mu_{0} }}\;\; - \;\;{\varvec{M}}\;\;\;\;\;\;{\text{and}}\;\;\;\;\left| {\varvec{M}} \right| = \frac{{B_{{\text{R}}} }}{{\mu_{0} }}.$$
(17)
Fig. 6
figure 6

Illustration of the effect of demagnetization on a thick-walled Halbach dipole (ad) and a quadrupole (e) with identical dimensions (dashed white lines). a The magnetization as requested by Eq. (4), b shows the magnetic flux density produced by a. c Combining M and B according to Eq. (17) gives the magnetic field H. d Images of the magnitude H for the same dipole and e for a quadrupole. The material properties were chosen from the FeNdB-material N54 with BR = 1.47 T, Hc = 880 kA/m (black lines in d/e) in Appendix A, Ro/Ri = 3. A coordinate system is shown on the lower left (color figure online)

Figure 6 illustrates this effect on a thick-walled Halbach dipole and quadrupole. The internal magnetic field exceeds the coercivity of the chosen material in several regions (marked by black lines in Fig. 6d, e) at the outer and inner rim, which would be demagnetized and hence no longer contribute to the planned magnetization pattern, causing a lower field and homogeneity than predicted.

In [31] Bjørk et al. calculated conditions for these inner and outer regions with highest magnetic field. Demagnetization is avoided if

$$\begin{aligned} & {\text{inner}}\;{\text{rim:}}\;\;\;\;H_{{\text{c}}} \;\; > \;\;\frac{{B_{{\text{R}}} }}{{\mu_{0} }}\;\ln \frac{{R_{{\text{o}}} }}{{R_{{\text{i}}} }}\;\;\;{\text{for}}\;\;k = 1\;\;\;\;{\text{and}}\;\;\;H_{{\text{c}}} \;\; > \;\;\frac{k}{k - 1}\frac{{B_{{\text{R}}} }}{{\mu_{0} }}\;\;\;{\text{for}}\;\;k > 1 \\ & {\text{outer}}\;{\text{rim:}}\;\;\;H_{{\text{c}}} \;\; > \;\;\frac{{B_{{\text{R}}} }}{{\mu_{0} }}. \\ \end{aligned}$$
(18)

At the outer rim these regions are located at the poles (0° and 180° for a dipole) and at the inner rim between them (90° and 270° for a dipole).

However, it may be worth noting that for accelerators Halbach dipoles (Ri = 3 mm, Ro = 100 mm) have been constructed which reach almost 4 T (homogeneity 0.4%) [17] and recently even 5.16 T in a 2 mm gap [39]. The same group also developed extremely strong multipoles [40], e.g. quadrupoles with gradients of ca. 300 T/m [39]. This was achieved by using various materials with different Hc to avoid demagnetization.

Finally, one should be aware that Hc is also strongly temperature dependent (cf. Table 1).

4 Homogenizing

4.1 Homogenizing in the Magnet Plane

The magnetic fields of ideal Halbach multipoles are flawless (see Figs. 5a, 6d, e). The inhomogeneities introduced by discretization increase with each step in Fig. 5. At first glance, it is unclear how the concept of Mandhalas [34] (constructing the magnet from the same magnetic parts) might help here. To understand this strategy the main sources which cause field inhomogeneities have to be discussed. Typically, the production and magnetization process of the permanent magnets is outsourced to companies that have specialized in this field. Usually, the quality of these building blocks of the Halbach system is most crucial for the final result, and unfortunately the underlying steps are out of direct control. Figure 7b shows the variation of the field produced at a fixed distance from the surface of some 600 permanent magnets. The variation can easily reach percent ranges, but clearly the numbering provided by the producer reveals two batches in the production by the change in variance. Such variations can have their origin in the production of the magnets and/or the magnetization process.

Fig. 7
figure 7

a dipole approximation for characterizing magnets by their far field: double log-plot of the magnetic field, B, (red line) produced outside a cube-shaped magnet in magnetization direction, x. The blue dashed line shows the expected slope for a dipole (x−3). The gray dashed line indicates the size of the magnet. The purple shaded region suggests a region for measurements of “dipole-like” behavior. The B-field of the cubic magnet was simulated for BR = 1.4 T, hence corresponds to a magnetic moment m = BRV/µ0 = 17.4 Am2. Note that an ideal spherical magnet of the same volume would generate a dipolar field everywhere beyond its surface. b Result of such measurements: The individual deviation, ΔB, of 620 FeNdB-magnets from the mean. The numbering was provided by the producer. The shaded regions identify two different batches by significantly different variances of unknown origin (color figure online)

Another problem arises from the accuracy of the magnetization direction. The cylindrical segments in Fig. 5b for instance need correct individual magnetization angles. It is easy to imagine that this will add another error in the percent range. An easy strategy to circumvent these problems is to order magnets of identical shape and measure their far field. Figure 7a shows how the magnetic field drops off the surface of a cube-shaped magnet in this example. At a distance roughly equal the size of the magnet, a dipolar regime is entered (dashed blue line), which means that shape and local magnetization variations inside the magnet average out and the magnet can be regarded as a spherical magnet of the same volume, or equivalently a point source described as a magnetic dipole. Note that this distance should be not too far away to ensure sufficient accuracy in measuring its stray field. In Appendix E a simple method is described that uses this dipole approach to minimize the error in the center of the arrangement [37]. This strategy typically improves the homogeneity by an order of magnitude. However, this strongly depends on the number of magnets to select from, their deviation and the chosen geometry. More evolved methods optimize larger field maps for different arrangements [6, 41, 42].

Using magnets with a polygonal footprint further reduces the error in misalignments of the magnetization direction because it coincides with a certain edge. However, edges in the magnet shape introduce higher polarities in the resulting field (cf. Fig. 5c, d), which can be reduced by using round magnets (spheres, bullet shaped, cylinders, cf. Fig. 5e). If one uses such round magnets, their correct orientation can be achieved by using a magnetic alignment procedure [35] giving excellent homogeneities. All the described concepts assume that one really uses only the innermost section of the magnet (somewhat like the far field). If the sample space is close to the size of the opening (2Ri) of the ring, the spatial inhomogeneity of the individual magnets can no longer be neglected (cf. Fig. 10a).

For dipoles Tewari et al. showed that the rotation angle \(\varphi\)i = (k + 1) \(\theta\)i (see Fig. 4a) of each magnet is not necessarily the best choice for optimal homogeneity [43]. From the same group there is also the suggestion to deviate from a circular arrangement and that arranging magnets on ellipses instead also improves overall homogeneity [44].

4.2 Axial Homogenization

The truncation of an ideal Halbach multipole to a certain length or height introduces an additional inhomogeneity of Bxy along the z-axis. This decay can be approximated by Eq. (14), and as already stated in Sect. 3.4 it is advantageous to separate the Halbach cylinders into differently spaced rings. This approach is very much like in Helmholtz coils or solenoids with denser pitch towards their ends to improve the homogeneity along their axis [37]. To homogenize the central field, \(B_{xy}^{\Sigma }\), produced by two dipole rings placed at distances ± s1, the second derivative has to become zero at the center z = 0.

$$B_{xy}^{\Sigma } (0,0,z)\; = \;R_{{\text{c}}}^{5} B_{xy} (0,0,0)\left[ {\frac{1}{{\left( {R_{{\text{c}}}^{2} + \left( {z + s_{1} } \right)^{2} } \right)^{5/2} }}\;\; + \;\;\frac{1}{{\left( {R_{{\text{c}}}^{2} + \left( {z - s_{1} } \right)^{2} } \right)^{5/2} }}\;} \right],$$
(19)

with the second derivative

$$\frac{\partial^2 B_{xy}^{\Sigma} (z)}{{\partial z^{2} }}\; = \;5R_{{\text{c}}}^{5} B_{xy} (0,0,0)\left[ {\frac{{6\left( {z + s_{1} } \right)^{2} - R_{{\text{c}}}^{2} }}{{\left( {R_{{\text{c}}}^{2} + \left( {z + s_{1} } \right)^{2} } \right)^{9/2} }}\;\; + \;\;\frac{{6\left( {z - s_{1} } \right)^{2} - R_{{\text{c}}}^{2} }}{{\left( {R_{{\text{c}}}^{2} + \left( {z - s_{1} } \right)^{2} } \right)^{9/2} }}} \right].$$
(20)

In the center (z = 0) this has to become zero for a flat maximum (cf. Fig. 8a)

$$\frac{\partial^2 B_{xy}^{\Sigma} (0)}{{\partial z^{2} }}\; = \;0\;\;\;\; \Rightarrow \;\;\;s_{1} \; = \; \pm \frac{{R_{{\text{c}}} }}{\sqrt 6 } \qquad \text{and}\qquad B_{xy}^{\Sigma}(0,0,0)\;=\;\frac{72}{49}{\sqrt{\frac{6}{7}}}\;B_{xy}(0,0,0) .$$
(21)
Fig. 8
figure 8

Illustration of stacking Halbach multipoles with optimized gaps along their axis. Dark blue: resulting combined magnetic field, \(B_{xy}^{\Sigma }\), of the arrangement. Cyan: magnetic field of each individual Halbach cylinder (gray rectangle). a Two dipole cylinders at the distance calculated in Eq. (21), b two antiparallel dipoles generating a constant gradient of Bxy along z. c 8 stacked rings (see Appendix E). For all: k = 1, Rc = 12.5 mm, L = 3 mm, BR = 1.4 T. d Instead of identical rings stacked at different distances one can also use rings of various L and different thickness (here Ri was kept constant and Ro adapted to homogenize the field) (color figure online)

Generally, this is fulfilled at \(s_{1} \; = \; \pm R_{{\text{c}}} /\sqrt {2k + 4} \;\;{\text{for}}\;\;k \ge 1\). Appendix F lists the optimal distances for up to 12 rings (cf. Fig. 8c) for k = 1—6.

Figure 8b shows a differential arrangement, which generates a constant gradient \(\partial B_{xy}^{\Delta} /\partial z\). For this the optimal distance is \(s_{1} \; = \; \pm R_{{\text{c}}} /\sqrt 2\) with a gradient of \(\frac{{\partial B_{xy}^{\Delta} }}{\partial z}\; = \;\frac{80}{{81}}\sqrt 3 \;\frac{{B_{xy}(0,0,0) }}{{R_{{\text{c}}} }}\) in the center.

Again, these distances are first starting points, which need refinement via simulations. The very homogeneous regions in Fig. 8a, c are, of course, limited to the axis. Farther away from the axis the gaps between the magnets will cause inhomogeneities increasing with radial distance (cf. Fig. 10b). Strategies to remove them will be discussed in the next section. An alternative to stacks of rings of the same length is to change the thickness of the individual rings [45] and remove/reduce the gaps in between them as shown in Fig. 8d. Nevertheless, the use of only one magnet size has to be sacrificed for this approach and the presented solutions in Appendix E are no longer valid because they were obtained for infinitesimal thin rings. However, the density distribution presented by them can be used as a starting point to optimize the ring thicknesses.

Another possibility to build Halbach arrays without end effects by truncation would be to use Halbach spheres [18]. This is more of a theoretical concept because the authors are not aware that anyone ever built such a demanding structure for magnetic resonance (in [46] a sphere has been roughly approximated). Figure 9a shows the principle layout of such a Halbach sphere generated by rotating the cross section of an ideal Halbach dipole around the axis of its poles [29, 47]. A Halbach sphere has 4/3 more internal flux than an ideal ring with the same shell thickness and additionally a strong stray field. At first glance it looks a bit foolish to wall an apparatus inside a hollow sphere, but there are certain angles where such spheres can be opened without force [1] to provide access to the inner volume (see also Sect. 5.1). This inner space can be extended by using Halbach hemispheres as endcaps of a Halbach ring (cf. Fig. 9b) [48]. The field strength of such a hemisphere is then half of that of the complete sphere, and the Halbach cylinder outer radius has to be adopted to match this by being \(R_{{\text{o}}}^{2/3} R_{{\text{i}}}^{1/3}\) of the hemispheres. Again, no one, to our knowledge, has ever built such a device.

Fig. 9
figure 9

a Halbach dipole sphere, b using Halbach hemispheres as endcaps of a Halbach cylinder. In both drawings a quarter is cut away. Red arrows sketch the magnetization direction and the big yellow arrow the resulting flux (color figure online)

4.3 Passive Shimming by Iron Pole Plates

Figure 10a shows the magnetic flux density measured close to the pole surface of eight magnets. Quite strikingly each of them shows a pronounced flux distribution over its surface. Although the methods described in Sect. 4.1 can compensate their overall strength at a distance, there are situations where one has to use as much of the inner volume of a magnet as possible. In [4] it was found that flat sheets of iron almost completely cancel this inhomogeneity out (cf. Fig. 10b, c). The iron plates (or other soft magnetic material with high permeability) act like a pole piece, and by bringing the various spatial magnetic field contributions to a similar magnetic potential smooths out the biggest inhomogeneities. Below about 1.5 T saturation effects are not expected in iron or low-carbon steels, but as it clearly can be seen in Fig. 10c, they also reduce the magnetic flux.

Fig. 10
figure 10

a Normal field component at a distance of ca. 1 mm over the pole surface of 8 FeNdB-magnets stacked together using aluminum spacers between them. They are all from the same batch of magnets and should be identical. b Magnetic flux measured over a similar arrangement but now being part of a Halbach magnet [4] and measured at a different distance, which explains the different field strengths. c Same as b but all magnet poles covered with 1 mm thick iron sheets. Please note the different color scales in a and b/c (color figure online)

Recently, it has been reported that magnetic filaments for 3D-printers can be used to easily create arbitrarily shaped pole pieces or be already embedded in the support for magnets [49], however their low permeability (\(\mu\)r < 10) may become a problem.

4.4 Mechanical Shimming

Due to the variation in the magnetic materials, production and positioning tolerances it is hard to imagine building Halbach magnets with homogeneities much less than 100 ppm deviation of the magnetic flux over a larger part of the inner accessible volume, which is a comparable value for superconducting magnets before cryo-shimming. Typically, the last mechanical correction steps have to take spatial field information into account to find the optimal configuration for an individual magnet (a step which may already require the incorporation of ambient field distortions).

For permanent magnets this correction can be done by individually position either additional magnets or materials of high permeability [50]. Such a semi-permanent correction of course is best planned from detailed spatially resolved field maps. The corrective material can be inserted at suitable positions and/or mechanically moved (e.g. by set screws) for fine adjustments [51,52,53] or being rotated [54,55,56]. One major aspect is that not too much of the available sample space should be sacrificed by this additional equipment. A very elegant and space preserving concept is shown in Fig. 11 [57]. The very small magnet produces a field of 0.7 T and allows simple spectroscopy shown on the 1H-spectrum of toluene acquired in a 5 mm standard NMR tube (inset Fig. 11a). The resolution measured for a water sample was 4.5 Hz or 0.15 ppm at half height. This homogeneity was achieved first by shifting the rectangular sections to suitable positions and finally using additional coils for finer field adjustment of the first-order terms only. In the meantime this idea has been further developed and successfully commercialized [58].

Fig. 11
figure 11

Halbach dipole built from fixed trapezoidal and movable rectangular units: a Picture of the 0.7 T magnet next to a standard 5 mm tube for the liquid sample. Inserted is the 1H-NMR spectrum of toluene of the homogenized system. b Demonstration how the movement of the rectangular magnets can generate magnetic fields of third order (top) and fourth order (bottom). Below each magnet arrangement is the resulting field map to illustrate the effect. Reproduced from [57] with permission from the Royal Society of Chemistry (color figure online)

Another idea for simple, adjustable and stationary shims is presented in Fig. 12. It makes use of a pair of permanent magnets both with the shape of a hollow cylinder and transverse magnetization, which are aligned coaxially (cf. Fig. 12 top row). They will have the same stray field if both have the same height and their geometry and remanences are chosen such that they both have the same product of remanence times their area, i.e.

$$B_{{\text{R}}}^{{\text{A}}} \;\pi \;\left( {R_{{{\text{Ao}}}}^{2} \; - \;R_{{{\text{Ai}}}}^{2} } \right)\; = \;B_{{\text{R}}}^{{\text{B}}} \;\pi \;\left( {R_{{{\text{Bo}}}}^{2} \; - \;R_{{{\text{Bi}}}}^{2} } \right),$$
(22)

where A/B indicates the inner or outer cylinder (RAo/i = outer/inner radius of cylinder A). Their fields add up when both point in the same direction. Their vector sum is minimal (vanishes if Eq. (22) is fulfilled) for antiparallel orientation as illustrated in Fig. 12. If a set of K such units is mounted on a circle with radius Rs and their geometry is chosen small compared to the rest of the magnet system, their influence in the center is approximately that of a dipole and the additional flux at a point p = [xy] close to the center is given by

$$\begin{aligned} & {\varvec{B}}({\varvec{r}})\; = \;\;\sum\limits_{j = 1}^{K} {\frac{{\mu_{0} }}{4\pi }\;\frac{{3{\varvec{r}}_{j} \;({\varvec{m}}_{j} \; \cdot \;{\varvec{r}}_{j} )\; - {\varvec{m}}_{j} r_{j}^{2} }}{{r_{j}^{5} }}} \;\;\;\;\;\;\;{\text{with}}\;\;\;\;\;{\varvec{r}}_{j} = R_{{\text{s}}} \;\left( {\begin{array}{*{20}l} {\cos \theta_{j} } \\ {\sin \theta_{j} } \\ \end{array} } \right)\;\; - \;\;{\varvec{p}} \\ & \quad {\text{and}}\;\;\;\;{\varvec{m}}_{j} \; = \;m_{j}^{{\text{A}}} \left( {\begin{array}{*{20}l} {\cos \varphi_{j}^{{\text{A}}} } \\ {\sin \varphi_{j}^{{\text{A}}} } \\ \end{array} } \right)\; + \;m_{j}^{{\text{B}}} \left( {\begin{array}{*{20}l} {\cos \varphi_{j}^{{\text{B}}} } \\ {\sin \varphi_{j}^{{\text{B}}} } \\ \end{array} } \right)\;\;\;\; \\ & \quad {\text{or}}\;\;\;{\varvec{m}}_{j} = \;\;\;\frac{{B_{{\text{R}}} \;V}}{{\mu_{0} }}\;\left( {\begin{array}{*{20}l} {\cos \varphi_{j}^{{\text{A}}} + \cos \varphi_{j}^{{\text{B}}} } \\ {\sin \varphi_{j}^{{\text{A}}} + \sin \varphi_{j}^{{\text{B}}} } \\ \end{array} } \right)\;\;{\text{for}}\;\;m_{j}^{{\text{A}}} \; = \;m_{j}^{{\text{B}}} , \\ \end{aligned}$$
(23)

where \(\theta\)j is the angle at which the jth shim cylinder-pair is positioned, whose outer and inner cylinders are rotated by angles \(\varphi_{j}^{{\text{A}}}\) and \(\varphi_{j}^{{\text{B}}}\). The last equation is given if both cylinders with total volume V are made from the same material with remanence BR.

Fig. 12
figure 12

Shimming using a pair of hollow cylinders with transverse magnetization (blue and purple arrows in top row). If their size and strength are matched according to Eq. (22) and if both can be rotated around a common concentric axis they produce the flux depicted in the lower row. To illustrate this principle, the inner cylinder stays at the same position and the outer one is rotated from a parallel, b perpendicular to c antiparallel, where the combined field of both vanishes. The field maps in the lower row show the magnitude of the field (colors limited to the lower half of the full range) with an overlaid vector plot, nicely showing the dipole characteristics of the magnetic field (color figure online)

The correction field can then rather simply be calculated by the superposition of K individual dipoles of individual strength and angle to homogenize the original magnetic field. From that the angles of each cylinder pair are determined using Eq. (23). This approach has the advantage that it only uses components on a fixed axis. The method was successfully tested but needs further refinement [59].

If the instrument is going to be used for NMR spectroscopy the final fine adjustment (“active shimming”) of homogeneity is typically and reasonably done by a set of coils charged by finely regulated and stabilized currents. However, these coils deviate from the standard shim-coil designs used in superconducting magnets with axial fields. Due to the transverse field in Halbach magnets, the coil geometry has to be adapted (e.g. using cosine-coils [60]).

5 Additional Features

5.1 Force-Free Openable Magnets

For some applications it can be useful to open Halbach rings and particularly spheres, e.g. to clamp them around a tube or plant or to insert samples (cf. Fig. 13). Following the discussion in [4] Halbach multipoles can be opened without forces at angles, \(\theta_{j}^{{{\text{opt}}}}\), which are solutions to (see Appendix G, Eq. (42))

$$3\cos (2k\theta ) = 1,$$
(24)

resulting in

$$\theta_{j}^{{{\text{opt}}}} \;\; = \;\frac{{ \pm \cos^{ - 1} \left( {1/3} \right)\;\; + \;\;2\pi j}}{2k}\;\;\;\;\;\;{\text{with}}\;\;j\; \in {\mathbb{Z}}.$$
(25)

Again, these are theoretically derived values for a dipole model. However, there are always clear minima in Halbach arrangements, but the optimal position to open such a magnet system depends also on the degree of discretization (see Appendix G). The optimal angle for k = 1 is \(\theta_{0}^{{{\text{opt}}}} \; \approx \; \pm 35.26^\circ\) and for k = 2, \(\theta_{0}^{{{\text{opt}}}} \; \approx \; \pm 17.63^\circ\). This variation of mutual forces can actually be experienced when building a Halbach dipole. Whereas the magnets close to \(\theta\) = 0 repel each other, they attract each other around \(\theta\) = 90°.

Fig. 13
figure 13

a Geometry of a Halbach dipole that opens without force at an angle \(\theta_{0}^{{{\text{opt}}}} \; \approx \; \pm 35.3^\circ\) relative to the poles. b Photograph of a prototype (NMR-CUFF) comprising four magnet stacks (of 8 magnets each, cf. Fig. 10, generating a magnetic field of 0.57 T), which opens at \(\alpha\) = 45°. Furthermore, it is equipped with gradient coils to image a stem of a plant in vivo. The resulting MRI is shown in c. For details see [4] (color figure online)

5.2 Nested Magnets with Adjustable Fields via Rotation

One of the most interesting ideas of using Halbach rings is to align them coaxially and rotate them to change the amplitude of the generated magnetic flux density in the center [61, 62]. Due to the fact that Halbach inner multipoles (k ≥ 1) have no stray fields they are not a magnet from the outside. Consequently, there is only negligible torque if they are rotated in the homogeneous field of another outer dipole [63]. The situation changes for multipoles which produce spatial field changes, but still the torque is relatively small, yet with some unavoidable cogging [33].

If B is a constant vector field over the entire sample region (i.e. a dipole, k = 1), its rotation by an angle \(\alpha\) is given by

$${\varvec{B}}^{\prime } = {\mathbf{R}}(\alpha )\;{\varvec{B}} = \left( {\begin{array}{*{20}r} {\cos \alpha } & { - \sin \alpha } \\ {\sin \alpha } & {\cos \alpha } \\ \end{array} } \right)\left( {\begin{array}{*{20}c} {B_{0} } \\ 0 \\ \end{array} } \right) = \left( {\begin{array}{*{20}l} {B_{0} \cos \alpha } \\ {B_{0} \sin \alpha } \\ \end{array} } \right),$$
(26)

where B′ is the rotated field by applying the rotation matrix R(\(\alpha\)).

For k > 1, however, the magnetic field depends on r (cf. Eq. (5)), and a real vector field rotation must be applied, e.g. for the gradients of a quadrupole (k = 2, see Eq. (16) and [2, 64])

$$\begin{aligned} {\varvec{B}}_{{\text{Q}}}^{\prime } ({\varvec{r}})\;\; & = \;\;{\mathbf{R}}(\alpha )\;{\varvec{B}}{}_{{\text{Q}}}({\varvec{r}}) \cdot \left( {{\mathbf{R}}^{ - 1} (\alpha )\;{\varvec{r}}} \right) \\ & = \;\;\left( {\begin{array}{*{20}r} {\cos \alpha } & { - \sin \alpha } \\ {\sin \alpha } & {\cos \alpha } \\ \end{array} } \right)\;G_{{\text{Q}}} \left( {\begin{array}{*{20}r} 1 & 0 \\ 0 & { - 1} \\ \end{array} } \right)\; \cdot \left[ {\left( {\begin{array}{*{20}r} {\cos \alpha } & {\sin \alpha } \\ { - \sin \alpha } & {\cos \alpha } \\ \end{array} } \right)\left( {\begin{array}{*{20}l} x \\ y \\ \end{array} } \right)} \right] \\ & = G_{{\text{Q}}} \;\left( {\begin{array}{*{20}l} {x\cos 2\alpha + y\sin 2\alpha } \\ {x\sin 2\alpha - y\cos 2\alpha } \\ \end{array} } \right). \\ \end{aligned}$$
(27)

Hence, the gradient rotates by 2\(\alpha\) when the quadrupole is rotated by an angle \(\alpha\) [64] (or generally the kth derivative of the magnetic field of a Halbach multipole with k ≥ 1, rotates with k\(\alpha\) when the multipole is rotated by \(\alpha\)).

The great advantage here is the possibility to change field and gradient strength when using nested magnets with the same polarity k. If, for instance, two dipoles are combined coaxially with radii chosen such that they produce the same flux, their combined field can be changed from twice that of a single one (parallel dipoles) to zero (antiparallel dipoles) as shown for dipoles and quadrupoles in Fig. 14.

Fig. 14
figure 14

Coaxial arrangement and rotation of Halbach dipoles (green, left column) and quadrupoles (red, right column). Their magnetization is indicated only by their poles (white or black encircled arrows): a, b two Halbach di- and quadrupoles which produce the same field strength, B, (central green arrow) in case of the quadrupoles the same gradient strength, G. Note that only the horizontal component of BQ is displayed by a red arrow and that this is the derivative of the field (small blue arrows in the center). In the following figures (ce) a and b are coaxially nested and the outer ring is rotated by an angle \(\alpha\). c For \(\alpha\) = 0° the fields are parallel and the two dipole fields add to 2B. d For \(\alpha\) = 90° the fields are orthogonal and the two dipole field vectors add to \(\sqrt 2 B\) at an angle of 45°. e For \(\alpha\) = 180° the fields are antiparallel and cancel each other. The same holds for the gradient in the right column at half the angles, because the gradient rotates at twice the angle of the quadrupole (cf. Eq. (27)). f The angular dependence of the combined field magnitude of both dipoles, \(B^{\Sigma } \; = \;2B\;\cos \,(\alpha /2)\) (green line) and the two quadrupoles \(G^{\Sigma } \; = \;2G\;\cos \alpha\) (red line) (color figure online)

This not only allows to adjust homogeneous fields for DNP [11, 12] or do field sweeps for EPR [9], but can also be used for imaging with gradients adjustable in strength and direction [64] (this will need a dipole and two rotating quadrupoles).

In this way very strong fields and gradients can be changed in less than a second, which may even be an alternative to electromagnets (considering their large inductance). In [65] a counter-rotating pair of dipoles generated an AC field of 150 mT with frequencies of about one Hz, a concept that may be also interesting for diffusion NMR on highly viscous melts.

5.3 Temperature Compensation

All sources of magnetic fields are temperature dependent and stable magnetic fields always require temperature control. While for superconducting magnets the boiling temperature of the cryogen depends only on ambient pressure, resistive electro- and permanent-magnets typically need active temperature control or locking systems [66].

However, Halbach systems can be constructed in a temperature compensated way. This very clever concept was proposed by Danieli et al. [67]. It uses the fact that the two main materials for rare-earth magnets (neodymium and samarium-cobalt) have temperature coefficients, \(\kappa\), of their remanence, which are different by a factor 2–4 (see Appendix A). They are defined via

$$B(T) = B^{{{\text{ref}}}} \left( {1\;\; + \;\;\kappa \;\Delta T} \right)\;\;\;\;\;{\text{with}}\;\;\;\;\Delta T = T - T^{{{\text{ref}}}} ,$$
(28)

where Bref is a reference magnetic flux at the temperature Tref. If two Halbach rings, which are made from two materials (A and B) with very different \(\kappa\), are combined such that their fields are antiparallel and their strength correspond to the ratios of their \(\kappa\), a change in temperature will shift the one field by the same amount as the other, but since they are subtracted the combined field stays constant (cf. Fig. 15).

$$\begin{aligned} B^{\Sigma } (T)\;\; & = \;\;B_{{\text{A}}} (T) - B_{{\text{B}}} (T)\; = B_{{\text{A}}}^{{{\text{ref}}}} \left( {1\;\; + \;\;\kappa_{{\text{A}}} \;\Delta T} \right)\; - B_{{\text{B}}}^{{{\text{ref}}}} \left( {1\;\; + \;\;\kappa_{{\text{B}}} \;\Delta T} \right)\; \\ & = \;B_{{\text{A}}}^{{{\text{ref}}}} - B_{{\text{B}}}^{{{\text{ref}}}} \;\; + \;\underbrace {{\left( {B_{{\text{A}}}^{{{\text{ref}}}} \kappa_{{\text{A}}} - B_{{\text{B}}}^{{{\text{ref}}}} \kappa_{{\text{B}}} } \right)}}_{ = 0}\Delta T, \\ & \Rightarrow \;\;\;\frac{{B_{{\text{A}}}^{{{\text{ref}}}} }}{{B_{{\text{B}}}^{{{\text{ref}}}} }} = \;\frac{{\kappa_{{\text{B}}} }}{{\kappa_{{\text{A}}} }}. \\ \end{aligned}$$
(29)
Fig. 15
figure 15

Temperature compensated Halbach dipole with the same construction principle as in Fig. 11. However, the system is combined now from two antiparallel dipoles. They are sketched on the right (cyan: NdFeB and yellow: SmCo) next to a measurement of the change of the magnetic field, ΔB, with temperature for the three magnet configurations. The dashed line corresponds to the magnet made only from trapezoidal SmCo blocks, while the dotted line represents the array built from rectangular NdFeB pieces. The continuous line shows the temperature compensated magnet. Adapted from [67] and reproduced with permission of the American Physical Society (color figure online)

The original publication also takes thermal expansion into account, which was neglected here for the sake of simplicity.

Temperature stabilization by this approach is a quite general concept, which can be adapted to various magnet geometries. In [67] it was also discussed for quadrupolar Halbach rings and planar Halbach arrays as used in undulators. However, the concept reduces the field by a factor of (1 − \(\kappa\)B/\(\kappa\)A). Recently new Sm2Co17 materials have become available which are completely temperature insensitive at RT. Although they have only remanence values in the regime of 0.8–0.9 T, this may still allow to generate higher fields than the approach discussed above [68].

5.4 Some Practical Considerations for Construction

The design of a Halbach array should start with an estimation of the necessary field and/or gradient strength needed for the planned experiment. Naturally, the necessary boundary conditions like size, homogeneity, temperature variations, and possible costs have to be determined as well. Then the equations in Sect. 3 should be used to estimate the sizes and the shapes of the magnets. Usually there are conditions that request compromises in field, homogeneity, space, and costs. The necessary equations are easy to program or can be copied from [69]. When a geometry seems to be suitable, the next step is a fine-tuning using some software that considers the actual magnet shapes (and not only their effect on the central field). This can be a simulation package that uses finite-element (e.g. COMSOL Multiphysics) or boundary-element methods (e.g. Amperes, IES, Winnipeg, Canada). If the design includes materials with non-linear magnetization (e.g. iron), the material properties must be properly included in the simulation. Quite often one has to request BH-curves from producers. However, there is also very useful freeware available, e.g. FEMM (https://www.femm.info/) which is limited to two dimensions, but includes the use of BH-curves. Another great package is magpylib (https://magpylib.readthedocs.io) [70], which is 3D and uses analytical solutions of a set of geometries, hence it is very fast, but needs some elementary skills in Python programming (it also does not include permeabilities and non-linear magnetic behavior). Regardless of which software package is used one should always predetermine the necessary accuracy up to which the geometric optimization is reasonable. Typically, this is limited by the precision to which magnets can be produced and supports machined (normally not better than 100 µm).

After optimizing the geometry and position of the magnets, the support needs some thought, ideally together with strategies on the procedure of mounting the magnets.

Mounting rare-earth magnets of sizes larger than ca. 10 cm3 can already become dangerous, as the forces roughly scale as [4] (for small distances to the surface of two magnets with surface area, A)

$$F\;\; \approx \;\;\frac{{B_{{\text{R}}} A}}{{2\mu_{0} }}.$$
(30)

Several of the software packages also allow the calculation of the forces, but the direction must be also considered, because a repelled magnet needs some support and fixture to keep it at the position. A good advice is therefore a test run on a scaled down mockup system (e.g. using inexpensive magnets from internet stock and 3D-printed plastic supports). This helps tremendously to figure out if the procedures are feasible before ordering expensive custom-made magnets.

For instance, Eq. (30) predicts a force in the range of 100 N for ca. 1 cm2, while it amounts already to 1000 N for 10 cm2 sized FeNdB magnets. This is just the force between two magnets, two completely assembled rings can easily generate forces that exceed 10 kN. Therefore, upscaling of such magnetic designs quickly becomes an engineering problem in calculating and managing forces, using suitable materials of sufficient thickness and safe procedures for placing and fixing the permanent magnets. This is a process, which requires a lot of experience that can only be acquired safely by starting and tinkering with smaller systems.

For the construction a magnetic set of tools is more useful than expensive non-magnetic instruments. This is because in a well-planned construction iron plates underneath the support for the permanent magnets can work as a yoke and help to hold the magnets in place while the glue is setting. The same holds for magnetic pliers or clamps which can be placed over the poles of a magnet to shield it from the others during positioning, thus significantly reducing mutual forces [34]. Nevertheless, a good magnet manufacturer also has a larger supply of wooden blocks, plates and wedges (and some band-aid). The handiest tool of all though is a 3D-compass or pole-finder to quickly check the polarity of a magnet or entire arrangements.

Since magnetic resonance does not only require magnets, readers, who are interested in developing or building equipment (amplifiers, coils, magnets, software, etc.) are referred to the webpage [71] of the Open Source Imaging (OSI2) initiative [72].

6 Conclusion

The intention of this review on Halbach magnets for applications in magnetic resonance was to compile the necessary knowledge to plan, design and construct such arrays. Special emphasis was given to simple, analytical estimations of magnetic field strength or their gradients. Another focus was to summarize various strategies to homogenize the fields as this is of paramount importance for NMR. As to the topic of homogeneity, to provide a sufficiently homogeneous field in a given space is a difficult task, especially with permanent magnets, because their physical properties usually vary in the percent range, as has been shown here. Thus, without further measures, it would be a matter of coincidence if a homogeneity requirement is met, based only on an even perfect numerical design of the magnet arrangement. Several such measures have been mentioned in this publication, they comprise the appropriate placement of the permanent magnets in the arrangement such that their magnetic property variations cancel, the adaptive placement of shim magnets or steel disks/sheets on the poles and even the active shimming by adjustable coil currents. Homogeneity is difficult to achieve if space restrictions force the magnetic arrangement to be small, the homogeneous region scales with the size of the arrangement, but the size of the permanent magnets and the forces between them scale more than linearly, which may become a safety issue. In the end, it may only be possible to achieve a required homogeneity with a combination of all these measures. A good numerical design, as described in many publications, can only be the starting point for further experimental optimization.

The last section is a collection of features that are to some extent special for Halbach magnets and allows to use them in unique experiments. We hope that this compilation enables interested experimentalists to create dedicated magnets for their special needs, and maybe share a bit of the fascination for these ‘magic rings’.