Permanent-magnet quadrupoles for an interdigital H-mode drift tube linear accelerator : Optimization code and adjustable magnet design

Magnets to be used for the internal quadrupoles of an interdigital H-mode drift tube linear accelerator (IH-DTL) using KONUS beam dynamics should be both compact in size and high in focusing field gradient. Permanent magnets are an attractive solution, but then the ability to adjust the field strength is lost. We investigated two different solutions to this problem: the first using external adjustable electromagnets; the second using internal adjustable permanent magnets. The first method moves the variability out of the resonant cavity, using adjustable electromagnet quadrupole doublets before entry into the IH-DTL to compensate for the lack of internal variability. We carried out optimization simulations with custom code that ran many instances of the LORASR beam dynamics simulation software, using different values of field strength for the external doublets. By optimizing the magnet settings for different values of input current, we were able to compensate for the space-charge forces involved in accelerating a high-intensity continuous-wave (CW) deuteron beam. Second, we designed some novel adjustable permanent-magnet quadrupoles to be used inside the cavity, which combine the advantages of small cross-section and variable field gradient. This allows much more control over the beam, and even other ion species with differing charge-to-mass ratios can be accommodated within the same accelerator design. We developed two adjustable permanent-magnet designs: one with an electromagnetic component, and the other with two concentric moving rings of Halbach-array quadrupoles.


I. INTRODUCTION
Quadrupole magnets are used for transverse focusing of the beam within a particle accelerator.For linear accelerators using resonant cavities, quadrupoles can be placed within the cavity's drift tubes, or outside the cavity entirely.For internal quadrupoles, the smaller the external diameter the better, because larger quadrupoles require larger drift tubes to accommodate them, resulting in increased capacitance, lower shunt impedance, and higher rf power dissipation [1,2].
Traditional electromagnets are difficult to keep small.The Heidelberg ion therapy (HIT) accelerator pushed standard magnet fabrication techniques to new limits to produce electromagnets with a small enough outer diameter to fulfill the power requirements [3].This type of magnet design has also been used in other DTLs [4].
A different technique uses electroforming to produce the coils, rather than bending copper tubes, producing even smaller outer dimensions for the drift tubes, first used at KEK in Japan [5], and more recently for the CSNS in China [6].
A promising avenue for further reducing the size of the internal quadrupoles is to make use of permanent-magnet technologies, as used in CERN's Linac 4 [7,8] and elsewhere [9][10][11][12].This also removes the requirements for electrical power and control of the electromagnets, and complicated cooling systems, but at the expense of control of the magnetic field [13].Once the permanent magnets are installed, the field pattern is fixed and cannot be adjusted.This is fine if the properties of the beam are always the same, but in practice the size and shape of the beam changes during operation of the accelerator.When a beam is first switched on, the current will start from zero and then rise up to full operational beam current.For high intensity accelerators, the difference in space-charge forces from zero to full current is substantial, and controlling the beam over the full range of current using fixed permanent magnets is problematic [13].For linacs that are designed to accelerate different species of ions, the difficulties are even greater, as the variation of field gradient required to control the beam for different ion species is an order of magnitude higher than the variation required to handle changes in beam current for a single species [14].
We have investigated a solution combining external variable-strength electromagnets with internal fixed-strength permanent magnets, using KONUS beam dynamics in an IH-DTL accelerating structure (see Sec. II below).This combination allows us to control the beam using conventional electromagnets located outside of the resonant cavity, where the outer diameter of the quadrupoles is less constrained, while using much smaller permanent magnets inside the cavity.
We have written some code using the scripting language AUTOIT that allows us to run multiple LORASR simulations (see Sec. III below).This enables us to sweep through the external electromagnet settings and find the best parameters to match various beams to the fixed internal permanent quadrupoles.The results show that this technique can adequately handle the increase of deuteron beam current from zero to 1 mA in the linac design described below.However, when switching the ion type to protons or to lithium ions, this external variation technique is not enough to control the different ion beams.This means that variable internal quadrupoles will be required to handle the different ion types.
We therefore have begun to investigate some possible designs for small-footprint adjustable quadrupoles to be used inside the resonant cavity (see Sec. IV below).The first design is a hybrid containing permanent magnets and small iron cores for the bulk of the field, with copper coils to adjust the field gradient upwards or downwards as required.The second design uses only permanent magnets, with two concentric rings of Halbach arrays that can rotate to adjust the combined field.The hybrid magnet has the advantage of being very quickly adjustable, allowing fast responses to changes in the beam parameters.The concentric design has the advantage of not requiring a dedicated cooling system.

