Visual Component Library of Delphi2 is used extensively for GUI programming. 2.3 Physics Class Library. The modeling and simulation kernel of the original.
ACCELERATOR MODELING AND CONTROL USING DELPHI ON WINDOWS NT* Hiroshi Nishimura Lawrence Berkeley National Laboratory University of California, MS 80-101 Berkeley, California 94720. USA A third generation electron storage-ring requires precise and stable orbit control which is usually based on various kinds of modeling and machine studies. Tracy V is an interactive tool designed to carry out accelerator modeling, simulation, machine studies, and data analysis in a consistent manner. This paper describes the development and the application of Tracy V based on the experience at the Advanced Light Source.
1. INTRODUCTION The Advanced Light Source1 (ALS) has been operating for users' since the completion of the commissioning in 1993. The requirements for beam quality, especially orbit stability, have become more stringent as the storage ring performance has been gradually improved. In order to meet these needs, the roles of modeling and simulation studies have become more important, and new software tools have had to be developed. ALS machine control system2 was originally designed to use PCs running Windows 3.1 as consoles. During the machine commissioning period, on-line programs were written taking advantage of wide variety of development tools available on Windows 3.1. Today, console PCs are running Windows NT with wider memory space and WIN32 multi-tasking and networking functions. New programs have been designed to make use of these capabilities. In contrast to the on-line programs originally developed on PCs, modeling and simulation programs were developed on VAX using VMS Pascal during the machine design phase3-5. They could not be ported to Windows 3.1, where on-line access was available, because of the large program size and the availability of compilers. It was only recently that we started porting them to PC using Borland Delphi2 on Windows NT. Windows NT is a platform for us to develop both on-line programs and modeling programs. It is especially useful for graphical user interface (GUI) development. Tracy V is one of these new programs. It is a fully interactive modeling, simulation, control and data analysis program dedicated to the use at the ALS storage ring.
*
2. TRACY V OVERVIEW 2.1 Primary Functions and Users Tracy V is a virtual machine of the ALS storage ring designed to be used not only by experts of modeling and simulation studies, but for accelerator physicists and engineers in general. It calculates and displays many machine functions, for example linear optics functions and closed orbits, for given magnet settings. Graphical user interface (GUI) is prepared to cover heterogeneous operation scenario. Data analysis tools for measured and archived data are embedded. For most of the user input, response is automatic and instantaneous. One of the exceptions is dynamic aperture calculation.
2.2 Language and Graphics Libraries Tracy V is fully written in Delphi2 object Pascal. The length of the source code is about 20,000 lines. The Visual Component Library of Delphi2 is used extensively for GUI programming.
2.3 Physics Class Library The modeling and simulation kernel of the original Tracy3 was structured and written in Pascal on VAX. This was rewritten in C++ employing object-orientation. The result is a C++ library named Goemon 6 that is a class library for accelerator modeling and simulation, and runs on Windows NT and UNIX workstations. A subset of Goemon is rewritten in Delphi2 that is an object-Pascal and embedded in Tracy V to support a standard 4x5 matrix formalism for optics calculations. Only a few routines are taken from the original Tracy as it is not object-oriented.
This work was supported by the Director, Office of Energy Research, Office of Basic Energy Sciences, Material Sciences Division, U. S. Department of Energy, under Contract No. DE-AC03-76SF00098.
2.3 On-line Device Access In addition to off-line modeling and simulation capabilities, Tracy V has on-line access to some of the storage ring devices. The on-line access is intentionally made indirect so as not to conflict with the off-line use of the program. It locally communicates with on-line programs that take care of device access security.
The dynamic aperture is defined at the injection point for 400 turns of a single particle. A page is prepared as shown in Fig.2.
3. TRACY V FUNCTIONALITIES 3.1. Magnet Settings and Misalignments Tracy V is a virtual model of the ALS storage ring. It calculates optics functions and closed orbit for given set of magnet settings and misalignments. It has GUI to manipulate these setting values. File access is also supported. Fig.1 shows the page for displaying beta functions and tune diagram, input knobs for tune fitting, and quadrupole settings. Fig.2. Dynamic Aperture Calculation. Tracking in phase space is also supported. For given initial condition and the number of turns, Tracy V produces phase plots in X-Px and Y-Py planes with Fourier analysis and amplitude tracing as options. Fig. 3 shows the phase and Fourier component graphs.
Fig.1. Twiss Functions and Quad page of Tracy V.
3.2 Parameter Fitting Parameter fitting routines are provided for tune, dispersion, chromaticity and closed orbit. Closed orbit manipulation is described below.
3.3 Closed Orbit Control and Analysis Tracy V calculates the closed orbit for given values of magnet settings and misalignments. Measured or calculated response matrices, the "Smatrix", which give the orbit change at the BPMs for an applied corrector setting, are used throughout the calculations. Local bump and most-effective corrector methods are provided for orbit control. For the measured orbit analysis, Tracy V can be linked to the directory on the network where on-line archived data is stored. It can also perform on-line BPM data reading in collaboration with an on-line program.
3.4 Dynamic Aperture and Phase Tracking
Fig.3. Phase Tracking and FFT to get Fractional Tune.
3.4 Wigglers and Undulators There are 4 undulators currently in use, a wiggler will be in use soon. They have been implemented in Tracy V to study their effect and develop operation scenarios. An elliptical-polarized undulator that is coming early in 1998 is being implemented. A linear model that represents only quadrupole component is used for optics calculations. A hard-edge model is used to calculate synchrotron integrals. Physical aperture limitations at narrow gap chambers are also modeled.
3.5 On-line Access As ALS machine control system is based on PC running Windows, on-line access from Windows application program is simple and fast. It is possible to provide online functions within Tracy V, but it conflicts with its offline use outside of the control room. Therefore, instead of making a direct on-line access, Tracy V communicates online programs running on the same PC in the control room. The inter-process communication is based on Win32 shared memory to minimize the overhead and named pipes as an option. BPM Data Taking Tracy V shares the BPM data taken by SRorbit, an on-line program shown in Fig. 4. The update speed of the BPM data reading is 5 Hz.
between the model and the orbit control. Although Tracy V has a capability of model-based orbit control by combining the on-line BPM reading and magnet setting, it sticks to this policy. It simulates the orbit control by using calculated Smatrices. When we actually apply the orbit control to the real machine, measured Smatrices are plugged into an on-line program that supports the same function. In case of local bumps, it is possible to calculate the bump condition that is a ratio of three kick angles by using a beta function and phase advance. Alternatively, it can be obtained by only using Smatrices without using beta function and phase advance. If we use the measured Smatrices, the effects of device calibration errors and beta beating are automatically eliminated.
3.6 Summary of Tracy V Tabbed Pages As we have seen in Figs. 1 to 4, Tracy V has two tabbed pages: the upper is mainly to display general optics functions around the ring, and the lower is to display special diagrams and provide knobs to set machine parameters. Here is the list of these pages: Upper Pages..general display
Fig.4 . SRorbit program that provides on-line BPM data to Tracy V. Tracy V also collaborates with on-line data archiver that continuously reads most of the machine status and writes them to the disk. For any given date and time for last several years of operation, Tracy retrieves BPM data if the PC has a network access to the ALS file server. It does not have to be in the control room. While we used commercially available database to manage the archived data, plain files are adopted to avoid the local database setup procedures. There are also knobs to read on-line data through the shared memory that can be either by demand or repetitively in collaboration with the SRorbit program. Magnet Setting On-line Magnet setting is supported by becoming a client of an on-line magnet server program, using either shared memory or named pipe on the same machine. As the server runs only on console PCs in the control room, the access security of the magnet settings is guaranteed. Orbit Control It may sound ironical but the storage ring orbit control is not model-based. It has been completely model-free and Smatrix-based7 for years. Instead of using a model directory to control the orbit, we put Smatrices
Twiss ..Twiss function display Dispersion ..Dispersion display Orbit ..Closed orbit display BPM ..Closed orbit and BPM read out display Steer ..Steering magnet setting display Misalignment ..Transverse misalignment display TuneFFT ..Fourier component of phase tracking AmpTime ..Betatron oscillation amplitude vs. time. Envelope ..Beam envelope display. Lower Pages.. special display and knobs Main ..Table of basic global parameters. Quad ..Quad magnet knobs and tune fitting knob. Quads ..Ganged quad magnet knobs. Steer ..Steering magnet knobs. Steers ..Ganged steering magnet knob. Bump ..Local bump knobs. Smat ..Smatrix calculation and display. BetaBeat ..Beta beat simulation Misalignment ..Transverse misalignment knobs. Girder ..Girder transverse shift knobs. BPM ..BPM data manipulation and orbit fitting. ID ..Insertion device knobs. Sextupole ..Chromaticity and sextupole knobs. DynAperture ..Dynamic aperture calculation. Orbit ..Closed orbit data manipulation. Phase ..Phase tracking. TwissTable ..Twiss function table. Emittance ..Emittance knobs for envelope calculation. By selecting and combining pages, users can carry out various modeling, simulation and analysis studies.
4. APPLICATIONS 4.1 Closed Orbit Analysis Tracy V has been used mainly for the beam diagnostics purposes at ALS. For example, it was used to analyze the spontaneous orbit drift that might due to magnet motions or malfunctioning. Usually, minute orbit drift is detected on the chart of IDBPM readout where IDBPM is a new family of beam position monitors to measure absolute beam position with an accuracy of ≈ 1 µm. When the date and time of the orbit drift is identified, we use Tracy V to navigate data files stored by the on-line archiver to extract the orbit drift pattern around the ring. This orbit can be fitted by using steering magnets or by shifting magnet location. If it was caused by single magnet malfunctioning or physical movement, Tracy V will pinpoint the magnet. The ALS storage ring has 12 curved sectors and all the magnets in a sector is located on a girder. Tracy V has a page to simulate and analyze the effect of transverse girder motion that might have caused some of the orbit drifts observed recently8.
4.2 Smatrix and Beta Beating Tracy V calculates an Smatrix and also reads a measured Smatrix. Based on the Smatrix, Tracy V calculates local bumps, picks up a most-effective steering magnet and fits the given orbit and extracts beta beating. It does not fit the Smatrix itself but estimates the quadrupole magnet strength errors that contribute to the beta beating. Fig. 5 shows the simulation of the beta beating. The top diagram of the lower tabbed page is the ideal Twiss function. The middle is the Twiss function distorted intentionally by changing one of the defocusing magnets. The Smatrix measurement is simulated under this condition. The bottom diagram shows the beta beating. The small boxes and crosses are the values of beating extracted from the Smatrix at BPM and corrector magnet locations.
4.3 Wiggler and Undulator Modeling As described in 3.4, Tracy V supports all the wigglers and undulators inserted in the storage ring. For given gaps of them, it calculates optics functions, closed orbit and dynamic aperture. Ganged knobs for quadrupoles are handy to explore the compensation schemes.
Fig.5. Beta beating and Smatrix.
5. ON-GOING EFFORT 5.1 Smatrix Analysis It is possible to fit a model to reproduce each element of a measured Smatrix as demonstrated in collaboration with BNL. 9 Since this is a time-intensive calculation, we do not plan to take it entirely to a part of Tracy V. Instead, we are seeking for the possibility of porting a subset of it.
5.2 Closed Orbit Calculation in 6 dimension Most of the optics and closed orbit calculations are done by using the standard 4x5 matrix model which has no constraint on the path length. In order to see the effect of the path-lengthening due to orbit excursion, Tracy V has adopted 6-dim routines developed for Gemini4 and Tracy2.5 This is a second order integrator using kicks to replace linear elements. The number of kicks per magnet is set large enough to keep the beta functions unchanged. This task has been in progress.
5.3 Variants of Tracy V Tracy V is completely dedicated to the ALS storage ring. All the default parameters are optimized for the ring. Nevertheless, a version of Tracy V was ported to the Barcelona Light Source storage ring that is in the design phase, and SPring 8 booster synchrotron that is being commissioned. A version to support beam transport lines at ALS is being developed.
5.4 Moving to Components The term "component" in object-oriented programming means an advanced form of the objects such as OLE and VBX from Microsoft. In case of Delphi, all the GUI elements are provided as components as Visual Component Library. We have already rewritten some of
our accelerator objects as components to evaluate the usefulness.
5.5 Beam Life Time Routines to calculate beam life time for a given lattice and operation mode are being developed10 to be a part of the program.
6. DISCUSSIONS AND CONCLUSIONS Tracy V has been demonstrated the usefulness and efficiency of the an interactive modeling and simulation tool with data analysis and on-line capabilities on Windows NT. The use of Delphi2 released the burden of GUI development considerably. On the other hand, further development of accelerator physics class library is required. The move to the component library should be an option.
AKNOWLEDGEMENTS The author wishes to thank A. Jackson for his helpful advises and suggestions, and R. Keller for many comments to improve the program.
REFERENCES [1] "1-2 GeV Synchrotron Radiation Source, Conceptual Design Report," LBL PUB-5172 Rev. LBL,1986. A. Jackson, IEEE 93PAC, 93CH3279-7,1432, 1993. [2] S. Magyary, IEEE 93PAC, 93CH3279-7,1811,1993. [3] H. Nishimura, EPAC 88,803,1989. [4] E.Forest and H.Nishimura, IEEE 89PAC, CH2669-0. [5] J.Bengtsson, E.Forest and H.Nishimura, unpublished. [6] H. Nishimura, LSAP-153, LBL Internal Report, 1993. H. Nishimura, IEEE 95PAC, 95CB35843,2162,1996. [7] H. Nishimura, L.Schachinger and H.Ogaki, IEEE 95 PAC, 95CB35843,2247,1996. [8] R. Keller, H.Nishimura and R. Alvis, to be published. [9] D.Robin, J.Safranek, G.Portmann and H.Nishimura, to be published in EPAC 96. [10] C.Kim, private communication.