Real-time Accelerator Diagnostic Tools for the MAX IV Storage Rings

In this paper, beam diagnostic and monitoring tools developed by the MAX IV Operations Group are discussed. In particular, new beam position monitoring and accelerator tunes visualization software tools, as well as tools that directly influence the beam quality and stability are introduced. An availability and downtime monitoring application is also presented.


I. INTRODUCTION
The MAX IV laboratory [1] is a synchrotron radiation facility in Lund, Sweden. MAX IV is the first Multi-Bend Achromat (MBA) Synchrotron Light Source in the world and provides scientists with the most brilliant X-rays for research. The laboratory was inaugurated in June 2016 and consists of two storage rings operated at 1.5 and 3 GeV providing spontaneous radiation of high brilliance over a broad spectral range. The 1.5 GeV ring has a circumference of 96 m and employs a double-bend achromat lattice to produce an emittance of 6 nm rad. The 3 GeV storage ring on the other hand is aimed towards ultralow emittance to generate high brilliance hard X-rays. The design of the 3 GeV storage ring includes many novel technologies such as MBA lattice and a compact, fullyintegrated magnet design. This results in a circumference of 528 m and an emittance as low as 0.2 nm rad [2]. A linear accelerator (linac) works as a full-energy injector for the storage rings as well as a driver to a Short Pulse Facility (SPF). The prime sources for synchrotron radiation at the rings are optimized insertion devices (IDs), providing intense X-ray light for each of the MAX IV beamlines.
This article is organized as follows. Section II briefly summarizes the nominal operation conditions of the storage rings and of the SPF. In Section III a new software tool which displays the beam position's evolution over time and the accelerator tunes' evolution over time using two-dimensional colormap spectrograms is presented. A tool that reduces the impact of changing orbit bumps for the MAX IV beamlines is presented in section IV. Section V introduces an application for adjusting the master oscillator's radio-frequency of a storage ring that is nearly transparent for beamlines. Section VI describes the MAX IV downtime web-application used for registering and monitoring the availability and downtime of the MAX IV accelerators with automatized plotting capabilities allowing for prompt statistical analysis of events. Conclusions are presented in Section VII. * bernhard.meirose@maxiv.lu.se

II. MAX IV ACCELERATOR OPERATIONS
The MAX IV storage rings [3] currently operate in a 30 minute top-up injection mode during user delivery. High bunch charge is delivered to the SPF in-between injections. Although both rings are filled in 30 minute intervals, different injection modes are used. In the 1.5 GeV storage ring injections are accomplished using a single dipole kicker magnet, which although efficient [4], is not transparent to users leading to betatron oscillations of the stored beam with amplitudes of the order of several millimeters. In the 3 GeV storage ring a Multipole Injection Kicker (MIK) method is used, which delivers quasi-transparent injections with good capture efficiency [5]. Under nominal conditions the 3 GeV storage ring operates with 166 filled RF buckets, out of a maximum (harmonic number) of 176, while the 1.5 GeV ring operates at 32 even-filled RF buckets.
Both storage rings employ passive harmonic (Landau) RF cavities [6]. The main function of the harmonic cavities is to generate a voltage which counteracts the longitudinal focusing at the bunch center of the main RF voltage, lengthening the bunch, decreasing the charge density, thus damping instabilities and increasing the Touschek-dominated lifetime.
The 3 GeV and 1.5 GeV rings make use of a number of feedback systems to deliver stable and reliable beams. These include main cavity field amplitude and phase, main cavity frequency and Landau cavity field amplitude, all implemented in an FPGA-based low level RF-system [7]. The 3 GeV ring uses also feedback to damp Robinson mode oscillations [8]. A digital Bunch-By-Bunch (BBB) feedback is used to damp coupled bunch modes and as a diagnostic tool [9,10].
A slow orbit feedback (SOFB) [11] loop is used in both storage rings to handle drifts. The main goal of this is to keep the electron orbit as constant as possible at all times. Using information from the BPMs, which measure the transverse position of the beam along the storage ring, dipole corrector magnets currents are adjusted so that the beam orbit is corrected towards offsets or a predefined golden orbit [12]. The SOFB loop updates at a 10 Hz rate.  A feedback system that acts directly on the accelerator radio frequency master oscillator (MO RF) is used in order to keep the energy contribution from the storage ring's corrector magnets constant. In the 1.5 GeV ring a tune feedback is used in order to keep the betatron tunes close to a predefined optimal value. While the tune feedback system itself makes use of the ring's quadrupole magnets and pole-face strips that are installed in dipole magnets as actuators, the betatron tunes are themselves obtained by the ring's BBB system. The main feedback systems used at the MAX IV storage rings are shown in table I. For completeness, a summary of key delivery parameters for the 1.5 and 3 GeV storage rings are presented in tables II and III, respectively.
The current nominal operation conditions for the SPF [13] aim at delivering 100 pC charge per bunch at a repetition rate of 2 Hz. To achieve this, electrons are extracted from a copper photo-cathode using a laser pulse, then accelerated to 3 GeV. The bunches are compressed  in two stages, at 233 MeV and at the full 3 GeV, to about 100 fs. Then the beam goes through the two undulators of the SPF, generating equally short x-ray pulses. As in the rings, there is a feedback on the trajectory, keeping the beam at the center of the optics. Figure 1 shows the facility status in November 2019. The status page shows the current stored in the two storage rings and the charge delivered to the SPF at present time and the evolution of the stored current during the previous 12 hours. It also shows the positions of the undulator gaps and the status of the beam shutters at all beamlines. A closed gap means that synchrotron light is produced by a beamline's insertion device whilst open shutters, indicated by highlighting the beamline name in green, means that the beamline is open to take the light produced by its insertion device. As can be seen from the plot, the linac performed excellently as injector providing beam current top-up every 30 minutes, as well as high bunch charge (100 pC) to the SPF.