II. ACCELERATOR LAYOUT
We chose the linac design shown in Fig. 1 as the subject of our investigations.This is part of a design for a deuteron accelerator, to be used as a compact neutron source.There are two quadrupole doublets surrounding a short buncher after the RFQ exit, and then the main IH-DTL with one internal quadrupole triplet.The parameters of the DTL are given in Table I, with input beam emittances taken from simulated RFQ output distributions.
This particular design has a number of features that make it attractive for the use of permanent magnets.
Firstly, the linac is an IH-DTL design using KONUS beam dynamics.KONUS stands for "KOmbinierte NUll grad Struktur," which means "combined zero degree structure."This type of dynamics, developed by Ratzinger et al. starting in 1988 as part of the upgrade for the Munich linear heavy ion post-accelerator [15][16][17], has the advantage that the bunches remain radially focused through the drift tubes, and can therefore travel longer distances between focusing elements such as quadrupoles.Some designs using KONUS dynamics have resonant cavities with no internal focusing elements [18,19], while others incorporate small quadrupoles within longer cavities [2,[20][21][22].
IH-DTL machines have a much higher effective shunt impedance than traditional Alvarez-type linacs, by a factor of three or more in some cases [23].With KONUS dynamics, the reduced need for focusing elements means that the drift tubes can be very slim, leading to a much lower capacity load per length and thereby increasing the effective shunt impedance [16].However, many IH linac designs still require some focusing elements, where slim drift tubes cannot be used.Making use of permanent magnets could further increase the shunt impedance.Also, permanent magnets do not require electrical power to produce fields, leading to further improvements in power usage.For this simple design with a single quadrupole triplet, the effect of reducing the external diameter of the internal quadrupoles by half is a further 3% increase in shunt impedance.For an equivalent Alvarez-style linac, the use of permanent magnets would produce even greater  gains, with the shunt improvement increasing by 17-20%, and saving on power required for each internal magnet.Second, the main application of this design is to accelerate a high-intensity CW deuteron beam.This offers the challenge of controlling the beam from zero to full current, with the added difficulty that deuteron losses can be a major radiation risk, so the requirements for control are tight.For this accelerator, we need to be confident that the entire beam can be well controlled at all times.
Third, the project related to this linac design has secondary aims of accelerating different ion species within the same DTL.In addition to deuterons ( 2 H þ ) and molecular hydrogen ions (H þ 2 ), which share the same charge-tomass ratio, the linac should also be capable of accelerating protons and lithium ions, albeit with much lower beam currents.The changes to the settings for the quadrupoles are much larger when switching to a new charge-to-mass ratio, so this offers an even greater challenge to the control scheme.

III. EXTERNAL ELECTROMAGNET OPTIMIZATION
Our first set of investigations focused on the two external electromagnetic quadrupole doublets.Being outside the cavity, these magnets have much less of a space constraint in the radial direction.We ran a set of simulations where the internal quadrupole triplet were fixed-strength permanent magnets, but the external doublets used standard electromagnets.The aim was to test whether enough variation could be introduced by the external quadrupole doublets to control the beam through the whole DTL.As the beam characteristics changed, such as by adjusting the current or the charge-to-mass ratio, we changed the settings on the external doublets in the simulation, but kept the internal triplet settings fixed.

A. Optimization code
To run the simulations, we used the LORASR code developed at GSI specifically for KONUS dynamics simulations [24][25][26].In order to investigate many different settings for the external doublet magnet parameters, we wrote some code using the scripting utility AUTOIT and investigated the optimal settings using the pivot table capabilities of MICROSOFT EXCEL.

Multidimensional parameter sweep
We wrote the scripts for running batches through the LORASR simulator as a number of interconnected modules.The code for these scripts is available open-source [27], although it relies upon the user having a valid copy of LORASR itself.The AUTOIT scripting utility is available free of charge [28].
The first module of the code is termed RUNLORASR.Its function is simply to automatically run a single instance of LORASR for a given input file.The code also incorporates a settings file, log files, and error checking, to be able to run the simulations robustly as part of a batch.
The second module is called PLOTLORASR.This module reads the output files produced in the last simulation and saves them to an EXCEL workbook, plotting the results as graphs in multiple sheets within the workbook.
The third module is BATCHLORASR.Given a set of input files, this module will work through the simulations one at a time, calling the RUNLORASR module for each input file and then calling PLOTLORASR to save the results to a separate spreadsheet for each run.It also creates a summary results file for all the runs in the batch.
The next module is termed SWEEPLORASR, which sets up the parametric sweep at the beginning of a batch process.The user defines the sweep using a template input file and a spreadsheet of all the parameter values to be tested.The code then works through the spreadsheet and creates a separate input file for every possible combination of parameter values.These generated input files are then used as the input for BATCHLORASR.
This sweep module has also been adapted and generalized to be able to perform the same function for different types of input files for other simulation programs, resulting in a standalone program currently known simply as SWEEP [29].
The code also contains a couple of utility modules, COLLATELORASR and TIDYLORASR, and a library of common functions.
The program structure is visualized in Figure 2. The main user interaction is with BATCHLORASR, which can call and control all the other modules.

Multidimensional analysis
To analyze the results, we made use of the pivot table capabilities of MICROSOFT EXCEL for multidimensional analysis.This allows us to identify not only the single best working point, but also the trends for each of the parameter dimensions and the relations between them.For example, Figures 3, 4 and 5 show results from the same data set sliced in different ways.
We built this particular multidimensional data set by running BATCHLORASR on a parametric sweep file with five different parameters: the field gradient for each of the four quadrupoles in the two external doublets, and the beam current.The code then works through all possible combinations of values for the five parameters, and runs the simulation for each combination.The summary results file stores the values of each swept parameter as the dimensions of the data set, and the beam dynamics results as the data points.This file is a flat comma-separated variable (CSV) file, which is then imported and analyzed in MICROSOFT EXCEL.
In the data set depicted below, there were five parameters with between five and eight values for each parameter.
There were a total of 7,000 combinations, meaning LORASR was run 7,000 times.The whole simulation batch took less than 24 hours to run.
Figure 3 shows how the maximum beam quality over all tested field settings varies with current.These values are calculated and plotted by taking a slice from the multidimensional data set along the dimension of beam current, and finding the highest value for beam quality across all other dimensions.This is equivalent to setting the beam current to a fixed value for each data point on the graph, and then varying all other parameters to find the optimal setting at that data point.
One advantage of the multidimensional approach is that we can ask all kinds of different questions using the same dataset.The corresponding disadvantage is that we need to prepare the data set with enough dimensions and enough data points when we are setting up the parametric sweep, otherwise we will not be able to answer some of the questions we may later want to ask.
Figure 4 is produced by slicing the same multidimensional data set along different dimensions.In this case, we firstly limited results to those at the design current of 10 mA.Then we sliced the data set along the dimension for each variable quadrupole field setting, finding the best quality beam for that data point by allowing the dimensions for the other three quadrupoles to vary.This is all handled automatically by the pivot table function.This produces the four different curves for the four different quadrupoles in the two external doublets.
Figure 5 is a slightly different plot.Rather than plotting the measure of beam quality for different parameter values, it plots the optimal values for one parameter given the value of another parameter.Again, this plot is produced from the same multidimensional data set, but by slicing the data in a different direction.
This kind of multidimensional approach can also be used to model "what-if" scenarios.For instance, by only considering one value for the field gradient of one of the quadrupoles, we can ask the question, "What if this magnet were a fixed permanent magnet?"Or by shifting the value for one of the parameters systematically away from its optimal value, we can ask the question, "What if one of the magnets was badly calibrated?"

B. Optimization results
We used the system described above to investigate two different scenarios, both of which assume that the internal quadrupole triplet uses permanent magnets.The first scenario is a single ion species, deuterons, with beam current ranging from zero to 14 mA in CW operation.This is to test whether the external electromagnet optimization can cope with the space-charge forces in a high-intensity accelerator.The second scenario introduced different ions with different charge-to-mass ratios, Lithium ions and protons, to investigate whether such external adjustments could work for a more versatile machine.

Deuteron beam current
In the first scenario, we were interested in whether we could compensate for space-charge forces when ramping up a deuteron beam current from zero to the design value of 10 mA.We fixed the physical dimensions of all the quadrupoles, fixed the design of the DTL structure, and fixed the field gradient of the internal quadrupole triplet.We allowed the field strength of the external quadrupole doublets to vary, and set the current to increase from zero to 14 mA, slightly higher than the design value.This models the situation a real machine would have if it had fixed permanent-magnet quadrupole triplets internally and variable electromagnet quadrupole doublets externally.
We found that the transmission of the DTL stayed at 100% unless the magnet parameters were set to extremely high or low values.However, the beam quality could still be measured by comparing the number of particles in the core of the beam.This value dropped off dramatically when the settings were not optimized, suggesting a significant beam halo effect [25,30,31].The plots in Figs. 3 and 4 use the percentage of particles in the core as the measure of beam quality.
The results plotted in Fig. 3 show the beam quality decreasing slowly as the current increases.As the spacecharge effects in the beam become more significant, the external quadrupoles alone are less able to control the shape of the beam, and more particles migrate to the beam halo.
Note that in this case, the best results are found at zero current.Further optimization would shift the working point for the internal triplet, or shift some other parameters of the DTL structure, so that the best results could be matched with the design current for the accelerator.
Figure 4 shows an interesting difference between the second quadrupole in the first doublet compared to the other three adjustable quadrupoles.The best results are found when that particular magnet (QD1-2) is set to a significantly higher gradient than the other three.In optimization of an accelerator design, this might suggest to the designer that the length or positioning of this particular magnet should perhaps be varied to bring it more in line with its neighbors.In this particular data set, it seems that the results do not have quite enough data points to fully characterize the response of the beam to the magnet variation.However, the trends are already starting to emerge.For example, the beam quality is much more strongly affected by the variation of the second doublet than the first, which is important when designing a scheme for varying the doublet settings for a real machine.
The plots of optimal magnet settings for different currents in Fig. 5 are interesting in that some magnets are more predictable than others.The first quadrupole in the second doublet (QD2-1) is the simplest, with required field rising monotonically with increasing current.The first quadrupole in the first doublet (QD1-1) follows the same pattern to begin with, but requires slight tweaking at higher currents.The second quadrupoles in each doublet are much harder to predict, with the optimal settings sometimes jumping higher and sometimes falling lower than the trend would suggest.
This behavior is due to the interconnected nature of the four parameters.Changing the magnitude of the field gradient in one magnet shifts the required settings for the next magnet, and so on.With all other parameters fixed, we expect that varying a single magnet will produce a simple trend for the beam quality, but allowing all four magnets to be varied independently allows for one magnet to compensate for another, so that the best combined working point can be found.
In fact, we hope that these types of multidimensional simulations can be helpful in finding optimal working points for real accelerators in operation.Allowing multiple adjustable parameters to vary independently is much easier in simulation than in experiment.This kind of analysis may help us to discover working points that may not be obvious when linearly varying one parameter at a time.
For the variation in current of the deuteron beam, we have found that the transmission can be kept at 100% up to the design current and beyond, and that by varying the external quadrupole doublets while fixing the internal quadrupole triplet, the beam halo can also be controlled quite effectively.The variation required for the external electromagnets is quite small, of the order of AE4% of the average field gradient.

Multiple ion species
The next scenario was much more challenging.In order to accept ions with different charge-to-mass ratios, the design called for a variation of the order of AE20% in the internal quadrupole triplet field gradient settings.To investigate whether these different species could be accommodated using fixed permanent-magnet quadrupoles for this internal triplet, we produced a few different variations of the DTL design.Each variation had different internal permanent-magnet quadrupoles, and the rest of the design was optimized around these magnets.Then, for each variation, we reran the optimization procedure described above.
We found that none of the combinations of settings we tested were able to handle all the target ion species effectively.For example, Fig. 6 plots the results for lithium 3þ ions running through a structure optimized for deuterons.Less than 15% of the lithium ions are transmitted, even at the low current specified (7.5 μA).Similar results were found when running deuterons through a structure optimized for lithium ions, and for running protons through either structure.
As we expected, this method will not be enough to handle beams of different ion species, and so we turned to another solution: adjustable permanent magnets.

IV. ADJUSTABLE MAGNET DESIGNS
We investigated two different approaches to adjustable permanent-magnet quadrupoles.The first approach is a hybrid design, using permanent magnets and iron wedges to provide the bulk of the field, with an electromagnetic component to provide the variation of the order of AE20%.The second approach does not have an electromagnetic component, but rather uses two concentric rings of permanent magnets that can move past each other in order to adjust the internal field.The requirements for the magnets are set out in Table II.Equivalent traditional electromagnets have an outer diameter of around 130 mm, so these requirements represent reducing the outer diameter by roughly a factor of two.

A. Hybrid design
The idea of combining permanent magnets and electromagnetic fields into a single hybrid magnet is not new [32][33][34].Our design uses a novel combination of four wedge-shaped iron cores, copper coil windings, and an array of permanent magnets.The layout is shown in Figure 7.
We chose this wedge shape to gather the flux from the permanent magnets and thereby increase the flux density in the central region.We optimized the shape of the wedge to increase the field gradient and improve its uniformity, with the optimization parameters as shown in Figure 7: wedge head length l and widths w 1 and w 2 , and angle of curvature α, where R ¼ w 2 =2 sin α 2 .The number of permanent-magnet segments in this design is 4n þ 8, where n is a parameter that can be optimized.The eight permanent magnets next to the iron wedges are triangular, with the direction of magnetization perpendicular to the surface of the iron.Each quadrant also has n sector-shaped permanent magnets, with the angle of magnetization defined as: where θ i and φ i are as marked in Fig. 8, and δ is another parameter that can be optimized.If δ were zero, the magnetization of each sector-shaped permanent magnet would be perpendicular to the radial direction.The other parameters of the design are also labeled in Fig. 7.The internal radius r 1 and the external radius r 4 were fixed as constraints of the design, and the other parameters FIG. 6. Plot of beam transmission and beam quality for lithium ions based on a design optimized for deuterons.were optimized to produce the desired field gradient with good field homogeneity.The aim was to produce a 75 T=m field gradient with no current applied, and a AE25 T=m adjustable component using a direct excitation current through the coils.
We optimized the quality of the field by minimizing the deviation of the field gradient GðrÞ, that is, minimizing the objective function [34]: where r is evaluated from zero to r 1 and swept around the angle φ.The final parameter values after optimization are listed in Table III.
Our 2D models show that we can produce fields that can vary from around 60 to 100 T=m, within a compact design with an outer diameter of 80 mm.Field gradient homogeneity is good, with a deviation just under 1.2% at a radius of 9 mm.The maximum exciting current density applied in these preliminary models was 50 A=mm 2 , although this could be reduced with further development.The total heat output produced by this current should be much lower than the same current density in a conventional electromagnet,  as the coils are much smaller.However, to meet the temperature constraints, we will still need to include water cooling.
Figure 9 shows the effect on magnetic flux by adjusting this excitation current.The calculated field gradient across the magnet with and without the excitation current is shown in Fig. 10.
The deviation from the nominal field gradient is plotted in Figs.11 and 12.The dominant error term is the eightpole term.The field gradient is slightly too high in front of the iron wedges and slightly too low in the gaps between these wedges, hence the eight terms for the four wedges.The deviation is still within 1.2% at 9 mm.

B. Concentric ring design
The second approach uses two concentric Halbach arrays of permanent magnets, as has previously been suggested for MRI applications [35].Each ring array produces a quadrupole field.The total internal field can be adjusted by rotating the two rings to change the relative angle, reaching maximum field when they are aligned in the same direction, and minimum field when opposing one another.Figure 13 shows the layout of the concentric rings, with the inner ring rotated clockwise through the angle θ 1 and the outer ring rotated counterclockwise through the angle θ 2 .The relative angle between the rings is the total angle θ ¼ θ 1 þ θ 2 .Both rings need to rotate in order to keep the alignment of the combined field axis.
To optimize the field, the inner and outer radii were constrained as above, and the number of permanent-magnet segments per ring was varied.After setting the number of segments, the intermediate radii r 2 and r 3 were set to produce the correct balance of field gradients between the two rings, in order to produce the central gradient of 75 T=m with variability of AE25 T=m.The final parameter values after optimization are listed in Table IV.The magnetic flux through the magnet with different angles of rotation is shown in Fig. 14.
Figure 15 shows how the field gradient depends on the relative angle between the two concentric rings.Figure 16   shows the field gradient when the rings are aligned to produce the maximum field gradient of 100 T=m.
Note that rotating the rings also introduces a torque between them, which will have to be taken into account when designing the mechanism for rotation of the two rings.The torque is proportional to the length of the magnet.Figure 17 shows the torque for the longest quadrupole in the current design, which is 83 mm long.
The homogeneity of the field gradient is better for the concentric design than for the hybrid design.Figure 18 shows the homogeneity in both the radial and azimuthal directions.The dominant error term is the 48-pole term, as there are 24 permanent magnet segments per ring.The deviation is less than 0.2% at a radius of 9 mm.The concentric design also has the advantage of not requiring a cooling system, and is slightly smaller, with an outer diameter of 72 mm.
The mechanical design of the concentric quadrupole is challenging due to the requirements on miniaturization and accuracy of the motion.Figure 19 shows a possible mechanical design, with each ring of permanent magnets being supported by a thin sleeve, rotating coaxially on two pairs of ball bearings.The right end of each sleeve is equipped with a gear.The power for the rotation is provided by a servo motor placed at the one end and transmitted through a small gearbox system, which are not shown in the figure .We have also carried out some preliminary error studies on the alignment of the two concentric rings, which will affect the field gradient flatness.When the two rings have  an eccentricity error of 0.1 mm, the deviation will increase slightly from 0.2% to 0.4% at a radius of 9 mm.More detailed error studies will be required as the magnet design is further developed.With both of these designs, from the two-dimensional models tested so far, we can produce all the required variability to handle not only the space-charge effects for the deuteron beam, but also the changes required for accelerating ion beams with different charge-to-mass ratios.The hybrid design offers the advantage of fast adjustment times, whereas the concentric design has the advantages of a fully permanent-magnet design.Both designs are significantly more compact than fully electromagnetic designs.V. CONCLUSIONS We have investigated two rather different solutions to the problem of reducing the size of internal quadrupole magnets in an IH-DTL.The first solution involves fixing the field of the internal magnets and optimizing external magnets to handle the required changes in beam dynamics.The second solution involves using adjustable permanentmagnet quadrupoles within the internal triplets.
To this end, we have created some scripting code for automatically running multiple LORASR simulations with parameter sweeps, and developed some multidimensional analysis tools for handling the resultant data sets.We have also produced conceptual designs for two new adjustable quadrupole structures using permanent magnets.
We found that the fixed-internal, adjustable-external method is successful in handling the range of beam dynamics required for a high intensity accelerator for a single ion type.Our simulations retained a transmission of 100%, with minimal beam halo effects, when ramping a deuteron beam from zero current to 10 mA in CW operation.This method should be applicable to a wide range of accelerator applications.However, it is not flexible enough to handle ions with different charge-to-mass ratios.
Our designs for adjustable permanent-magnet quadrupoles have enough flexibility to handle different ion species, while still being significantly smaller than conventional fully-electromagnetic quadrupoles.The two different magnet designs have different advantages, suiting different applications.The hybrid magnet can cope with fast changes of field gradient, suitable for designs where the beam dynamics can shift quickly and needs to be computercontrolled to compensate.The concentric ring design uses only permanent magnets and small motorized components, which helps reducing the power consumption and cooling requirements.
The next steps for these investigations will be more detailed three-dimensional modeling of the adjustable permanent-magnet designs, leading to prototyping and testing of the accuracy of our models.We will have to consider the motorization and control scheme for the concentric ring design, and ensure that the system can handle the induced torque.We also need to consider the radiation-hardness of the design for application to highintensity deuteron beams.

FIG. 3 .
FIG. 3. Plot of maximum beam quality at different values of deuteron beam current.

FIG. 8 .
FIG. 8. Angles of magnetization for a single quadrant of the hybrid magnet design.

FIG. 10 .
FIG.10.Field gradient in hybrid magnet design when adjusting excitation current.

FIG. 15 .
FIG.15.Dependence of field gradient on relative angle between the two concentric rings.

TABLE I .
Linac design parameters for deuteron beam.

TABLE II .
Target requirements for magnet designs.
FIG. 7. Layout of hybrid magnet design.

TABLE III .
Parameters of hybrid magnet design.

TABLE IV .
Parameters of concentric magnet design.