Optimization of the undulator period in the K vs period with flux vs energy spaces.
IGOR Pro
U4Opt: Undulator plot for the period optimization
Introduction
The undulator is an insertion device used to generate the synchrotron radiation at a higher flux density than that from the bending magnet radiation. The photon energy ($hc/\lambda$) from the undulator depends on the electron beam energy ($0.000511\gamma$ GeV), harmonic number ($n$), undulator period ($\lambda_u$), polar angle from the undulator axis ($\theta$), and $K$ parameter which is based on the $\lambda_u$ and peak magnetic field ($B_0$; in the sinusoidal field approximation).
$B_0$ can be designed in the magnet height ($h$) and magnetization ($B_r$), and tuned in the magnetic gap ($g$) and temperature. The minimum gap is basically limited in the dynamic aperture of the storage ring lattice, and the maximum gap is limited in the mechanical structure of the undulator. Various magnetic types and structures are available in the advanced synchrotron facilities.
The deviation from the sinusoidal field appears owing to the finite number of trapezoidal magnet blocks in a period ($M$). In particular, the hybrid short period undulator deforms the sinusoidal field because the high peak field strength at the small pole materials. The photon radiative field can be analyzed in the Fourier transform as described in elsewhere by Takashi Tanaka.
Here, even if $\beta (z)$ is not sinusoidal, the effective $K$ should be obtained in either the numerical integration of the field as shown above or the discrete Fourier transform (DFT) analysis within a period $\lambda_u$.
For a simplity in the DFT analysis, assume $B_x$=0, so $\beta_x$ is formulated as below.
$$\beta_x (z) = {e \over \gamma m c} \sum_{n=1}^{n_{\mbox{odd}}} {\beta_n} \sin(2 \pi n z / \lambda_u)$$
$K_n$ is described in terms of $\beta_n$, and effective $K$ can be evaluated.
The flux ($F$) from the undulator depends on the the electron beam current ($I$ amps), total length ($L$), $\lambda_u$, $n$, and $K$. The flux over the central cone ($\sqrt{\lambda/L}$) at the harmonic $n$ and number of periods $N$ ($=L/\lambda_u$) in the band width ($\Delta \omega/\omega=0.1$ %) is
$${\partial F \over \partial (\Delta \omega/\omega)} = 1.431 \cdot 10^{14} \cdot N \cdot Q_n(K) \cdot I$$
The maximum $K$ value is correlated with the lowest energy as well as highest $F$ at a particular $n$. The photon energy extends toward a high energy as the $n$ increases at every odd $n$. However, the energy is not tunable between 1st and 3rd harmonics if $K$ is less than 2, because the wavelength of radiation $\lambda_1$ at $K=0$ is equal to $\lambda_3$ at $K=2$ on axis $\theta = 0$ as shown below.
U4Opt discloses these complex relationship among the parameters above. Users comprehend the principle of the undulator at a glance in two plots and tune the periodic length interactively.
Background
The undulator period can be optimized in the plot based on the magnet type, gap, flux. To design the undulator specification in the synchrotron facility, U4Opt has been developed. The first prototype of the program is based on the Excel spreadsheet, and transfered to the macro in Igor Pro. Python code is now available. The coding is in progress, not well documented, but open for public for review.
The first concept of K-period space analysis originates from the talk of Dr. Markus Tischer (DESY) in the ID23 workshop.
Magnet
The magnetic configuration can be selected in the pop down list. Users can tune the parameters from the default values in either ($a, b, c$) or ($B_r, M, h$) configuration. APPLE-II is based on the $B_r = 0.62$ expirically. The magnetic field can be approximated in the following equations;
$$B_0 = a \cdot \exp \left[{g \over \lambda_u} \left( b + {g \over \lambda_u}c \right) \right]$$
by K. Halbach, Nucl. Instrum. Methods 187, 109 (1981) for a pure permanent magnet (PPM). $M$ represents the number of magnets in a priod, and $h$ the height of magnet. The higher order magnetic field appears upon $M$. The effective magnetic field or K can be evaluated in the Fourier transform of the field simulation in the Radia or in-situ measurement in magnet arrays.
Preset
Users can import and export the parameters as a preset (.dat) in Python version.
Non-linear effects
No emittance or energy spread are taken into account resulting in the single electron and Gaussian beam approximation. Further optimization including the end-magnet, phase error, and betatron function should be conducted in SPECTRA or SRW. Takashi Tanaka formulates the universal representation of phase errors.
Jui-Che Huang describes the average brilliance by using electron beam emittance ($\epsilon$), radiation emittance ($\epsilon_r = \lambda /4\pi$), radiation wavelength ($\lambda$), undulator length ($L$), betatron function ($\beta$), and $\zeta = 2\pi \beta/L$.
Here, $\sigma_{\gamma} / \gamma$ represents the energy spread.
Limitations
No warranty of U4Opt without errors. Python and Igor Pro work in the same manner, but Igor Pro runs faster than Python does. The data can be handled in Igor as a wave within the program and transformed in further analysis.
Setup
Python (tested in Windows and macOS)
Install Python3 and pip3 install numpy, scipy, PyQt5, matplotlib, and reliability.
Download this repository and run the main.py under the Python folder.
python3 main.py
Igor Pro version 8 or 9 (tested in Windows and macOS)
Open the procedure file, then compile it. Undulator is available in the macro menu. Select the plot in the popup menu of U4Opt interface.
MPW and BM radiations
The flux of multi-pole wiggler (MPW) and bending magnet (BM) radiation can be added in Igor version. The flux of MPW is limited at the horizontal acceptance angle of 1 mrad. The magnet type and periodic length of MPW are equivalent to those used in the undulator. The magnetic field of BM is evaluated from the beam energy because the circumarence is roughly proportional to the beam energy (Lightsources2018.csv). The on-axis angular flux density of BM is caluclated in