Particle Acceleratrs, 1986, Vl. 19, pp. 99-105 0031-2460/86/1904-0099/$15.00/0 1986 Grdn and Breach, Science Publishers, S.A. Printed in the United States f America ROUNDING ERRORS IN BEAM-TRACKING CALCULATIONS P. WILHELM and E. LOHRMANN II. Institut fur Experimentalphysik, Universitiit Hamburg, Hamburg, Germany (Received March 7, 1985) The cmputer simulatin f particle dynamics in acceleratrs and strage rings has becme an imprtant tl in acceleratr physics. In ne methd particles are tracked by explicitly cmputing their mtin thrugh the magnets and the drift spaces f the machine ("kick cdes"). The purpse f ur wrk is t investigate hw the results are affected by the finite numerical accuracy f the cmputatin. Our study reveals a strng influence f runding errrs n the results f tracking calculatins. They grw much mre rapidly with the number f turns than naively expected. Therefre they give a limit f meaningful calculatins. In ur example, this limit is reached fr a few 10 6 turns arund the strage ring, crrespnding t sme 10 secnds' real-strage time. I. INTRODUCTION At DESY an electrn-prtn cllider HERA (hadrn-electrn ring ~cceleratr) will be built. It will cnsist f tw separate strage rings fr the electrns and prtns. The prtn ring will have supercnducting magnets. The prtn strage ring was used as an example in the present investigatin. Particles were tracked by explicitly cmputing their mtin thrugh the magnets and drift spaces f the machine. The mtin f a particle in the magnetic field f a strage ring is described by the fllwing differential equatins: d 2 x e -d2+ Kx(S) x=- Bz(z,x,s), s P d 2 z e ds 2 + KAs) z = - P Bx(z, x, s), where x, z = hrizntal and vertical displacement f the particle frm the ideal rbit, s = lngitudinal crdinate, K x, K z = fcusing strengths (including weak and edge fcusing), B x, B z = transverse cmpnents f the additinal magnetic field (B s = 0), P = design mmentum f the particle. The actual cmputatin was dne using the prgram RACETRACK l. We investigated the rle f runding errrs using this prgram as applied t ne versin f the HERA prtn strage ring. In the RACETRACK cde linear magnetic 99 (1)
100 P. WILHELM AND E. LOHRMANN elements (drift spaces, diples, quadruples) are represented by their transfrmatin matrices. These elements are cmbined int blcks as far as pssible. Each blck is represented by ne matrix nly. The crdinates after the kth blck are calculated by the usual matrix frmalism fr linear ptics. Nnlinear elements are treated in the thin-magnet apprximatin. This means that nly the directin f the particle (x', z') is changed at ne pint in the middle f the magnet ("kick cde"): X~+l =x~+ ~x', ~,=i.±(bn+ian)(x+izt- 1 P n=l In the HERA structure, which we have used fr ur investigatins,2 we had 836 linear blcks, 208 pure sextuples, and 600 elements with multiples up t and including n = 9. The plynmials in Eq. (2) were develped by hand and explicitly written dwn as "Hrner Schema" in the cmputer cde. T calculate ne turn arund the strage ring, we had t carry ut 250 000 flating-pint peratins. Nrmally the calculatins are carried ut in duble precisin n an IBM 3081 cmputer. In this case, ne revlutin, which crrespnds t 20 J-tS strage time, takes 80 ms f CPU time. Much f this wrk was als dne n a 370 E (emulatr), develped by H. Brahman et ale (Weizmann Institute) and perated at DESY by D. Ntz. Its speed is abut 1/5 f an IBM 3081D fr ur cdes. On an IBM cmputer, single-precisin numbers are represented with 24-bit mantissa, duble precisin with 56, and furfld precisin with 120-bit mantissa. The errr in the representatin f a single number, the single rundff errr, is f the rder f 2- t fr a t-bit mantissa; fr IBM cmputers it may be up t a factr f 8 larger because f their hexadecimal nrmalizatin. S, single runding errrs are very small, but they prpagate and accumulate and therefre becme nn-negligible after sme time. (2) II. METHODS We have used three different methds t determine the size f runding errrs. The first methd can nly be applied fr the special case f linear ptics withut skew quadruples. Here the hrizntal crdinates x, x' and the vertical crdinates z, z' are independent f each ther. The emittance 1 {2 2 [' a(s) J2} ex =fj(s) x (s) + fj (s) x (s) + fj(s) xes) (and E z analgus) is a cnstant f mtin. /3 is the /3-functin and a = -! dd fj. The emittance can be calculated frm the starting crdinates and must 2 s remain cnstant as the particle is traced thrugh the lattice. Deviatins must be due t runding errrs. (3)
BEAM-TRACKING CALCULATIONS 101 In a secnd general methd the runding errr can be determined by cmparing the tracking results with thse f a much mre accurate reference calculatin. Cmparisn f single precisin with a duble-precisin reference des nt wrk, because single precisin is much t inaccurate t be f any practical value. S we emulated a 40-bit mantissa (by masking the last 16 bits f duble precisin with zers after each flating-pint peratin). The results f this calculatin were cmpared t a duble-precisin reference. We have checked by a calculatin with furfld precisin that this reference is gd enugh fr ur purpse. As a third methd we used backtracking. The particle is first tracked fr a number f turns N arund the ring. Then its directin is reversed, and it is traced back thrugh the same magnet structure. It shuld then g exactly the same way back and finally after N turns f backtracking be at the starting pint again. Failure t d s must be due t the influence f runding errrs during the calculatin f a ttal f 2N revlutins. We determined the runding errr fr smaller numbers f revlutins by lking at crrespnding pints alng the path f the particle: n its way back, the particle shuld g thrugh the same pints it went thrugh frward. The distance f these crrespnding pints is due t runding errrs. Fr the backtracking, the matrices f the linear ptics are inverted: M- 1 = ( d-b), -c a because det M = 1. The kick Ax' is calculated in the same way as fr the tracking, but it is subtracted, nt added. As a check, we cmpared the results f the three methds fr a linear machine (the HERA prtn ring withut sextuples and higher-rder multiples). We have chsen 10 particle trajectries with starting crdinates lying n a phase-space ellipse with a betatrn amplitude f 12 mm at the starting pint. After averaging ver the 10 particles, we fund the fllwing results: as expected, the errrs fr 40-bit accuracy are larger by a factr f 2 16 than the errrs fr 56-bit accuracy. The relative errrs f z and z' are rughly equal; therefre fr 40-bit accuracy we calculated a cmmn mean value. The relative errr f the emittance is abut a factr f tw greater than the ne f the crdinates. This fact is rughly expected frm Eq. (3). These results are shwn in Fig. 1. In summary, the three different methds give a cnsistent picture fr the linear machine. In the same sense, we cmpared in spt checks the tw applicable methds fr the nnlinear machine and gt cnsistent results. (4) III. RESULTS We used the prgram RACETRACK as described t test the effect f runding errrs n the result f tracking calculatins. We used the methd f backtracking and duble precisin (real *8, 56-bit mantissa).
102 P. WILHELM AND E. LOHRMANN relative runding errr [-] I(L\e/ )av 1.\ (L\Z/z)av \t I(L\Z'/Z')av I 1.10-0 5.10-6 v..."1 1.10-8 5.10-9.v.. 40: bit accuracy: ~ :emittance:.'.... ''\1'. ~:tra'c'king i ~ z I 1.10-9 5.10-10.. 0 t t;l 6 6... ~... ~. 0 6 6 56 :bit accurapy: " Q.. : ':'emittance~'....:... 6.: :backtra ek~ng 'I,~z/z ~. A : :backtrack~ng I:~z'/z' I 1 5 10 50 100 500 1000 number f turns N [-] 38847 FIGURE 1 Relative runding errrs fr tracking as functins f the number f turns (fr 40-bit and 56-bit accuracy).
BEAM-TRACKING CALCULATIONS 103 We first studied the linear machine (nly diples, quadruples, and drift spaces). We find that the relative errr increases rughly prprtinal t the number f revlutins N, see Fig. 1. We pltted the distributin f the relative runding errrs in Fig. 2. There are tw grups f : the errrs in the hriz0ntal (x, x') and vertical (z, z') crdinates, re~pectively. The average errr in each grup grws apprximately linear with N. This behavir can be understd frm the nature f the linear apprximatins. Cnsider the transfer matrix M fr ne cmplete revlutin arund the ring, btained by multiplying all individual transfer matrices tgether. We shuld have det M = 1, and this guarantees that the emittance e is a cnstant f mtin. Due t runding errrs, the matrix M' actually used in the calculatins des generally nt have det M' = 1. Depending n whether det M' ~ 1, the emittance will increase/decrease with each turn, leading in the average t a psitive/negative value f the errr. Since the same (wrng) matrix is used fr each turn, this effect accumulates with the same sign fr each turn, and the errr increases linearly with N. It therefre prevails ver the effect f randm runding errrs, which shuld grw like Nl/ 2 10 8 after N= 1 turn 6 4 2 15 10 5 after N= 10 turns -3.0-2.0-1.0 0.0 1.0 2.0 3.0 relative runding errr li.y/y [10-13 ] -3.0-2.0-1.0 0.0 1.0 2.0 3.0 relative runding err'r tj.y/y [10-12 J 15 15 after N=100 turns 10 10 5 5 a.fter N= 1000 turns,--: r a -3.0-2.0-1.0 0.0 1.0 2.0 3.0 relative runding errr ~yiy [10-11 ] -3.0-2.0-1.0 0.0 1.0 2.0 3.0 relative runding errr t",y/y [10-10 J 38849 FIGURE 2 Evaluatin f relative runding errr fr particles with X max = 1.2 cm in the linear machine. Nte change f scale. unshaded: y = x, x'; det M' -1 = 1.2.10-13 shaded: y = z, z'; det M' -1 = -0.8 10-13
104 P. WILHELM AND E. LOHRMANN This behavir is brne ut in Fig. 2. As a matter f fact, the tw crdinate grups x, X' and z, z', which are calculated independently f each ther, differ in the sign f (det M -1). It shuld be nted here that the determinatin f the sign f (det M - 1) requires a calculatin with furfld precisin (real *16). Fr the nnlinear machine we investigated the abslute errrs f the amplitudes and directins, nrmalized t their maximum value, determined in the linear machine. We lked at the distributins f the nrmalized errrs fr samples f particle trajectries; they were chsen with the starting crdinates lying n phase-space ellipses with different betatrn amplitudes. The distributins are centered arund zer and symmetric. The rms values /( L\y)2)112 \ - are pltted vs. the number N in Fig. 3. Fr large values f N the rms Ymax errrs grw like N 2. There is a strng dependence n the betatrn amplitude. This behavir can be understd frm the physics f a nnlinear strage ring, which determines the errr prpagatin. The betatrn phase f a particle trajectry grws by 21C Q every turn, with Q = betatrn tune. In the nnlinear machine, the tune Q depends n the betatrn amplitude X max accrding t 10-5 r:----,----r-r-t"""t""'t'tt".---,---.,.--,..-,-t--rrrr--,----r--'t'-rrrr---,-----r-'t'--rrrr--.---r-'t'-rrrr;r---r--.---r--r'~ "." a [-] ".,,~ 10-6. - - - - """II'" : Xmax= 6.10 mm,,#" :-xmax=-12;oomm,..... -..,. '.. : Xmax= 16.00 mm quadrat~~"," A.,;,.'- 10-9 ",'--linear 10 10 0 10 6 number f turns N [-] 38848 FIGURE 3 a f nrmalized runding errr ~Y/Ymax fr the nnlinear machine.
BEAM-TRACKING CALCULATIONS 105 in first apprximatin. (Qlin = Q-value f the linear machine, q = cnstant). Because f the determinant errr, the amplitude changes systematically by a X max, a ==: 10-13 every turn, s the cmputed value f X max is x~~~ =xmax(1 + an). Therefre Q changes systematically every turn, and the errr in tune will be Qcalc - Q = Qlin q x~ax(2an + a 2 N 2 ). Fr an«1 we can integrate this equatin t get the errr in betatrn phase: epcalc - ep = in2jrqlinqx~ax 2aNdN ==: 2Jl'Qlin q x~ax a N 2, which shws indeed the N 2 dependence and the strng dependence n x max Our data reveal in fact that the errr in phase is systematic in nature: errr distributins in are again nt centred arund zer, but the sign f the errr crrespnds t the sign f the determinant errr, indicating that the present interpretatin is basically crrect. The significance f these bservatins is the fllwing: Even thugh the magnitude f a single runding errr is very small, their accumulated effect grws with N 2 and will eventually vertake ther effects which grw mre slwly with N. Fr ur prblem runding errrs limit the pssibility f meaningful tracking t a few millin revlutins. Hwever, the systematics explained abve pen the pssbility t heuristically crrect fr thse effects. 3 REFERENCES 1. A. Wrulich, DESY Reprts 82-04, 82-07, 84-026. 2. F. Schmidt, Diplma thesis, Hamburg University, 1984. 3. F. Schmidt, private cmmunicatin, and ther papers in this cnference.