Halbach Array Permanent magnets using harmonic corrector rings – thus making the field real-valued. Because H z is much larger than the transverse components, H x or H y , they are truncated by H z and therefore negligible. Hence, to a good approximation, H z determines the Larmor frequency. The task of the shimming system is to vary the currents in shim coils, which amounts to varying the coeffi- cients R a lm or I a lm . Similarly, spherical harmonics can be used when the shims are Halbach-type arrays instead of coils, however the solution and execution are of slightly different form. Halbach-type arrangements can provide one-sided fluxes which show a remarkable degree of uniformity inside a ring 4 and nearly zero flux outside. This means the usable shimming field can be relatively large; in fact, almost as large as the shimming aperture itself. Additionally, the absence of flux outside the aperture does not perturb the magnet creating the external field. While shim coils can achieve considerable homogeneity over the bore Halbach-type shimming can have its advantages in smaller systems. When designing small scale portable magnets with small bores, it is crucial that the shimming system does not occupy too much space inside the bore of the magnet, as this would severely limit the usable region. For such systems, a Halbach-type arrangement can yield gradient field strengths strong enough for shimming purposes and still be compact, thus leaving enough room for experiments. Furthermore, Halbach arrays eliminate the need for a power supply, which can be important in portable ex situ and rotating field type systems.