III. BEAM POSITION MONITOR TIME EVOLUTION
The Beam Position Monitor Time Evolution (BPM trends) is a tool developed by the operations group that shows the storage rings' beam positions over time (a realtime "sliding plot" during operations) as measured by all the rings' BPMs. The vertical scale on the right (in µm) controls whether there is any deviation within the lower and upper limits set by the scale. Figure 2 shows a typical example of stable delivery, where all BPM readings show the beam is kept within the required limits (within 0 µm to ±0.3 µm, in this case) and are therefore shown in green. When the deviation is above the upper limit (0.3 µm) the points are shown in red. An illustration of this fact is demonstrated in Figure 3, where one can observe that small changes to one of the beamline's gaps in the 3 GeV storage ring can cause visible disturbances to the beam. In Figure 4 it is noticeable that during injections a large vertical line can be observed in the 1.5 GeV ring BPM trends, due to the significant disturbances caused by the dipole kicker that it is used in the smaller ring. A similar line is not observed in Figure 2 as the 3 GeV ring makes use of the MIK.
The tool allows also the possibility of switching mode between "BPM-space" and "corrector-space", the former being the positions measured by the BPMs, and the latter being the BPM positions transformed through the orbit response matrix (ORM) to the angular kicks at the corrector magnets that would result in the observed orbit distortions. The ORM is normally used for the feedback system to calculate corrector magnet strengths, and by the same logic, it is possible to use the ORM to locate where kicks on the beam are originating from.
Two-dimensional colormap spectrograms are also useful to monitor the synchrotron and betatron frequencies variations measured by the BBB system [9,10] and, therefore, a useful tool to monitor the accelerator's tunes. At times when there are disturbances of the same order as the frequency of the tunes, the spectrograms convey a clearer image than just observing the tune value. Figure 5 illustrates a typical use case. At approximately -40 min, the MO RF of the 3 GeV storage ring is manually increased in an attempt to change the vertical tune closer to its delivery set value (0.265). The MO RF changes are done in 5 Hz steps, which is visible in the staircase decrease of the vertical betatron frequency. At -5 minutes one of the beamlines closes its undulator gap, causing the tune to shift, which is clearly visible at right end of the plot. An example of the use of this tool to diagnose faulty equipment is given in Figure 6. Between -80 and -40 min, a disturbance can be seen around the tune frequency. At -40 min a faulty amplifier connected to an alternative tune measurement system was turned off. This vertical disturbance caused an increase in vertical emittance, which decreased to nominal values as soon as the disturbance moved away from the tune frequency.
The tool also provides a good way to visualize whether the beam is behaving as expected in all planes of space. Figure 7 shows the longitudinal and transverse frequencies for the 1.5 GeV storage ring. In the longitudinal plane (synchrotron frequency) one can see the effects of the top-up injections every 30 minutes. In the vertical plane (middle plot) one can see the signal is strongest around 350 kHz, but lines for higher and lower frequencies, albeit weaker, can be seen, which is consistent with the synchrotron sidebands of the betatron frequency measured by the BBB system. A similar, but less pronounced effect can be observed in the horizontal plane (bottom plot). Such plots can be constantly monitored during beam delivery, and should significant deviations on the shown patterns be observed in any of the planes, actions can be taken to improve beam quality and prevent beam losses.

