User’s Manual for elegant

Program Version 2026.1
Advanced Photon Source
Michael Borland

March 5, 2026

Note: another source of help for elegant is the on-line forum. Users are encouraged to join and participate. At minimum, users should subscribe to the “Bugs” topic, since this is where bug notifications are posted.

A set of examples and scripts is available from the software download page that demonstrates many features of elegant. A brief overview of elegant is also available, which introduces the capabilities at a high level.

Starting in Version 2025.4, AI coding assistants have been used for addition of new features and generation of documentation.

1 Highlights of What’s New in Version 2026.1
 1.1 Bug Fixes for Elements
 1.2 Bug Fixes for Commands
 1.3 New and Modified Elements
 1.4 New and Modified Commands
 1.5 Changes to Examples
 1.6 Changes to Related Programs and Files
 1.7 Known Bugs, Problems, and Limitations
2 Credits
3 Introduction
 3.1 Program Philosophy
 3.2 Capabilities of elegant
4 Digression on the Longitudinal Coordinate Definition
5 Fiducialization in elegant
6 Preparing beams for bunch-mode simulations
7 Namelist Command Dictionary
 7.1 Commandline Syntax
 7.2 General Command Syntax
 7.3 Setup and Action Commands
 7.4 Table of elegant commands and their functions
 7.5 alter_elements
 7.6 amplification_factors
 7.7 analyze_map
 7.8 aperture_data
 7.9 bunched_beam
 7.10 bunched_beam_moments
 7.11 change_end
 7.12 change_particle
 7.13 change_start
 7.14 chaos_map
 7.15 chromaticity
 7.16 closed_orbit
 7.17 correct
 7.18 correction_matrix_output
 7.19 correct_tunes
 7.20 coupled_twiss_output
 7.21 divide_elements
 7.22 elastic_scattering
 7.23 error_element
 7.24 error_control
 7.25 find_aperture
 7.26 floor_coordinates
 7.27 frequency_map
 7.28 global_settings
 7.29 ignore_elements
 7.30 include_commands
 7.31 inelastic_scattering
 7.32 insert_elements
 7.33 insert_sceffects
 7.34 ion_effects
 7.35 linear_chromatic_tracking_setup
 7.36 link_control
 7.37 link_elements
 7.38 load_parameters
 7.39 macro_output
 7.40 matrix_output
 7.41 modulate_elements
 7.42 moments_output
 7.43 momentum_aperture
 7.44 obstruction_data
 7.45 optimize
 7.46 optimization_constraint
 7.47 optimization_covariable
 7.48 optimization_setup
 7.49 parallel_optimization_setup
 7.50 particle_tunes
 7.51 optimization_term
 7.52 optimization_variable
 7.53 print_dictionary
 7.54 ramp_elements
 7.55 rf_setup
 7.56 replace_elements
 7.57 rpn_expression
 7.58 rpn_load
 7.59 run_control
 7.60 run_setup
 7.61 sasefel
 7.62 save_lattice
 7.63 sdds_beam
 7.64 semaphores
 7.65 set_reference_particle_output
 7.66 slice_analysis
 7.67 subprocess
 7.68 steering_element
 7.69 touschek_scatter
 7.70 transmute_elements
 7.71 tune_footprint
 7.72 twiss_analysis
 7.73 twiss_output
 7.74 track
 7.75 tune_shift_with_amplitude
 7.76 vary_element
8 elegant Command-file Mode for Emacs
 8.1 Introduction
 8.2 Features
 8.3 Indentation Rules
 8.4 Installation
 8.5 Customization
 8.6 Troubleshooting
 8.7 Conclusion
9 Lattice Mode for Emacs
 9.1 Introduction
 9.2 System Architecture
 9.3 Data Extraction from track_data.c
10 Installation Procedure
 10.1 Directory Layout
 10.2 Completion Behavior
 10.3 Parameter Documentation Using =TAB
 10.4 Optional Popup Completion Interfaces
 10.5 Key Binding Summary
 10.6 Conclusion
