Single Particle Beam Dynamics Codes Winni Decking DESY –MPYHHH Workshop CERN 2004 Winni Decking Overview • Introduction • Code repository – Models used – Programming philosophy • Examples • Summary This is a workshop contribution: The description of methods and their implementation in the various beam dynamics codes is not complete, not always accurate and maybe wrong at all. Winni Decking Definition • Describes the motion of a particle in the 6 dimensional phase space under the influence of external fields • Linear Motion – Fitting of linear optic functions etc. – Definition of magnets and alignment – Definition of geometry • Nonlinear Motion – Nonlinear perturbations – Dynamic Aperture Winni Decking Point of view • The physicist who cares only about the methods/assumptions used • The programmer who wants to implement the newest programming techniques • The user (also a physicist/programmer) who doesn’t care about methods and programming but likes a well documented, usable, cross-checked code to get the work done Winni Decking Program Layout 1. Get the data/lattice into the code - the lattice parser 2. Calculate • Linear optics functions • Tracking • Construct Map 3. Analyze the result • Display optics function • Calculate DA, frequency map, nonlinear distortions Winni Decking A legacy of beam dynamics codes • Many beam dynamics codes written over the years • Here is a – surely – not complete list: AT, BETA, BMAD, COMFORT, COSY-INFINITY, DIMAD, ELEGANT, LEGO, LIAR, LUCRETIA, MAD, MARYLIE, MERLIN, ORBIT, PETROS, PLACET, PTC, RACETRACK, SAD, SIXTRACK, SYNCH, TEAPOT, TRACY, TRANSPORT, TURTLE, UAL Winni Decking Model – Ray Tracing • • • • • P Orbit vector X ( x, x, y, y, z, ) , P0 Transport through elements X f RX i using R matrix Linear optics calculations Concatenated by Matrix multiplication Extended to higher order (TRANSPORT) x j , f R jk x j,i T jkl x j,i xl,i U jklm x j,i xl,i xm,i k kl klm • NOT symplectic AT, BETA, BMAD, COMFORT, COSY-INFINITY, DIMAD, ELEGANT, LEGO, LIAR, LUCRETIA, MAD, MARYLIE, MERLIN, ORBIT, PETROS, PLACET, PTC, RACETRACK, SAD, SIXTRACK, SYNCH, TEAPOT, TRACY, TRANSPORT, TURTLE, UAL Winni Decking Symplecticity f i Given a transfer Map z Mz And its Jacobian J is symplectic if f z J ab ( z i ) ai zb J T SJ S • A Hamiltonian system is symplectic, i.e. a map which fulfills the symplectic conditions describes a Hamiltonian system • Important test to verify validity of chosen approximations • If violated, artificial damping/excitation of motion Winni Decking Model – Element by Element Kick Code • Elements described by thin lens kicks and drifts • Always symplectic • Long elements to be sliced =>slow AT, BETA, BMAD, COMFORT, COSY-INFINITY, DIMAD, ELEGANT, LEGO, LIAR, LUCRETIA, MAD, MARYLIE, MERLIN, ORBIT, PETROS, PLACET, PTC, RACETRACK, SAD, SIXTRACK, SYNCH, TEAPOT, TRACY, TRANSPORT, TURTLE, UAL Winni Decking Model – Lie Maps • Lie map methods allow extension of linear concepts in the non-linear Regime • Lie transformation x f exp(: f :) xi • Lie maps can be factorized and truncated without loosing symplecticity AT, BETA, BMAD, COMFORT, COSY-INFINITY, DIMAD, ELEGANT, LEGO, LIAR, LUCRETIA, MAD, MARYLIE, MERLIN, ORBIT, PETROS, PLACET, PTC, RACETRACK, SAD, SIXTRACK, SYNCH, TEAPOT, TRACY, TRANSPORT, TURTLE, UAL • Concatenation formulae exist Winni Decking Example – Different Transfer functions in BMAD The computation method used for tracking and calculating transfer maps can be set individually for each element. Winni Decking Model – Differential Algebra • Differential Algebra techniques allow computation of Taylor maps • Basic idea is to “track” a power-series element-by-element • Taylor Map is again not symplectic but can be used to obtain factorized Lie map • AT, BETA, BMAD, COMFORT, COSY-INFINITY, DIMAD, ELEGANT, LEGO, LIAR, LUCRETIA, MAD, MARYLIE, MERLIN, ORBIT, PETROS, PLACET, PTC, RACETRACK, SAD, SIXTRACK, SYNCH, TEAPOT, TRACY, TRANSPORT, TURTLE, UAL Winni Decking Application of One Turn Maps • One turn map tracking – One-turn Taylor Map – Construct mixed-variable generating functions – Cremona maps • Normal form analysis – Extracts higher order lattice function perturbations and their parameter dependence as well as driving terms out of one-turn map – Very useful Winni Decking PTC-TWISS MAD-X Module E. Courant et al, “A comparison of several Lattice Tools for Computation of Orbit Functions of an Accelerator”, published in PAC2003 Portland, shown is nx versus p/p for a simple cyclotron. Standard MAD-X gives the green curve which deviates since the MAD-X (like MAD8) uses the expanded Hamiltonian. In PTC the exact attribute allows to the treat the true Hamiltonian. Note, that PTC has read-in the structure from MAD-X input. There is now PTC_TWISS as attribute of the PTC MAD-X module (still rudimentary!) that allows to produce the Ripken/ Willeke lattice functions called TWISS3 in MAD8. Example for the Afternoon Normal Form MAD-X Module There is now also a NORMAL attribute of the PTC MAD-X module (still rudimentary!) to calculate dispersion, tune and anharmonicities to high orders and as function of delta. This module will be eventually become the replacement of the DYNAMIC/STATIC of MAD8. Winni Decking Programming Philosophies • Integrate the physics into a high level mathematics software (like Mathematica, MatLab, …) • Many existing codes can be ‘operated’ from high level software • Only few codes are ‘embedded’ into MatLab AT, BETA, BMAD, COMFORT, COSY-INFINITY, DIMAD, ELEGANT, LEGO, LIAR, LUCRETIA, MAD, MARYLIE, MERLIN, ORBIT, PETROS, PLACET, PTC, RACETRACK, SAD, SIXTRACK, SYNCH, TEAPOT, TRACY, TRANSPORT, TURTLE, UAL • Advantages: – Input/output dealt with built in math functions – Easy implementation in control system • Disadvantage: Slow Winni Decking Programming Philosophies • Provide the user with a toolbox (library) rather than an existing program which does contain the needed elements and procedures • Realized in C++, F90, Pascal AT, BETA, BMAD, COMFORT, COSY-INFINITY, DIMAD, ELEGANT, LEGO, LIAR, LUCRETIA, MAD, MARYLIE, MERLIN, ORBIT, PETROS, PLACET, PTC, RACETRACK, SAD, SIXTRACK, SYNCH, TEAPOT, TRACY, TRANSPORT, TURTLE, UAL • Can be tailored to specific problem, should be easy to maintain and extend Winni Decking Programming Philosophies • A more or less advanced process control is implemented in the code itself and allows complicated run logic AT, BETA, BMAD, COMFORT, COSY-INFINITY, DIMAD, ELEGANT, LEGO, LIAR, LUCRETIA, MAD, MARYLIE, MERLIN, ORBIT, PETROS, PLACET, PTC, RACETRACK, SAD, SIXTRACK, SYNCH, TEAPOT, TRACY, TRANSPORT, TURTLE, UAL Winni Decking Programming Philosophies • Programs tailored to more or less specific needs • Not universal, but usually the code is not as complex and allows easy changes • Often only used at only one laboratory and closely linked to the specific facility and control system AT, BETA, BMAD, COMFORT, COSY-INFINITY, DIMAD, ELEGANT, LEGO, LIAR, LUCRETIA, MAD, MARYLIE, MERLIN, ORBIT, PETROS, PLACET, PTC, RACETRACK, SAD, SIXTRACK, SYNCH, TEAPOT, TRACY, TRANSPORT, TURTLE, UAL Winni Decking Input Format • A common format for input and output does not exist • A mad-like description of beam lines seems is the most accepted approach • Much more information on a beam line element needed – Errors, Aperture, Wakefields, …. – Magnet errors • Systematic • Random – Time dependent variation of magnet strength, magnet positions – Correlation between errors important • Girder motion • Correlated systematic errors • Attempt for unified input (SXF) Status? Winni Decking Input Format (Typical) Life Cycle of an Accelerator Project (from N. Walker) • Simple models (sequences of elements) Basic Lattice Design • Tend to work with smaller modules • Fitting, constraints etc. Lattice matching • ‘Generic’ magnet families Performance Simulation construction Modelling of real machine • Definition of basic parameters • (may have more than one possible optics) Quadrupole L K1 value or range of K1 values Winni Decking Input Format (Typical) Life Cycle of an Accelerator Project (from N. Walker) • More complex (complete) models Basic Lattice Design • Tolerance studies • Simulation of a range of “errors” • Refinement of parameter specifications Performance Simulation • Definition of prototype component • Tuning algorithms, diagnostics specs. construction Modelling of real machine • Power supplies (circuits), Klystrons etc. Quadrupole L Pole tip radius max / min pole-tip field Tolerances (used to generate random errors) Winni Decking Input Format (Typical) Life Cycle of an Accelerator Project (from N. Walker) Basic Lattice Design • Engineering design of accelerator components Performance Simulation construction Modelling of real machine Quadrupole prototype (family) L Pole tip radius max / min pole-tip field Tolerances Documentation (drawings, cad files etc) Winni Decking Input Format (Typical) Life Cycle of an Accelerator Project (from N. Walker) • Complete model of real machine Basic Lattice Design • Used for • Online modelling • Continued performance studies Performance Simulation construction Modelling of real machine • Tuning studies etc. Quadrupole QF10 (now unique) L Pole tip radius max / min pole-tip field Measured field map Other unique physical attributes Winni Decking Input Format (Typical) Life Cycle of an Accelerator Project (from N. Walker) Basic Lattice Design Input Format should support all stages of the project Performance Simulation construction Modelling of real machine Winni Decking Example – HERA-e Synchro-Betatron Resonances • Working Point close to integer was found to have low lifetime • Incomplete cancellation of chromatic perturbations in the two IR’s north and south • Analytic treatment with perturbation theory by F. Willeke (EPAC04) Winni Decking Example – HERA-e Synchro-Betatron Resonances • Tracking with SIXTRACK – constant initial amplitude in x, y, d – change of coherent tune with arc FODO quads – Frequency Map analysis of 2048 turns Winni Decking Example – Frequency Map at BESSY II • Model incorporates: – Linear coupled model based on orbit-response measurements – Dipole and quadrupole fringe fields – Longitudinal variation of sextupole field – Systematic octupole in quadrupole – Sextupole and decapole components created by steering magnets Measurement from P. Kuske (BESSY) – EPAC04 Model Winni Decking Measurement ALS Off-Momentum Aperture • Excitation of increasing horizontal beam centroid motion with single turn kicker • (Static) momentum variation by change of RF frequency • Single turn BPM’s provide tune of kicked beam (lower figure) • Beam intensity monitor records beam losses (upper figure, dot size corresponds to relative intensity loss) Winni Decking ALS Off-Momentum Aperture • Tracking with ALS model after orbit response measurement • Beam loss on 6th order resonance reproduced Winni Decking Early Indicators – Survival Plots • Huge number of turns • Early indicators for chaotic motion – Frequency maps – Lyapunov coefficient – Survival plot extrapolation – Diffusion rates in amplitude space HERA-p , 2000 Model • Difficulty with time dependent process (ripple, events) Winni Decking Beam Dynamics Measurements with Hadrons • Measurements at SPS, FermiLab, Hera-p, … • Optional control off non-linearity with additional sextupoles and octupoles • Optional additional application of ps-ripple to simulate tune variations • Phase space reconstruction with kicker and single-turn BPM’s • Resonance driving term analysis from single-turn BPM data • Model verified by tune-shift with amplitude measurements (often difficult if aperture restriction does not allow large kick amplitudes) • Measurement of DA agrees with predictions within 20 % Winni Decking Measurements at SPS 2002 Winni Decking Resonance driving terms at HERA • Resonance line amplitudes obtained from single-turn PM data • Line amplitude can be calculated form normal form theory Winni Decking Conclusion • The ideal beam dynamics code looks like – Library type architecture – Linear and nonlinear matching – Symplectic map tracking through arbitrary fields with time and s dependence – Normal form analysis – Element by element kick tracking as alternative to the above • Pre processing – Connection to data base and control system – Uniform format only important for big collaborations • Post processing – Includes FMA, early indicators etc. – Can be done by external math program Winni Decking Conclusion • Single particle dynamics is mature field with many available tools • Codes have been benchmarked against experiments with good agreement if the accelerator model is refined enough • Modern tools like Lie algebra and normal form should be promoted and used more frequently • But: For today’s accelerator physics problems the single particle approach is less and less valid: – Beam-beam, space charge, geometric wakes, ion-and ecloud, coherent synchrotron radiation, …. Winni Decking Model Usage AT(Matlab) C Spear,ALS BETA S Kick ESRF, BESSY BMAD C,S Matrix, Kick, Lie, PTC Cornell COMFORT Matrix DESY COSY-INFINITY Taylor, Lie, DA World DIMAD Matrix, GF SLAC ELEGANT L,S Matrix, Kick APS, World LEGO C Da, Lie PEP-II LIAR L Matrix SLAC LUCRETIA L SLAC MAD C,S,L Matrix, Kick, Lie, PTC World MARYLIE Lie, GF World MERLIN L Matrix, Kick World ORBIT C PETROS C Matrix DESY PLACET L Matrix CERN, World PTC C,S Kick World (BMAD, MAD) RACETRACK S Kick Elettra SAD C,S,L Matrix, Kick KEK SIXTRACK C,S Kick World SYNCH TEAPOT C Kick (UAL) TRACY S Kick SLS, Soleil, ALS TRANSPORT C,S,L Matrix World TURTLE L Matrix UAL C Matrix, Kick(Teapot) RHIC Comments beam-beam wakefield project started particle interaction wakefield Winni Decking AT(Matlab) BETA BMAD COMFORT COSY-INFINITY DIMAD ELEGANT LEGO LIAR LUCRETIA MAD MARYLIE MERLIN ORBIT PETROS PLACET PTC RACETRACK SAD SIXTRACK SYNCH TEAPOT TRACY TRANSPORT TURTLE UAL EXE SOURCE U,L,W DOC y Optimisation Input U,L y y y madlike y U,L y U,L,W y y y y y y y U,L,W y y n U,L,W y y U,L,W y y y y y U y U,L,W y y (y) n n U,L U,L y y y n y y y y y y y y Language MatLab, DLL F90, C++, Lib F77 mad,sxf C++ madlike,sxf F90 madlike C C++, Lib F90 MatLab, DLL mad C,F77,F90 F77 madlike C++, Lib C++ F77 C F90 F77 madlike F90 sxf F77 C++ F77 F77 C++ Winni Decking