IV. WOBBL
Changes to the orbit of the beam through the long straight sections of the storage rings where the insertion devices are situated, are sometimes requested by beamline users at MAX IV during normal operation.
The implementation of such orbit bumps is done by changing the reference orbit to which the SOFB corrects the beam. Manual implementation of a beamline bump results in an abrupt disturbance of the stored beam, which is not transparent to the users at the beamlines.
In order to accommodate beamline bump change requests without disturbing the measurements performed at any of the other beamlines, a Widget for setting the Orbit Bumps for BeamLines (WOBBL) has been developed within the operations group.
WOBBL implements changes to the reference positions for the SOFB in a series of sub-micrometer steps at a repetition rate which is lower than that of the feedback system. This allows the orbit to be corrected in-between each step change. The result is a smooth transition from the initial orbit to the desired final orbit. Figure 8 shows the WOBBL interface which is used to implement the beamline orbit changes non-disruptively. The WOBBL interface shows the beamlines which are in normal operation for the 3 GeV ring and also the MIK. The widget has input fields for setting each of the four types of bump changes, for each beamline. Via the widget it is also possible to get a read-back of the positions and angles through the insertion devices, as picked up by BPMs in the ring. Both the step size and repetition rate are available as input settings.
In order to determine the effectiveness of the WOBBL tool in a controlled manner, studies were performed for the NanoMAX [14] beamline, one of the most instabilitysensitive beamline at the MAX IV laboratory. During the measurements, the bumps for another beamline (BioMAX [15]) were changed both directly and via the WOBBL tool and compared. Figure 9 shows the horizontal position observed by NanoMAX. At t = 129 s, the vertical angle of the BioMAX beamline is directly increased by 68 µm. While disturbunces in the horizontal plane are relatively small, a significant positive vertical displacement can be seen in Figure 10. At t = 190 s, BioMAX'S horizontal angle is now decreased by 68 µm and, consistently, a negative displacement is seen by the beam delivered to NanoMAX. At t = 265 the horizontal angle is increased, and subsequently decreased (at t = 312 s), but since the changes are performed in a perpendicular plane, the disturbances are much less pronounced. Other horizontal (t = 427 s) and vertical (at t = 498 s and t = 559 s) bump changes are done directly at BioMAX and again the effects are consistently visible. In Fig. 10 it is noticeable that all the direct vertical changes mentioned for the BioMAX's bumps are unsurprisingly more visible for NanoMAX's measured vertical position, while the horizontal changes appear as small perturbations. Figure 11 shows for comparison the horizontal position measured by NanoMAX during a period of approximately one hour, during which several changes (also of   It is worth mentioning that during the nearly one hour of data taking, NanoMAX's observed beam position drifts downwards by nearly 20 µm, but such a deviation is within the normal limits of perturbations observed at the NanoMAX beamline, considering the period of observation, and cannot, therefore, unambiguously be attributed to the WOBBL tool or disentangled from other possible causes, such as for example, temperature changes.

