Research on the simulation environment of hard X-ray nanoprobe beamline station

In the hard X-ray nanoprobe beamline station, experiments need to be performed by adjusting the optical equipment in order to obtain good beamline performance. Due to many factors, only through the use of intelligent optimization, the beamline performance can be quickly improved. Therefore, an intelligent optimization method is proposed in this work to improve the performance of the beamline rapidly by using an adaptive algorithm to optimize the motor shaft of each device. Moreover, this paper introduces the simulation environment of the hard X-ray nanoprobe beamline equipment. In this environment, a multi-axis parallel optimization model of several optical devices is designed, and the ionization chamber feedback is replaced by Rastrigin function. Furthermore, the differential evolution algorithm is used to verify the model. The optimization tests of multiple devices in the beamline are carried out, and the automatic optimization of the devices is realized. As for the theoretical result, the designed intelligent beamline optimization program is capable of converging to the optimal value within 3-6 minutes on the simulation platform, this automated process could potentially enhance beamline adjusting efficiency by 10-20 times compared to manual beamline adjusting.


Introduction
The Hard X-ray Nanoprobe beamline station (BL13U) is an important construction project in the field of synchrotron radiation, which requires the X-ray beam to achieve 10 nm spatial resolution and 2 nm motion scanning repetition accuracy.This station provides experimental methods including nanobeam fluorescence, nanobeam absorption, nanobeam diffraction, and coherent diffraction imaging.Its completion will provide nanoscale detection and experimental capabilities, allowing for cutting-edge research in materials science, life science, and environmental science [1][2][3].
Before the synchrotron radiation experiment, each device of the beam line should be adjusted to the optimal state to meet the experimental requirements.Manual operation of engineers is currently the primary method employed to optimize beamline regulation.However, due to the uncertainty of factors affecting beamline performance and the limitations of engineers' experience, the efficiency of beam modulation by manual methods cannot be guaranteed at all times.
The application of intelligent control technology can facilitate the automatic optimization and adjustment of the beamline, which can significantly improve efficiency.Studies on intelligent beamline adjusting based on a differential evolution algorithm have been conducted in other stations of the Shanghai Light Source [4,5].However, the initial position of each regulated motor needs to be randomly initialized at the beginning of each beamline adjusting stage, which reduces the practicability of the intelligent beamline adjusting system.This paper proposes the use of Experimental Physics and Industrial Control System(EPICS) [6,7] software to simulate the motor control system of BL13U beam line equipment and design an intelligent beamline adjusting algorithm based on differential evolution.The proposed algorithm is tested on the simulation platform and shows effective and fast convergence on the motor simulation platform.The simulation platform enables the study of the intelligent beamline adjusting algorithm before the completion of the online station and allows for offline beamline adjusting exercises after completion.

Hard X-ray nanoprobe beam-line simulation environment
In EPICS, Simmotor is an Input Output Controller (IOC).The simulation environment includes a bottom IOC motor frame based on Simmotor and a top Operator interface (OPI) display interface dedicated to the nanoprobe beamline station device.

Motor motion shaft
The controlled equipment of the beam-line part includes: a collimator (HCM), double-crystal monochromator (DCM), a multilayer monochromator (DMM), and a pre-focusing mirror (PFM) to realize synchrotron radiation collimation, wavelength screening, focusing, and transmission.More, the optical attitude of the device determines the beam performance after processing.Therefore, several beamline devices provide a rich optical motion attitude due to the differential asymmetrical motion of each motor.Hence, as shown in Figure 1, the double-layer monochromator, where the motor is controlled, changes the light beam.

Visual GUI interface
The real-time optimization process of the motor motion axes of each optical component of the BL13U beam line needs to be reflected by visual feedback.The optimization process is to improve multiple motor motion axes in parallel.There, the OPI interface is realized through the directional design of Phoebus software.

Motor shaft frame based on Simmotor
BL13U beamline station is composed of three modules: the front-end area, the beamline, and the experimental station.The motor motion of the beamline is established by Simmotor as shown in Figure 2.
In the nanoprobe beamline section, multilayer monochromator and double-crystal monochromator are used interchangeably, under certain conditions, but they are not running simultaneously.According to the functional division, each optical element has its specific motor composition, and the corresponding record is created in Simmotor to generate the required motor motion shaft according to its frame.The motor shaft of the controllable device is shown in Table 1.In the software logic structure, shown in Figure 3, starting or stopping the device optimization task is available in the display screen.Moreover, the program realizes the interaction with the and EPICS system through PyEpics interface.Through the control of the VAL domain, the optimization algorithm can control the motor to move towards the target position, and get obtain the read-back value of the motor position after the movement throughout the RBV domain [8].