11 Specialized Tools for Use with elegant
 11.1 abrat
 11.2 astra2elegant
 11.3 computeCBGGE
 11.4 computeRBGGE
 11.5 coreEmittance
 11.6 csrImpedance
 11.7 doubleDist6
 11.8 haissinski
 11.9 ibsEmittance
 11.10 ionTrapping
 11.11 elegantto
 11.12 sddsanalyzebeam
 11.13 sddsbrightness
 11.14 sddsbunchingfactor
 11.15 sddsemitproc
 11.16 sddsfindresonances
 11.17 sddsfluxcurve
 11.18 sddsmatchtwiss
 11.19 sddsrandmult
 11.20 sddsupsample
 11.21 sddsurgent
 11.22 smoothDist6
 11.23 TFBFirSetup
 11.24 touschekLifetime
 11.25 view3dGeometry
12 Accelerator and Element Description
 12.1 Magnet Strength
13 Element Dictionary
 13.1 ALPH—An alpha magnet implemented as a matrix, up to 3rd order.
 13.2 APCONTOUR—An aperture (or its inverse) defined by (x, y) points in an SDDS file.
 13.3 BEAMBEAM—An element to provide kicks from another beam
 13.4 BEDGE—A simple dipole edge matrix
 13.5 BGGEXP—A magnetic field element using generalized gradient expansion.
 13.6 BMAPXY—A map of Bx and By vs x and y.
 13.7 BMXYZ—A map of (Bx, By, Bz) vs (x, y, z), for straight elements only
 13.8 BOFFAXE—A straight magnetic field element using off-axis expansion from an on-axis derivative.
 13.9 BRANCH—Conditional branch instruction to jump to another part of the beamline
 13.10 BRAT—Bending magnet RAy Tracing using (Bx, By, Bz) vs (x, y, z).
 13.11 BUMPER—A time-dependent kicker magnet with optional spatial dependence of the kick and no fringe effects. The waveform is in SDDS format, with time in seconds and amplitude normalized to 1. The optional spatial dependence is also specified as an SDDS file.
 13.12 CCBEND—A canonically-integrated straight dipole magnet, assumed to have multipoles defined in Cartesian coordinates.
 13.13 CENTER—An element that centers the beam transversely on the ideal trajectory.
 13.14 CEPL—A numerically-integrated linearly-ramped electric field deflector.
 13.15 CHARGE—An element to establish the total charge of a beam. Active on first pass only. If given, overrides all charge specifications on other elements.
 13.16 CKICKER—Optical stochastic cooling kicker element—applies a kick in particle momentum
 13.17 CLEAN—Cleans the beam by removing outlier particles.
 13.18 CORGPIPE—A corrugated round pipe, commonly used as a dechirper in linacs.
 13.19 CORGPLATES—A pair of corrugated plates, commonly used as a dechirper in linacs.
 13.20 CPICKUP—Optical stochastic cooling pickup element—records particle position
 13.21 CSBEND—A canonical kick sector dipole magnet.
 13.22 CSRCSBEND—Like CSBEND, but incorporates a simulation of Coherent Synchrotron radiation.
 13.23 CSRDRIFT—A follow-on element for CSRCSBEND that applies the CSR wake over a drift.
 13.24 CWIGGLER—Tracks through a wiggler using canonical integration routines of Y. Wu (Duke University).
 13.25 DQCOR—A canonically-integrated dipole/quadrupole corrector.
 13.26 DRIF—A drift space implemented as a matrix, up to 2nd order. Use EDRIFT for symplectic tracking.
 13.27 DSCATTER—A scattering element to add random changes to particle coordinates according to a user-supplied distribution function
 13.28 ECOL—An elliptical collimator.
 13.29 EDRIFT—Tracks through a drift with no approximations (Exact DRIFT).
 13.30 EHKICK—A horizontal steering dipole implemented using an exact hard-edge model
 13.31 EKICKER—A combined horizontal/vertical steering dipole implemented using an exact hard-edge model
 13.32 EMATRIX—Explicit matrix input with data in the element definition, rather than in a file.
 13.33 EMITTANCE—Applies a linear transformation to the beam to force the emittance to given values.
 13.34 ENERGY—An element that matches the central momentum to the beam momentum, or changes the central momentum or energy to a specified value.
 13.35 EVKICK—A vertical steering dipole implemented using an exact hard-edge model
 13.36 FLOOR—Sets floor coordinates
 13.37 FMULT—Multipole kick element with coefficient input from an SDDS file.
 13.38 FRFMODE—One or more beam-driven TM monopole modes of an RF cavity, with data from a file.
 13.39 FTABLE—Tracks through a magnetic field which is expressed by a SDDS table.
 13.40 FTRFMODE—One or more beam-driven TM dipole modes of an RF cavity, with data from a file.
 13.41 GFWIGGLER—Tracks through a wiggler using generate function method of J. Bahrdt and G. Wuestefeld (BESSY, Berlin, Germany).
 13.42 GKICKMAP—An ordinary kick map (use UKICKMAP for undualtors).
 13.43 HISTOGRAM—Request for histograms of particle coordinates to be output to SDDS file.
 13.44 HKICK—A horizontal steering dipole implemented as a matrix, up to 2nd order. Use EHKICK for symplectic tracking.
 13.45 HKPOLY—Applies kick according to a Hamiltonian that’s a polynomial function of x and y together with a generalized drift also given as a polynomial of qx and qy
 13.46 HMON—A horizontal position monitor, accepting a rpn equation for the readout as a function of the actual position (x).
 13.47 IBSCATTER—A simulation of intra-beam scattering.
 13.48 ILMATRIX—An Individualized Linear Matrix for each particle for fast symplectic tracking with chromatic and amplitude-dependent effects
 13.49 IONEFFECTS—Simulates ionization of residual gas and interaction with the beam.
 13.50 KICKER—A combined horizontal-vertical steering magnet implemented as a matrix, up to 2nd order. For time-dependent kickers, see BUMPER.
 13.51 KOCT—A canonical kick octupole.
 13.52 KPOLY—A thin kick element with polynomial dependence on the coordinates in one plane.
 13.53 KQUAD—A canonical kick quadrupole.
 13.54 KQUSE—A canonical kick element combining quadrupole and sextupole fields.
 13.55 KSEXT—A canonical kick sextupole, which differs from the MULT element with ORDER=2 in that it can be used for chromaticity correction.
 13.56 LGBEND—A multi-segment straight longitudinal dipole magnet
 13.57 LMIRROR—A mirror for light optics
 13.58 LRWAKE—Long-range (inter-bunch and inter-turn) longitudinal and transverse wake
 13.59 LSCDRIFT—Longitudinal space charge impedance
 13.60 LSRMDLTR—A non-symplectic numerically integrated planar undulator including optional co-propagating laser beam for laser modulation of the electron beam.
 13.61 LTHINLENS—A thin lens for light optics
 13.62 MAGNIFY—An element that allows multiplication of phase-space coordinates of all particles by constants.
 13.63 MALIGN—A misalignment of the beam, implemented as a zero-order matrix.
 13.64 MAPSOLENOID—A numerically-integrated solenoid specified as a map of (Bz, Br) vs (z, r).
 13.65 MARK—A marker, equivalent to a zero-length drift space.
 13.66 MATR—Explicit matrix input from a text file, in the format written by the print_matrix command.
 13.67 MATTER—A Coulomb-scattering and energy-absorbing element simulating material in the beam path.
 13.68 MAXAMP—A collimating element that sets the maximum transmitted particle amplitudes for all following elements, until the next MAXAMP.
 13.69 MBUMPER—A time-dependent multipole kicker magnet. The waveform is in SDDS format, with time in seconds and amplitude normalized to 1.
 13.70 MHISTOGRAM—Request for multiple dimensions (1, 2, 4 or 6) histogram output of particle coordinates.
 13.71 MODRF—A first-order matrix RF cavity with exact phase dependence, plus optional amplitude and phase modulation.
 13.72 MONI—A two-plane position monitor, accepting two rpn equations for the readouts as a function of the actual positions (x and y).
 13.73 MRFDF—Zero-length Multipole RF DeFlector from dipole to decapole
 13.74 MULT—A canonical kick multipole.
 13.75 NIBEND—A numerically-integrated dipole magnet with various extended-fringe-field models.
 13.76 NISEPT—A numerically-integrated dipole magnet with a Cartesian gradient.
 13.77 OCTU—An octupole implemented as a third-order matrix. Use KOCT for symplectic tracking.
 13.78 PEPPOT—A pepper-pot plate.
 13.79 PFILTER—An element for energy and momentum filtration.
 13.80 POLYSERIES—Tracks through a Polynomial series map specified by a file containing coefficients.
 13.81 QUAD—A quadrupole implemented as a matrix, up to 3rd order. Use KQUAD for symplectic tracking.
 13.82 QUFRINGE—An element consisting of a linearly increasing or decreasing quadrupole field.
 13.83 RAMPP—A momentum-ramping element that changes the central momentum according to an SDDS-format file of the momentum factor vs time in seconds.
 13.84 RAMPRF—A voltage-, phase-, and/or frequency-ramped RF cavity, implemented like RFCA.
 13.85 RBEN—A rectangular dipole, implemented as a SBEND with edge angles, up to 2nd order. Use CSBEND for symplectic tracking.
 13.86 RCOL—A rectangular collimator.
 13.87 RECIRC—An element that defines the point to which particles recirculate in multi-pass tracking
 13.88 REFLECT—Reflects the beam back on itself, which is useful for multiple beamline matching.
 13.89 REMCOR—An element to remove correlations from the tracked beam to simulate certain types of correction.
 13.90 RFCA—An rf cavity with exact phase dependence, first order in transverse coordinates.
 13.91 RFCW—A combination of RFCA, WAKE, TRWAKE, and LSCDRIFT.
 13.92 RFDF—A simple traveling or standing wave deflecting RF cavity.
 13.93 RFMODE—A simulation of a beam-driven TM monopole mode of an RF cavity.
 13.94 RFTM110—Tracks through a TM110-mode (deflecting) rf cavity with all magnetic and electric field components. NOT RECOMMENDED—See below.
 13.95 RFTMEZ0—A TM-mode RF cavity specified by the on-axis Ez field.
 13.96 RIMULT—Multiplies radiation integrals by a given factor. Use to compute emittance for collection of various types of cells.
 13.97 RMDF—A linearly-ramped electric field deflector, using an approximate analytical solution FOR LOW ENERGY PARTICLES.
 13.98 ROTATE—An element that rotates the beam about the longitudinal axis.
 13.99 SAMPLE—An element that reduces the number of particles in the beam by interval-based or random sampling.
 13.100 SBEN—A sector dipole implemented as a matrix, up to 2nd order. Use CSBEND for symplectic tracking.
 13.101 SCATTER—A scattering element to add random values to particle coordinates.
 13.102 SCRAPER—A collimating element that sticks into the beam from one side only. The directions 0, 1, 2, and 3 are from +x, +y, -x, and -y, respectively.
 13.103 SCRIPT—An element that allows transforming the beam using an external script.
 13.104 SEXT—A sextupole implemented as a matrix, up to 3rd order. Use KSEXT for symplectic tracking.
 13.105 SHRFDF—Simulation through space harmonics of zero length deflecting cavity.
 13.106 SLICE—Performs slice-by-slice analysis of the beam for output to a file.
 13.107 SOLE—A solenoid implemented as a matrix, up to 2nd order.
 13.108 SPEEDBUMP—Simulates a semi-circular protuberance from one or both walls of the chamber.
 13.109 SREFFECTS—Lumped simulation of synchrotron radiation effects (damping and quantum excitation) for rings.
 13.110 STRAY—A stray field element with local and global components. Global components are defined relative to the initial beamline direction.
 13.111 TAPERAPC—A tapered aperture that is a section of a circular cylinder.
 13.112 TAPERAPE—A tapered elliptical aperture.
 13.113 TAPERAPR—A tapered rectangular aperture.
 13.114 TFBDRIVER—Driver for a turn-by-turn feedback loop
 13.115 TFBPICKUP—Pickup for a turn-by-turn feedback loop
 13.116 TMCF—A numerically-integrated accelerating TM RF cavity with spatially-constant fields.
 13.117 TRCOUNT—An element that defines the point from which transmission calculations are made.
 13.118 TRFMODE—A simulation of a beam-driven TM dipole mode of an RF cavity.
 13.119 TRWAKE—Transverse wake specified as a function of time lag behind the particle.
 13.120 TSCATTER—An element to simulate Touschek scattering.
 13.121 TUBEND—A special rectangular bend element for top-up backtracking.
 13.122 TWISS—Sets Twiss parameter values.
 13.123 TWLA—A numerically-integrated first-space-harmonic traveling-wave linear accelerator.
 13.124 TWMTA—A numerically-integrated traveling-wave muffin-tin accelerator.
 13.125 TWPL—A numerically-integrated traveling-wave stripline deflector.
 13.126 UKICKMAP—An undulator kick map (e.g., using data from RADIA).
 13.127 VKICK—A vertical steering dipole implemented as a matrix, up to 2nd order. Use EVKICK for symplectic tracking.
 13.128 VMON—A vertical position monitor, accepting a rpn equation for the readout as a function of the actual position (y).
 13.129 WAKE—Longitudinal wake specified as a function of time lag behind the particle.
 13.130 WATCH—A beam property/motion monitor–allowed modes are centroid, parameter, coordinate, and fft.
 13.131 WIGGLER—A wiggler or undulator for damping or excitation of the beam.
 13.132 ZLONGIT—A simulation of a single-pass broad-band or functionally specified longitudinal impedance.
 13.133 ZTRANSVERSE—A simulation of a single-pass broad-band or functionally-specified transverse impedance.