V. SOFT MO RF SWEEPER
The soft MO RF sweeper is a tool for changing the MO RF of a storage ring in combination with an orbit feedback system. With this tool, changes in the MO RF can be carried out without significantly affecting beam instability-sensitive beamlines as the adjustments made in each step are carefully set up such that the beam instabilities arising from the MO RF adjustments are as small as the regular beam oscillations. As with the WOBBL, each adjustment also gives time for the orbit feedback system to adjust the beam orbit after adjusting the MO RF. This is accomplished by fulfilling two conditions: a) at least one second has to elapse and b) at least five iterations of beam trajectory corrections has to be carried out before the next MO RF adjustment is done.
At the two MAX IV storage rings, it was found that MO RF adjustments of 0.05 Hz results are practically undetectable by beam instability-sensitive beamlines. The simple graphical user interface (GUI) of this tool shows which storage ring is selected, the current MO RF and  In Figure 12, the difference between applying a change of 5 Hz directly and via the soft MO RF sweeper is visible from the 1.5 GeV storage ring beam data. At time instants when the MO RF is directly increased by 5 Hz (21:05) and decreased by 5 Hz (at 21:07) a large deviation in beam position is measured by the 1.5 GeV storage ring BPMs', both in the vertical and horizontal planes. At 21:10 the same 5 Hz increase is applied to the MO RF, followed by a 5 Hz decrease at 21:21, both via the sweeper -disturbances to the beam orbit are then barely seen. This preservation of stability that is accomplished with the MO RF sweeper is crucial during delivery for the experiments measurements to be carried out without disturbances. As with the WOBBL tool, the effect can be observed for NanoMAX, as shown in Fig. 13. At t = 50 s the MO RF is increased directly by 5 Hz which can be observed both at NanoMAX's measured beam horizontal intensity, as well as in its measured beam horizontal position. The beam intensity decreases abruptly and significantly before rising again, as a result of MO RF increase, while the horizontal position oscillates as much as ∼ 150 µm (a similar effect is observed in the vertical plane, but is not shown). At t = 174 s, the MO RF is decreased by 10 Hz directly and once more a large disturbance in the delivered beam for NanoMAX is observed for both quantities. At 285 s the MO RF starts to be increased towards a total 5 Hz change using the sweeper. The effect is observable as a subtle drop in the horizontal intensity at the recorded change time, which starts increasing again during the approximate 5 minutes it takes the MO RF to reach its new desired value. The change is not noticeable in the horizontal position plot in Figure 14, which is a strong indicator of the sweeper's usefulness during beam delivery.

VI. AVAILABILITY AND DOWNTIME MONITORING
In order to improve the gathering of statistics concerning downtime duration and facilitate reliability studies, a "downtime web-application" was developed [16]. This application has since its deployment proven itself useful for analyzing the different downtime events and for finding ways to prevent similar incidents in order to further reduce downtime. The application allows operators to   chine protection system, network, orbit interlock, programmable logic controller, personnel safety system, radio frequency, vacuum, water, WatchDog (software), or others, if the cause is unknown or no existing label is well suited.
The database can be downloaded as a CSV file and analyzed in further detail. The heatmap in Figure 16 shows number of downtime events by code and week number for all three systems (I, R3, R1). The histograms on the margins are the projections of the heatmap onto the x and y-axis. The histogram on the right margin shows that certain event types are more frequent, and the upper histogram highlights how the downtime is distributed across the run period. The heatmap in Figure 17 shows the distribution of downtime events across days and hours (the hour during which the downtime started). The upper histogram shows that downtime is more likely to occur   Figure 15 shows that a beam availability of 98.4% was achieved for the 1.5 GeV storage ring (with 60h of Figure 13: NanoMAX's horizontal beam intensity. At t = 50 s the MO RF is increased directly by 5 Hz. The beam intensity decreases abruptly and significantly before rising again, as a result of MO RF increase. At t = 174 s, the MO RF is decreased by 10 Hz directly and once more a large disturbance in the delivered beam for NanoMAX is observed. At 285 s the MO RF starts to be increased towards a total 5 Hz change using the sweeper. The effect is observable as a subtle drop in the horizontal intensity at the recorded change time, which starts increasing again during the approximate 5 minutes it takes the MO RF to reach its new desired value. Figure 14: NanoMAX's horizontal beam position. At t = 50 s the MO RF is increased directly by 5 Hz. The horizontal position oscillates as much as ∼ 150 µm as a result of MO RF increase. At t = 174 s, the MO RF is decreased by 10 Hz directly and once more a large disturbance in the delivered beam for NanoMAX is observed.
At 285 s the MO RF starts to be increased towards a total 5 Hz change using the sweeper, which takes approximately 5 minutes, but the change is not noticeable in the plot.
MTBF) and of 98.0% for the 3 GeV ring (with 40h of MTBF) during the first half of 2019. This can be compared to a beam availability of 96.7% for the 1.

VII. CONCLUSION
Several applications developed by the MAX IV accelerator operations group were presented. Most of the tools are for monitoring purposes, but the group has also developed software that directly improved the beam stability seen by the beam users. Specifically, the following software tools were presented: (i) a tool which displays the beam position's evolution over time and the accelerator tunes' evolution, (ii) a tool that reduces the impact of changing orbit bumps for the beamlines, (iii) an application for adjusting the master oscillator's radio-frequency of a storage ring that is nearly transparent for users, and (iv) the downtime web-application used for registering and monitoring the availability and downtime of accelerators. The development of these programs have significantly improved accelerator operations at the MAX IV laboratory.