OPTICIAN A COMPUTER PROGRAM FOR BEAM OPTICAL PROBLEMS Nicholas R. White, after T.J.L. Greenway. (C) Nicholas R. White, 1983,1986. 1. Introduction "Optician" is an interactive program which allows the user to trace the trajectories of single rays or of beam envelopes through any series of beam optical elements, with output to the display or plotter or both. Various adjustments or optimising routines are available which enable the desired trace to be obtained on the display and a hard copy then to be produced on the plotter. The program is developed from the Oxford beam optics program Optryk by Tom Greenway 1 which used routines based on "Rayplot" by K.H. Purser2. ..page 2. Operating the program. The program OPTICIAN is on a diskette containing DOS 2.0 and a startup file. Place it in drive A and switch on or reboot the system. Press the (Caps Lock) key, since the program only recognises upper case letters as valid commands. Place a diskette for data files in drive B if required. After exiting, the program may be restarted by typing OPTICIAN(CR) In this document (CR) is used to represent the carriage return key. The program starts by going through an input sequence once to specify all necessary parameters, after which various options become available. On entry to the program, when the element sequence is being specified or when the option switches are available (indicated by *) entering H(CR) (help) will type a summary of the options. On entry the program types Input from: to request the form of data entry; the response should be  T(CR) for input from the terminal keyboard, or D(CR) for input from a disk file (which must have been created during a previous run). Any other input will cause a Help message to be typed to the screen. For terminal input a Filename, (the default diskette drive is B) and extension (e.g. TESTFILE.MK3) and a Title (up to 60 characters) must be given; these appear on subsequent listings or plots, and the filename is the name of the file on which data may later be stored by the O (Output) command, unless it is later changed by the N (new Name) command. For disk file input Filename is the name of the file read. WARNING: an error in the typing of the filename causes exit from the program, which is inconvenient. ..page When entering data from the terminal, an element sequence is first specified, consisting of a list of allowed beam optical elements in the order in which they are encountered by the beam. The element types at present available are: Full title: Abbreviation: Ion source................................ I Drift length.............................. D Quadrupole singlet lens................... Q Solenoid lens............................. S Focal Length (thin Lens).................. F or L Bending magnet (median plane horizontal).. M Axial rotation (about z axis)............. R Accelerator Tube.......................... A or T Gas or foil stripper (Scattering effect).. G Electrostatic bend (Cylindrical).......... B End of sequence........................... E One element is specified per line. Only the initial letter is needed. If an illegal character is typed in the element sequence this sequence is aborted and a reminder of the allowed elements is typed; if H is typed in the sequence this reminder is immediately typed, but the sequence must be restarted. The maximum number of elements that can be stored is 50. The program then asks for the parameters of the various elements specified. 3. Data entry When the program requests data to be entered it will be accepted in free format. The values may be entered on one line, each value being terminated by comma, or on successive lines. A value must be given for every parameter, even if it is zero. Those parameters which are altered by the optical elements (charge, energy, momentum, etc.) are updated automatically. 4. Ion source. This should be the first element in the sequence. Subsequent ion sources are allowed (up to a maximum of six); after each source a new set of beam coordinates is started (either beam envelope or single ray). Injection energy (MeV); specify the beam energy at the source and let the program look after it thereafter. Charge state (in units of e); usually 1 at the beginning, or the current value at any later source in the sequence. It may be changed in subsequent accelerator tubes. Mass (AMU); can only be changed by another ion source. Current (mA); This is important in the optics of accelerator tubes; it is assumed that the beam is 95% space-charge neutralized elsewhere. NOTE: For beams typically encountered in tandem accelerators space charge is insignificant. In systems where the optics is sensitive to the current, care must be taken to provide reliable traps for neutralizing particles, and design the optics to tolerate fluctuations in current. Momentum (MeV/c) is calculated by the program from the input data. The program then asks whether a single ray or a beam envelope is required. The six starting coordinates (x,x',y,y',DelptaP,DeltaL) are then requested. For a beam envelope these are the projctions of a six dimensional upright ellipsoid on these axes. A beam is therefore assumed to start at a waist. For many beams the last two coordinates are not relevant, and only the values for (x,x',y,y') need be entered, followed by two zeros. The user is expected to have a working familiarity with this conventional beam optical notation. The beam central ray is the z-axis, which may be curvilinear, and the x- and y- coordinates are measured from it; x' and y' are the angular divergences from the z-axis. The program makes the assumption that divergences are sufficiently small that an angle is equal to its tangent. This assumption is usually an excellent approximation; the error at 200mrad is 10%. For more details, see reference 3. 5. Drift length. Enter the length in meters. The program can handle negative lengths (treated as a single step in plotting, i.e. a straight line in the negative direction). Zero lengths may be entered as dummies for later insertion of different elements by the R (rearrangement) command. It is often convenient to divide long drift lengths into two or three shorter lengths, so as to place a marker on the plots. 6. Quadrupole singlet. Enter length in meters, and dimensionless strength parameter K = kl where k2= g/BR (g = magnetic field gradient, BR = beam rigidity). Electric field gradient = g*v (velocity in m./sec.). The trajectory in a converging quadrupole is a sinusoid; K is the number of radians of this sinusoid to occur within the quadrupole. Since the quadrupole strength contains a beam rigidity factor focusing occurs independent of momentum or charge state. To investigate the effect of defocusing for different beams with the same quadrupole current (constant g) the strength should be adjusted in inverse proportion to the square root of the beam rigidity (BR). Initial strength parameters are rather a matter of trial and error; for a doublet it usually turns out to be around 0.6. Enter a positive strength for a singlet converging in the horizontal plane, negative for diverging. It is possible to enter coupled quadrupoles into the sequence. A doublet is normally constructed by specifying two free singlets; the strength of these singlets may later be optimised to find beam waists. For a triplet the normal arrangement is for the first and third singlets to have the same excitation, therefore to construct a triplet in the program specify two free singlets and a third singlet coupled to the first. Thus the length and strength of two singlets are given (the first usually being shorter than the second) and for the third singlet a coupling coefficient is entered in place of the strength; this is usually +1.0 for a horizontally converging third singlet, and -1.0 for one diverging. Then in response to the question Is this quad coupled to a previous one? enter Y(es) for the third singlet, and give the sequence number of the first singlet. Later when using the quadrupole optimising routine the sequence numbers of the first and second elements are given as variable elements,and the third element remains automatically coupled to the first. Similarly quadrupole quartets or other multiplets may be constructed, keeping two free singlets for the optimising routine. Note that coupling can only be specified to a quadrupole earlier in the sequence. Coupled singlets may later be respecified as free using the R (rearrangement) command. 7. Solenoid lens. A solenoid lens focuses a beam but also rotates it; this is fully taken into account. The length and strength must be specified in a similar way to that for quadrupoles. The program will calculate the required magnetic field strength if the data are printed out on the printer. 8. Magnet. Uniform field (index N = 0) and non-uniform field magnets are treated, the bending plane being horizontal (x plane). Where magnets occur with different bending planes an axial rotation may be placed between them. The effect of finite fringing fields is to reduce y-focussing. To allow for this effect, an algorithm of Enge3 is included. The program will ask for the pole gap in mm, and a field integral I2. This integral is typically 0.45 for a sharp edged pole, but may be as large as 0.75 for a Rogowski profile or in a magnet which saturates. Do not place undue faith in the predictions for magnets whose field integrals are as yet unknown. Do not use pole gaps greater than one fifth of the bending radius, as further corrections may then be needed. Within these limitations, results have been excellent. 9. Axial rotation. Rotates the beam around the z axis. Angle in degrees. This is very useful in the following situations: - if two bending magnets bend in different planes, - if an acceleration tube has an entrance slit which is not horizontal (as the program assumes), - to investigate the effect of quadrupole misalignment. 10. Accelerator tube. Accelerator tubes can be entered with various options for the focusing effect at the tube entrance and exit. If the entrance or exit is gridded there is no focusing effect; enter 0 for entrance or exit lens. If the entrance or exit is the normal circular aperture, enter 1. A correction factor, determined from ray plotting through a potential field determined by a relaxation calculation, can be applied to the aperture lenses,6,7; for small or zero diameters this factor approaches 1, when the same focusing as given by Larson's program OPTIC should be obtained. The correction factor also approaches 1 when the aperture lens effect is weak. HVEC used tubes with horizontal slot electrodes, except at the low energy entrance; this effect can be obtained by entering 2 for the entrance and exit lenses. A horizontal slot has no focusing effect in the horizontal plane, and twice the focussing effect of a circular aperture in the vertical plane. Each change of field gradient should be represented by a section of accelerator tube, with the appropriate apertures at entrance and exit (circular or slot). At the junction of the tube sections the diverging exit lens and the converging entrance lens will combine to form the correct focusing effect for the change in field gradient (to a good approximation). Entering other than 0, 1 or 2 for the lens effect gives a typed reminder, and the correct code may be retyped. Within an accelerator tube, the beam is assumed to be unneutralized, and space charge is taken into account, assuming a uniform current distribution. It may be necessary to allow extra short accelerator tube lengths to simulate an electron trap at the negative end of accelerator tubes used for positive ions. 11. Focal length (thin lens). Enter the focal lengths in the horizontal and vertical planes, FX and FY. These will usually be equal, representing a cylindrical electrostatic lens. Zero focal lengths are interpreted subsequently as meaning zero strength, i.e infinite focal length. While this device is idealized, and only approximately valid as a representation for Einzel lenses, it has other important uses. For example, if the required starting coordinates are NOT an upright beam ellipse (i.e. a waist), the procedure is to specify an ion source of the correct size, to enter a divergence which gives the correct emittance, and then to alter the divergence by means of a thin lens as element 2. This procedure also allows slit geometry sources to be well represented. 12. Gas or foil stripper (scattering). Either foil or gas stripper may be specified; since lateral displacement of the beam in a long gas stripper turns out to be negligible in the case of tandem strippers only angular scattering at a plane normal to the z axis is considered. Zero thickness may be specified, to give no scattering. The scattering is calculated according to a Thomas - Fermi potential9 and incorporated as a RMS width assuming a gaussian distribution. Thus if the initial beam envelope corresponds to a RMS width the scattered beam envelope will still correspond to the RMS width. However for very thin scatterers a Gaussian distribution underestimates the width, there being a large proportion of the beam in the tail scattered at large angles. Even for fairly thick scatterers the RMS width contains only about 20% of the beam, if one considers an integration of the density function over x, x', y, and y' to the RMS width. Since the effect of a stripper is to increase the emittance of a beam, the stripper is ignored when a single ray is being transmitted. ..page 13. Options. At the end of the data entry for the element sequence the option become available, indicated by: * The replies to this prompt are listed below; some can include element sequence numbers as numeric arguments. (blank)(CR) is no-op. A(CR) New axes Clears the plot. Next time D is typed the screen is cleared and new axes are plotted. C(CR) Coordinates Enter a new set of ion source coordinates: Mass, charge, initial energy, current, ray or envelope, and (x,x',y,y', DeltaP,DeltaL). The screen is not cleared at the next D, thus successive traces may be overlaid on the same plot. Cn(CR) to change coordinates for ion source no. n. D(CR) Display the current plot on the screen. The top half of the screen shows the trajectory or beam envelope in the horizontal plane, and the lower half the vertical plane, with the particles travelling from left to right. In the case of single rays it is possible to cross the axis, so horizontal and vertical should be determined from the starting position. The positions of the element boundaries are shown with a label indicating which element it is. The switches C, F, M, Q, S and T can be called to change rays or certain element parameters which affect focusing, after which a D will cause the new ray to be overlaid on the screen or plot. This can be repeated several times; the A command should be used to clear the screen regularly. E(CR) Exit from the program. Clears the screen. F(CR) Focus Change the focal length of a thin lens. F5(CR) allows lens sequence no. 5 only to be given a new focal length. The screen is not cleared at the next D, thus successive traces may be overlaid on the same plot. G(CR) Gas (or foil) stripper Allows the stripper thickness to be varied. The screen is not cleared at the next D, thus successive traces may be overlaid on the same plot. G4(CR) allows stripper sequence no. 4 only to be given a new thickness. H(CR) Help types a brief summary of the options. I(CR) New Input Goes to the beginning of the program to input a new element sequence. Automatic A is given. L(CR) List A detailed listing of the current element sequence and element parameters is sent to the line printer, together with a list of the particle or beam coordinates at the end of each element and the distance and size of the nearest beam waist. M(CR) Magnet Change magnet pole tip angles and index to specified new values. Typing M6(CR) allows magnet sequence no. 6 only to have its pole angles changed. The screen is not cleared at the next D, thus successive traces may be overlaid on the same plot. N(CR) New Name A new filename and title may be given for the current data. The creation date is updated. These items appear as headings on plots and listings, and Filename is used for input and output of data to the disk. NOTE: this command in itself does not save the data. Remember to type O. O(CR) Output Sends the current data (element sequence and parameters) to the diskette where it is stored on a file with the current Filename. P(CR) Plot the current plot on the Epson dot matrix printer. If there has been no previous plot or if a new frame has been started, plots new axes followed by the trajectories. Further rays may be overlaid without replotting axes. This command is otherwise the same as D. In subsequent use of D the first trajectory displayed will be the last one plotted. NOTE: this produces high resolution labeled plots. Low resolution plots can of course be obtained with the IBM PC PrtSc key at any time. The P command will print a list of plotting captions on the plinter, but writes the plot to a disk file. After exiting the program, a utility called PLOT is invoked automatically, and this completes the plotting process. High resolution plots take several minutes to complete, and cannot be interrupted. ..page Q(CR) Quadrupole strength Option for changing any quadrupole to a specified new strength, or to optimise a pair of singlets (to which any number of other quads may be coupled) to form a waist at a specified position after the end of a given element - the reference plane.The computer asks which option is required: for the first option it asks for a new strength for each singlet in turn, or a new coupling coefficient if it is coupled. For the second option the two singlets to be optimised are chosen and the distances from the reference plane to the required waist positions (x and y) are specified (left negative, right positive). An iteration process then optimises the two singlet strengths, and the final strengths are typed out. By changing the starting strengths followed by a second Q to optimise again other waist conditions may be found, as it is possible to obtain either a broad waist with low divergence or a narrower waist with correspondingly higher divergence. Typing Qn(CR) allows a new strength to be specified for quadrupole sequence no. n only. The screen is not cleared at the next D, thus successive traces may be overlaid on the same plot. R(CR) Rearrangement of element sequence. Enables corrections to be made for typing errors at input, elements to be changed from one type to another or element parameters to be changed. The computer asks which option is required: typing -1 allows addition of a further sequence of elements to continue after the present sequence; this allows long sequences to be built up step by step, getting the required result for a simple case before making it more complex. Typing an element sequence number allows that element to be changed to a different type, or the parameters of that element to be changed. (CR) returns to the option switches (*). An automatic A is performed. Typing Rn(CR) allows element sequence no. n only to be changed. S(CR) Solenoid Change the strength of solenoid lenses. The screen is not cleared, and successive plots may be overlaid on the same plot. S7(CR) changes the strength of only solenoid sequence number 7. T(CR) Tube Change potential across accelerator tube or charge state of particles. The screen is not cleared at the next D, thus successive traces may be overlaid on the same plot. Tn(CR) allows tube sequence no. n onlyto be changed. ..page W(CR) Waist For a single ray types out the particle coordinates at the end of the specified element, or for a beam envelope types out the distance from the spcified element to the nearest beam waist, together with waist radii and divergences. Type Wn(CR) for the sizes at the end of element no. n. The overall transfer matrix from the source to the end of a given element n can be viewed by typing W-n(CR). Y(CR) Yanks the current sequence of element parameters onto the screen. The display will be lost. Yn(CR) displays data for element n only, and preserves the display. ..page References 1) T.J.L. Greenway, OPTICS program, Oxford Nuclear Physics internal report. 2) K.H. Purser, RAYPLT program - private communication. 3) A Septier, ed. Focusing of Charged Particles, Academic Press (1967) A.P. Banford, Transport of Charged Particle Beams, Spon (1966) 4) K.L. Brown, SLAC report no. 75 (1971) 5) J.D. Larson, I.E.E.E. Trans. NS-18 No.3, 1088 (1971) 6) M.M. Elkind, R.S.I. 24, 129 (1953) 7) P.J. Stenning & C.W. Trowbridge, Reading University / Rutherford Laboratory Report RU/RL 1 (1968) 8) T. Joy, N.I.M. 106, 237, (1973) 9) P. Sigmund & K.B. Winterbon, N.I.M. 119, 541 (1974) and 125, 491 (1975)