14 Examples
15 The rpn Calculator
16 Change Log
 16.1 Highlights of What’s New in Version 2025.4
 16.2 Highlights of What’s New in Version 2025.3
 16.3 Highlights of What’s New in Version 2025.2
 16.4 Highlights of What’s New in Version 2025.1
 16.5 Highlights of What’s New in Version 2024.1
 16.6 Highlights of What’s New in Version 2023.4
 16.7 Highlights of What’s New in Version 2023.3
 16.8 Highlights of What’s New in Version 2023.2
 16.9 Highlights of What’s New in Version 2023.1
 16.10 Highlights of What’s New in Version 2022.2
 16.11 Highlights of What’s New in Version 2022.0
 16.12 Highlights of What’s New in Version 2021.4
 16.13 Highlights of What’s New in Version 2021.3
 16.14 Highlights of What’s New in Version 2021.2
 16.15 Highlights of What’s New in Version 2021.1
 16.16 Highlights of What’s New in Version 2020.5
 16.17 Highlights of What’s New in Version 2020.4
 16.18 Highlights of What’s New in Version 2020.3
 16.19 Highlights of What’s New in Version 2020.2
 16.20 Highlights of What’s New in Version 2020.1.1
 16.21 Highlights of What’s New in Version 2019.4.0
 16.22 Highlights of What’s New in Version 2019.3.0
 16.23 Highlights of What’s New in Version 2019.2.1
 16.24 Highlights of What’s New in Version 2019.1.1
 16.25 Highlights of What’s New in Version 35.1.0
 16.26 Highlights of What’s New in Version 35.0.1
 16.27 Highlights of What’s New in Version 34.4.0
 16.28 Highlights of What’s New in Version 34.3.0, June 14, 2018
 16.29 Highlights of What’s New in Version 34.2.0, March 22, 2018
 16.30 Highlights of What’s New in Version 34.1.0, 27 February 2018
 16.31 Highlights of What’s New in Version 34.0, 31 October 2017
 16.32 Highlights of What’s New in Version 33.1.1, 25 July 2017
 16.33 Highlights of What’s New in Version 33.0, March 3, 2017
 16.34 Highlights of What’s New in Version 32.0, 5 Jan. 2017
 16.35 Highlights of What’s New in Version 31.0, 1 Oct. 2016
 16.36 Highlights of What’s New in Version 30.1, 3 Aug. 2016
 16.37 Highlights of What’s New in Version 30.0, 5 July 2016
 16.38 Highlights of What’s New in Version 29.1, 3 March 2016
 16.39 Highlights of What’s New in Version 29.0, 15 Jan. 2016
 16.40 Highlights of What’s New in Version 28.1.0, 23 July 2015
 16.41 Highlights of What’s New in Version 28.0.0, 18 June 2015
References