A spatially periodic magnetic field is essential to cause an electron beam to wiggle and to emit electromagnetic radiation in a synchrotron (SR) source of radiation, and to provide fully coherent light in free electron lasers (FEL). To create this field, permanent magnets (PM) or electromagnets are patterned in a device commonly called an insertion device for SR and a radiator or modulator for FEL. In reality, magnet blocks or iron poles are not identical, in terms of geometry and magnetic properties, even with progressive manufacture. Compensatory methods are thus desired to recover the magnetic field and also to decrease the duration of construction. Magnet sorting is a pre-process that aims to eliminate the effect of manufacturing error. Before assembly of an insertion device, data of each component, especially the magnetic properties of each magnet block and the gap variation of mechanical structure, are organized to optimize the performance of the magnetic field. After that process, there is sometimes an optimization to shim the magnetic field. An effective algorithm of both processes is significant, particularly for a long undulator and an elliptically polarized undulator (EPU).An APPLE-II EPU comprises four PM arrays of Halbach type [1]. This device provides variable polarization of radiation via symmetric or antisymmetric movement of arrays [2]. In addition to a greater number of magnets than a normal planar undulator, an APPLE-II EPU suffers from magnetic forces of various kinds operating in varied phase modes; this condition becomes a challenge for mechanical design and field optimization. In total, 10 undulators will be installed in phase I at the Taiwan Photon Source (TPS). Among these, three are EPU; they will provide photon energy in a range from 0.25 or 0.45 to 2 keV for horizontal or vertical linear (HL/VL) mode and 0.3 to 1.5 keV for circularpolarization (CP) mode.
Magnet sortingThere are two main requirements for an insertion device: to achieve the desired properties of radiation and to have no net effect on an electron beam. To realize the first objective, the magnetic field needs to have a purely periodic distribution. Radiation emitted from each pole has a correct correlation, resulting in a constructive interference. The phase error describes the deviation of the phase between a real device with field error and an ideal one at each pole [3,4]. The rms phase error, which has been shown to be well-correlated with the spectral intensity, must thus be minimized [5]. The first and second field integrals represent the exit angle and position of the electron beam, respectively. For the other objective, these field integrals in transverse directions must be minimized to effect a negligible multipole error. How to arrange thousands of magnet blocks to fulfill multiple requirements is the task of magnet sorting.Magnet sorting is a multi-objective problem of optimization. The best arrangement, which implies a global minimum of the configuration space, can be found if every possible combination is teste...