at.load.elegant#
Using Elegant files with PyAT#
PyAT can read lattice descriptions in Elegant format (.lte files), and can export lattices in Elegant format.
However, because of intrinsic differences between PyAT and Elegant, some incompatibilities must be taken into account.
1. Translation losses#
Multipoles#
Elegant thick multipoles are limited to a single multipole order. For AT
Multipole
elements combining several orders, the lowest order is converted
and higher orders are discarded. AT ThinMultipole
elements are expanded
to a series of thin MULT
elements with 0 length.
Elegant elements absent from AT#
Many Elegant elements have no equivalent in AT. They are replaced by
Marker
or Drift
elements, depending on their length.
Incompatible attributes#
Some AT element attributes have no Elegant equivalent, and vice versa.
When exporting to an Elegant file:
FringeBendEntrance, FringeBendExit, FringeQuadEntrance, FringeQuadExit are discarded,
R1, R2, T1, T2 are discarded,
RApertures, EApertures are discarded.
When reading an Elegant file:
TILT is interpreted and converted to R1 and R2 attributes,
DX, DZ are converted to T1`and `T2 attributes,
N_SLICES, if specified, is converted to NumIntSteps. If not, NumIntSteps is left to is default value (10).
2. Usage#
Usage Elegant files is similar to using MAD-X files. The Elegant RPN calculator is emulated.
3. Functions and classes#
Functions
|
Create a |
Classes
|
Elegant parser |
- class ElegantParser(**kwargs)[source]#
Bases:
UpperCaseParser
,BaseParser
Elegant parser
The parser is a subclass of
dict
and is a database containing all the Elegant objects.Example
Parse a file:
>>> parser = at.ElegantParser() >>> parser.parse_file("file1")
Look at the “qf1” element
>>> parser["QF1"] QUAD(name=QF1, l=1.0, k1=0.5, tilt=0.001)
Generate an AT
Lattice
from the “RING” sequence>>> ring = parser.lattice(use="RING") # generate an AT Lattice
- Parameters:
verbose – If
True
, print details on the processing**kwargs – Initial variable definitions
- clear()#
Clear the database: remove all parameters and objects
- evaluate(expr)#
Evaluate the right side of an expression
- Parameters:
expr (str) – expression to evaluate
- Returns:
value – evaluated expression
- expand(key)#
iterator over AT objects generated by a source object
- lattice(use='ring', **kwargs)#
Create a lattice from the selected sequence
- Parameters:
use – Name of the sequence or line containing the desired lattice. Default:
ring
- Keyword Arguments:
name (str) – Name of the lattice. Default: sequence name.
particle (Particle) – Circulating particle. Default: Particle(“relativistic”)
energy (float) – Energy of the lattice [eV]. Default: 1.0 GeV
periodicity (int) – Number of periods. Default: 1
* – All other keywords will be set as Lattice attributes
- parse_files(*filenames, final=True, prolog=None, epilog=None, **kwargs)#
Process files and fill the database
- parse_lines(lines, *, final=True, **kwargs)#
Process input lines and fill the database
- property ignored#
Set of ignored commands
- property missing#
Set of missing definitions
- property sequences#
List of available sequences or lines
- load_elegant(*files, use='RING', verbose=False, **kwargs)[source]#
Create a
Lattice
from Elegant lattice filesElegant lattice files do not specify the beam energy.
ElegantParser
sets it by default to 1.0 GeV. Use the energy keyword to set it to the desired value.Long elements are split according to the default AT value of NumIntSteps (10) unless N_SLICES is specified in the Elegant element definition.
- Parameters:
- Keyword Arguments:
name (str) – Name of the lattice. Default: Elegant sequence name
particle (Particle) – Circulating particle. Default: Particle(“relativistic”)
energy (float) – Energy of the lattice [eV]. Default: 1.0E9
periodicity (int) – Number of periods. Default: 1
* – Other keywords will be used as Lattice attributes
- Returns:
lattice (Lattice) – New
Lattice
object
See also
load_lattice()
for a generic lattice-loading function.