Halbach Array Permanent magnets using harmonic corrector rings
Fulfilling the need for 5,6 shimming systems suited for rotating field NMR systems would be technically challenging in connecting and control- ling electrocoil shims as the shimming coils would need to rotate with the field. However, permanent magnets supply a perfect solution as they have no leads which would tangle as the bore rotates. To overcome these difficulties, in the contexts of portable and/or rotating field NMR systems, we present a “one shot” shimming system where one maps the field and com- pensates for each order of inhomogeneity in the field. Shimming with this method can be done in real time, using field mapping, or it can be done only once, as part of the magnet design phase. The novelty of our method lies in its use of harmonic 7 corrector rings which are rings composed of concentric permanent magnet rods ͑ magnetic dipoles ͒ whose overall and relative orientations can be used to adjust the field strength, orientation, and multipole order. In our case, the rods are substituted by adjacent pairs of small disk PMs which ap- proximate magnetic dipoles. We demonstrate the method’s implementation in generating quadrupolar fields to correct inhomogeneities. Any number of additional rings can be added to correct arbitrary multipole orders simultaneously. Magnets can be arranged in a ring to produce a field of a chosen order, N , by selecting their overall and relative orientations. Assembled this way they can be used to correct for an inhomogeneity in an already existing magnetic field. In order to null a multipole term of order N , using a single ring of equally spaced magnets as in Fig. 1, the orientation of the 7 n th magnet is given by n = N + 1 n + init , 2 where  n is the angle of the location of the n th magnet on the ring and init is an angle defined by the orientation of the required multipole, both with respect to the x axis. In general, the magnetic dipole moment of the n th magnet is given by m n = n ͑ cos n , sin n , 0 ͒ , where n is the magnitude of the dipole moment. The latter is related to the dimensions of the magnet according to the volume integral of the magneti- zation or remanent field n = ʈ ͐ V M ͑ r ͒ d 3 r ʈ . Figure 2 shows a ring of six magnets oriented to produce dipolar, quadrupolar, and sextupolar magnetic fields in this manner. Our analysis will concentrate on the quadrupolar case, though extension to higher orders is straightforward ͑ see the Appendix ͒ . In this case, N = 2 and init is the orientation of the H x component of the quadrupole. Using  n values defined for a six-magnet ring in Fig. 1 and applying these values to Eq. ͑ 2 ͒ , we get 3 o = e + = init + , ͑ 3 ͒ 2 where o is the orientation of odd-numbered magnets and e is the orientation of the even-numbered magnets. Thus, going round the circle, the orientation of neighboring magnets differs by . In order to control the magnitude and orientation of the quadrupole, we analyzed the contribution of each H ͑ r ͒ = 4 1 r 3 ͓ 3 ͑ m · r ˆ ͒ r ˆ − m ͔ , ͑ 4 ͒ where H ε ͑ H x , H y , H z ͒ is the magnetic field at r , the position vector of the measurement point relative to the position of the dipole. Differentiation of this expression with respect to r gives the field gradient due to the point dipole magnet ٌ H H ͑ r and ͒ ε = d d 4 magnet H r 1 r = 3 ͓ 4 3 ͑ 3 m r ring 4 ͓ · mr r ˆ ͒ to ˆ r ˆ + − the r ˆ m m ͔ overall , + ͑ m · magnetic r ˆ ͒ I − 5 ͑ m field. · r ˆ ͒͑ r ˆ r ˆ ͔͒ ͑ 4 , ͒ where If the H ε dimensions ͑ H x , H y , H of z ͒ a is magnet the magnetic are small field in at comparison r , the posi- ͑ 5 to ͒ tion the where distance vector I is the of to the identity a point, measurement tensor r , at and which point the a notation relative field measurement to uv the indicates position is a of tensor being the made, dipole. ͑ dyadic then ͒ Differentiation product the magnet of u and can of this be v . approximated expression with as respect a point to dipole. r In gives our The the experiments, magnetic field gradient field the of due x a axis point to the was dipole point designated at dipole r , the as position main magnetic vector of field the measurement direction, while point the relative z direction to the was position along the of longitudinal the dipole, is axis given of by the magnet bore. Truncation of H y and H z , as described in the introduction, means that the relevant tensor component for our experiments is ٌ H x ε dH x / d r . We now restrict the analysis to points along the z axis, as shown in Fig. 3 ͑ a ͒ , where r , the magnitude of r , is the same for all magnets on a given ring. It is also assumed that the value for the magnet strength, , is the same for all magnets. ٌ H ε d d H r = 4 3 r 4 ͓ mr ˆ + r ˆ m + ͑ m · r ˆ ͒ I − 5 ͑ m · r ˆ ͒͑ r ˆ r ˆ ͔͒ , ͑ 5 ͒ where I is the identity tensor and the notation uv indicates a tensor ͑ dyadic ͒ product of u and v . In our experiments, the x axis was designated as main magnetic field direction, while the z direction was along the longitudinal axis of the magnet bore. Truncation of H y and H z , as described in the introduction, means that the relevant tensor component for our experiments is ٌ H x ε dH x / d r . We now restrict the analysis to points along the z axis, as shown in Fig. 3 ͑ a ͒ , where r , the magnitude of r , is the same for all magnets on a given ring. It is also assumed that the value for the magnet strength, , is the same for all magnets. In the case of a single ring of six magnets, the gradient of H x is given by substitution of the values of m and r from Table I into Eq. ͑ 5 ͒ , dH d r x =− 45 8 n r l 3 7 cos sin o o , ͑ 6 ͒ 0 where l is the radius of the ring of dipoles. Thus a single ring of magnets enables control of the orientation but not the magnitude of the field gradient. To null a quadrupolar term of arbitrary magnitude, a second corrector ring is required ͓ Fig. 3 ͑ b ͔͒ . The gradient is given by the sum of the contributions from each ring sin o 1 sin o 2 dH d r x =− 45 8 n l 3 ́ r 1 7 1 cos 0 o 1 + r 1 7 2 cos 0 o 2 ̈́ , ͑ 7 ͒ where r i ͑ i = 1 , 2 ͒ is the distance from the magnets on the i th ring to the point of interest and oi is the value of odd num- bered magnets for the i th ring. We note a small limitation to consider when choosing the strength of magnets used for shimming. The gradient has l 3 / r 7 dependence. Thus a probe having a finite length in the z dimension will experience a variation in dH x / d r , even if centered at Z c , the center point between two paired rings. This new inhomogeneity can be minimized by making r as large as possible. Hence, the coil must be centered away from Z c , though this reduces the overall magnitude of gradient that can be produced by the ring pair. The situation is improved with the incorporation of an identical second ring pair symmetrically opposite to the first, as shown in Fig. 3 ͑ c ͒ . This doubles the available gradient magnitude, while further reducing the z dependence of the H x gradient. The field gradient at Z 0 , the point between the two ring pairs is then simply twice Eq. ͑ 7 ͒ . The ideal case for this system is one where the magnets in rings 1 and 2 would literally occupy the same space. In this case our rings would be capable of correcting for any field error within the PMs strength in xy up to order 5. It should be noted that Eq. ͑ 7 ͒ implies that there is a minimum gradient magnitude that a given ring pair can correct for. This occurs when o 1 = o 2 + . To obtain lower magnitude gradients r must be increased by separating the two ring pairs along the z axis or PMs of smaller strength should be used. Nulling higher order harmonics can also be done using this system along with using multiple sets of shimming rings for simultaneously nulling multiple orders of harmonics. The corrections for second order and third order inhomogeneities are provided in the Appendix. The PM shims can in principle be used to reduce a z gradient simultaneously with an xy plane gradient through a vectorial superposition of magnet orientations which would individually null the errors in the xy plane and z axis. The magnet is a 16-element NdFeB Halbach array as shown in Fig. 4. The elements are arrayed in four layers to produce a dipole field. The array has a mass of approxi- mately 5 kg with an outer diameter of 100 mm and a usable bore diameter of 41 mm. The resulting field strength was 0.5 T, or a proton resonance frequency of 21.4 MHz. Typical inhomogeneities over a volume of 0.1 mm 3 at the center of the magnet, are approximately 10 500 Hz ͑ 450 ppm ͒ ͓ see Fig. 7 ͑ c ͔͒ . Two types of magnetic inhomogeneities can arise in a magnetic system. One, those produced by the inherent discretization and symmetries of the magnet design. Two, those due to the accuracy of design execution and level of toleration in fabrication. Our magnet described earlier was designed to have an intrinsic inhomogeneity limit of 20 ppm in a field region of 1 mm 3 . However, even at this level of homogeneity the field would still benefit from shimming. A third broadening specific in NMR is the field drift, which we will discuss at more length in Sec. IV A. The shimming experiments were performed on water and fluorinated compounds using a Chemagnetics Infinity 400 spectrometer. Due to the significant inhomogeneity in the field, and to bypass the coil ring down time, a single spin echo readout was used to measure the center frequency and linewidth of the peak. Field measurements were made using a home built probe which consisted of a solenoidal microcoil of length 2 mm and inner diameter 350 m, using copper wire of width 50 m, wrapped around a capillary tube of outer diameter 350 m and inner diameter 250 m. It was a single resonance probe with the tuning circuit located outside of the magnet. This allowed the coil to be on a thin rod which would be movable via a positioning system for accurate field mapping ͓ see Fig. 6 ͔ . The tube was filled with MnCl 2 doped water, to keep the T 1 relaxation time under 1 s in order to speed up the acquisition time typically to under 2 min. The harmonics correcting device consists of four azi- muthally evenly spaced cylindric PMs mounted into rings of Delrin, as shown in Fig. 5. Halbach Array Permanent magnets The PMs are small cylinders of NdFeB with radius 2.5 mm and length 2 mm. Each PM can be rotated in the xy plane but is prevented from rotation into the z direction. Each ring of PMs is directly adjacent to an- other ring ͓ Figs. 5 ͑ b ͒ and 5 ͑ c ͔͒ , in the z axis, creating two pairs. The distance between the two ring pairs can be increased by adding spacers. This reduces the magnitude of the correction gradient, as described at the end of Sec. II B. Magnetic field maps were constructed from the proton resonance frequency of water ͓ Figs. 7 ͑ a ͒ and 7 ͑ b ͔͒ with the mapping coil oriented parallel to the z axis in order to obtain the smallest possible voxel size in the xy plane. The probe was positioned using a translational stage, as shown in Fig. 6, which had a precision of 0.01 mm in all three dimensions. Using a map of the xy plane of the magnetic field at the Z 0 position, the dominant inhomogeneity in the magnetic field was determined to be a quadrupole, n = 2. The values of dH x / dx and dH x / dy were determined and used to solve Eq. ͑ 7 ͒ for the angles o 1 and o 2 . The angles e 1 and e 2 were calculated from Eq. ͑ 3 ͒ and the PMs were manually oriented into their respective directions. Figures 7 a and 7 b are maps of the H x component of the magnetic field before and after placement of the shim rings. The shim rings compensated for a gradient of approximately 2.78 G/mm at 300° with respect to the positive x axis. In further experiments the nullification of the xy plane, first derivative, gradient was accompanied by a significant improvement in NMR linewidth. In the center region of the magnet, before shimming, linewidths were as great as 12 000 Hz. Figures 7 ͑ c ͒ and 7 ͑ d ͒ demonstrate the spectroscopic improvement on a water sample. The nullification of the gradient led to a concomitant reduction in half peak width from 10 500 Hz ͑ 450 ppm ͒ to 1200 Hz ͑ 56 ppm ͒ , or an improvement of about 8.75:1. Following the one-shot shimming process, linewidth improvements of 7.5:1 were commonplace, Halbach Array Permanent magnets while improvements of up to 9:1 were sometimes observed. In other experiments, the linewidths of two 19 F species were improved to reveal a chemical shift splitting that could oth- erwise not be resolved, as demonstrated in Figs. 7 ͑ e ͒ and 7 ͑ f ͒ . Our multielement Halbach magnet typically exhibited drifts in the gradient of the ͑ main ͒ static field on the order of ±0.05 G / mm and ±5° over the course of a day, due to the poor temperature control in the room ͑ 19–22 °C over 24 h ͒ . As for any permanent magnet, adequate temperature stabili- zation is required. Further improvements in linewidth can be made by iden- tifying higher-order inhomogeneities following shimming and adding additional shim rings to correct for them. Such additional corrections were not necessary in order to resolve the 19 F chemical shift in a mixture containing two fluorinated compounds. For higher resolution spectroscopy such as proton NMR, where the whole chemical shift range is 10 ppm, this method would be necessary. The shimming magnets are themselves a source of error due to the lack of precision knowledge of the easy-axis orientation and field strength of each PM. The variations in these properties are due to unavoidable inaccuracies in the fabrication process. However, in principle these errors could also be nulled with the system itself. Adjustments of the PM after further inquiries into each PMs properties and further iterations of the mapping, shimming system would eventu- ally allow the system to shim out its own inhomogenieties. The response of this shimming method to these inaccuracies was analyzed through computer simulation. The computer program used the charge sheet model described by 8 Schlueter et al. to calculate the magnetic field due to the PMs. Halbach Array Permanent magnets The PM field strength standard deviation was estimated to be 20% while the error in the orientations of the magnets was estimated to be 3° ͑ standard deviation ͒ . This variation was included as a random value added or subtracted from the strengths and orientations of the PMs. One hundred simulations were run and the data are displayed in Fig. 8. From this, we conclude that, within the center of a harmonic corrector ring, a large portion of the area can be used to provide desired gradient corrections. For a shimming method to be useful, the gradient must be uniform across the spatial extent of the coil. These data imply that the region within the center of the magnet has a tolerable variability in its field gradient. This region could be made larger by increasing the accuracy of magnet orientation and improving the consistency of the surface fields of the magnets. We have shown that harmonic corrector rings can be used to shim the field of a permanent magnet, leading to NMR linewidth improvements of up to an order of magnitude. Nullification of the quadrupolar inhomogeneity has been demonstrated and the methodology for higher-order harmonics correction using further sets of rings has been outlined. The method has been shown to be robust in response to inherent uncertainties in the strength and orientation of the PMs. Adjustment of the angle and magnitude of the applied correction gradient is simple, allowing for quick response to drift in the magnetic field. The method could be further sped up by automation of the magnet orientations. The low-cost, simplicity, and flexibility of this device make it a useful tool in the development of magnets where field homogeneity is important but shimming coils are unsuitable. In particular, the large size of the usable shimmed region in comparison to the overall size of the corrector rings makes this shimming method particularly convenient for use in small portable NMR systems. This work was supported by the Director, Office of Sci- ence, Basic Energy Sciences, U.S. Department of Energy under Contract No. DE-AC02–05CH11231. The authors thank Marcus H. Donaldson for carefully proofreading the manuscript and William Gath for the assembly of the Halbach magnet array and for help during the design and assembly of the shimming device. In general, a ring of n equally spaced permanent magnets can be used to null up to a harmonic of order n − 1. Thus the corrector rings described in this article could be used to null an inhomogeneity of up to a decapole. The analytical expressions for the second and third derivatives of the field are d d 2 r H 2 = 4 15 r 5 5 1 ͓ 2 Im + mI ͔ − r ˆ mr ˆ − r ˆ r ˆ m − mr ˆ r …