Parallel optimization algorithm
The Differential Evolution (DE) algorithm [4,9] simulates the biological evolution, retains the iterative and adaptive individuals, has strong global convergence and robustness, and is suitable for solving complex optimization problems that cannot be treated using the traditional mathematical programming.
This algorithm is suitable for the parallel optimization of multi-device beam line.Moreover, suppose there are NP individuals in the population, and the information of individuals is in the Dim dimension vector, the following relation can be applied:   ,  ,  1,2, … , ;  1,2, … ,  (1) where GEN is the evolutionary algebra of the population, starting from the zeroth generation that is randomly generated.Assuming that the upper and lower thresholds of the j th dimension vector of the i th individual are  and  , respectively, the initial dimension vector is represented as follows: Where CR is the crossover probability parameter, and the crossover operation is carried out at the vector level.Individuals with high fitness levels are upgraded to the next generation, while those with low fitness levels are discarded.To sum up, the selection operation is as follows: Figure 4 depicts the motor optimization process of the Differential Evolution Algorithm, which primarily consists of the following steps: (1) The differential evolution algorithm generates the next generation population; (2) After transferring the population parameters to the software motor, it is then driven to move to its designated location.
(3) The results of the motor motion are sent back to the operator interface (OPI) at the top layer, where the OPI operator can review them.

Simulation experiment verification
The algorithm runs in the simulation environment and drives the controlled motor to achieve the optimization effect after each iteration.The simulation environment lacks the feedback of the ionization chamber in the actual scene to form a closed-loop control, so it is necessary to build a complex feedback function in order to replace the feedback of the ionization chamber.The standard test function Rastrgin is selected as the fitness function, and it is defined as follows [5]: ,  20  10 cos 2  10 cos 2 5 ,  5 (6) The three-dimensional visualization of function is shown in Figure 5.One can identify the regular symmetric mirror peaks on the curved surface.However, by adjusting the position of the function interval of the decision variable, the global maximum value is not unique; therefore, the function tends to the minimum value within the interval.This shows that the intelligent control method based on the differential evolution algorithm proposed by us can make the entire population converge to the global optimal solution in the simulation model.Compared to traditional manual beamline adjusting, which takes several hours, our simulation test indicates that the optimization efficiency using this method is at least 10-20 times higher.Therefore, this method significantly improves the intelligent optimization efficiency of the BL13U.However, since the algorithm requires optimization from scratch each time, there is still room for improvement in terms of using optimization experience.

Conclusion
The parallel optimization simulation environment of optical element on hard X-ray nanoprobe beamline is designed, realized, and verified through this work.The results show that, while optimizing the finite algebraic algorithm, the feedback function can converge to the global optimal result; therefore, each motor shaft of the controlled device can be optimized to the best position.The simulation experiment verifies the correctness of parallel optimization in the simulation environment, and reduces the workload and time of optimization compared with the traditional manual online testing, and provides valuable experience for the online testing of the nanoprobe beamline equipment in the future.As for the future works, how to effectively use the experience of each optimization can be applied to enhance this work.

Figure 5 .
Figure 5. 3D visualization of the Rastrigin function.In this paper, equipment HCM, DMM, DCM, PFM as well as HCM-DMM-PFM and HCM-DMM-PFM are selected to conduct the simulation environment test of the algorithm, and verify its effectiveness through simulating the model optimization.Finally, the test results are shown in Figure6.In more detail, Figures.6(a) to 6(f) show the relationship between the target value and evolutionary algorithm of each optimized device during the optimization process.The blue line indicates the average value of the entire population, while the yellow line represents the optimal individual value within the population.The results indicate that the algorithm can reach the optimal result within a finite number of iterations.However, if the algorithm architecture remains unchanged and the number of motor shafts increases, it takes longer for the algorithm to converge -usually about 3-6 minutes.This shows that the intelligent control method based on the differential evolution algorithm proposed by us can make the entire population converge to the global optimal solution in the simulation model.Compared to traditional manual beamline adjusting, which takes several hours, our simulation test indicates that the optimization efficiency using this method is at least 10-20 times higher.Therefore, this method significantly improves the intelligent optimization efficiency of the BL13U.However, since the algorithm requires optimization from scratch each time, there is still room for improvement in terms of using optimization experience.

Table 1 .
Name of motor shaft included with each device.