Xtrack API

Line

class xtrack.Line(elements=(), element_names=None)
classmethod from_dict(dct, _context=None, _buffer=None, classes=())
classmethod from_sixinput(sixinput, classes=())
classmethod from_madx_sequence(sequence, classes=(), ignored_madtypes=[], exact_drift=False, drift_threshold=1e-06, install_apertures=False, apply_madx_errors=False)
to_dict()
slow_track(p)
slow_track_elem_by_elem(p, start=True, end=False)
insert_element(idx, element, name)
append_element(element, name)
get_length()
get_s_elements(mode='upstream')
remove_inactive_multipoles(inplace=False)
remove_zero_length_drifts(inplace=False)
merge_consecutive_drifts(inplace=False)
merge_consecutive_multipoles(inplace=False)
get_elements_of_type(types)
get_element_ids_of_type(types, start_idx_offset=0)
find_element_ids(element_name)

Find element_name in this Line instance’s self.elements_name list. Assumes the names are unique.

Return index before and after the element, taking into account attached _aperture instances (LimitRect, LimitEllipse, …) which would follow the element occurrence in the list.

Raises IndexError if element_name not found in this Line.

Tracker

class xtrack.Tracker(_context=None, _buffer=None, _offset=None, line=None, sequence=None, track_kernel=None, element_classes=None, particles_class=None, skip_end_turn_actions=False, particles_monitor_class=None, global_xy_limit=1.0, local_particle_src=None, save_source_as=None)
find_closed_orbit(particle_co_guess)
compute_one_turn_matrix_finite_differences(particle_on_co, dx=1e-07, dpx=1e-10, dy=1e-07, dpy=1e-10, dzeta=1e-06, ddelta=1e-07)
get_backtracker(_context=None, _buffer=None)

Beam elements

Drift

class xtrack.Drift(_xobject=None, **kwargs)

Bases: xobjects.dress.DressedDriftData, xtrack.base_element.BeamElement

Beam element modeling a drift section. Parameters:

  • length [m]: Length of the drift section. Default is 0.

isthick = True
get_backtrack_element(_context=None, _buffer=None, _offset=None)

Multipole

class xtrack.Multipole(order=None, knl=None, ksl=None, bal=None, **kwargs)

Bases: xobjects.dress.DressedMultipoleData, xtrack.base_element.BeamElement

Beam element modeling a thin magnetic multipole. Parameters:

  • order [int]: Horizontal shift. Default is 0.

  • knl [m^-n, array]: Normalized integrated strength of the normal components.

  • ksl [m^-n, array]: Normalized integrated strength of the skew components.

  • hxl [rad]: Rotation angle of the reference trajectoryin the horizzontal plane.

  • hyl [rad]: Rotation angle of the reference trajectory in the vertical plane.

  • length [m]: Length of the originating thick multipole.

to_dict()
property knl
property ksl
get_backtrack_element(_context=None, _buffer=None, _offset=None)

Cavity

class xtrack.Cavity(_xobject=None, **kwargs)

Bases: xobjects.dress.DressedCavityData, xtrack.base_element.BeamElement

Beam element modeling an RF cavity. Parameters:

  • voltage [V]: Voltage of the RF cavity. Default is 0.

  • frequency [Hz]: Frequency of the RF cavity. Default is 0.

  • lag [deg]: Phase seen by the reference particle. Default is 0.

get_backtrack_element(_context=None, _buffer=None, _offset=None)

RFMultipole

class xtrack.RFMultipole(order=None, knl=None, ksl=None, pn=None, ps=None, bal=None, phase=None, **kwargs)

Bases: xobjects.dress.DressedRFMultipoleData, xtrack.base_element.BeamElement

Beam element modeling a thin modulated multipole, with strengths dependent on the z coordinate:

kn(z) = k_n cos(2pi w tau + pn/180*pi)

ks[n](z) = k_n cos(2pi w tau + pn/180*pi)

Its parameters are:

  • order [int]: Horizontal shift. Default is 0.

  • frequency [Hz]: Frequency of the RF cavity. Default is 0.

  • knl [m^-n, array]: Normalized integrated strength of the normal components.

  • ksl [m^-n, array]: Normalized integrated strength of the skew components.

  • pn [deg, array]: Phase of the normal components.

  • ps [deg, array]: Phase of the skew components.

  • voltage [V]: Longitudinal voltage. Default is 0.

  • lag [deg]: Longitudinal phase seen by the reference particle. Default is 0.

to_dict()
property knl
property ksl
set_knl(value, order)
set_ksl(value, order)
property pn
property ps
set_pn(value, order)
set_ps(value, order)
get_backtrack_element(_context=None, _buffer=None, _offset=None)

DipoleEdge

class xtrack.DipoleEdge(r21=None, r43=None, h=None, e1=None, hgap=None, fint=None, **kwargs)

Bases: xobjects.dress.DressedDipoleEdgeData, xtrack.base_element.BeamElement

Beam element modeling a dipole edge. Parameters:

  • h [1/m]: Curvature.

  • e1 [rad]: Face angle.

  • hgap [m]: Equivalent gap.

  • fint []: Fringe integral.

to_dict()
get_backtrack_element(_context=None, _buffer=None, _offset=None)

XYShift

class xtrack.XYShift(_xobject=None, **kwargs)

Bases: xobjects.dress.DressedXYShiftData, xtrack.base_element.BeamElement

Beam element modeling an transverse shift of the reference system. Parameters:

  • dx [m]: Horizontal shift. Default is 0.

  • dy [m]: Vertical shift. Default is 0.

get_backtrack_element(_context=None, _buffer=None, _offset=None)

SRotation

class xtrack.SRotation(angle=0, **nargs)

Bases: xobjects.dress.DressedSRotationData, xtrack.base_element.BeamElement

Beam element modeling an rotation of the reference system around the s axis. Parameters:

  • angle [deg]: Rotation angle. Default is 0.

to_dict()
property angle
get_backtrack_element(_context=None, _buffer=None, _offset=None)

LimitEllipse

class xtrack.LimitEllipse(a_squ=None, b_squ=None, **kwargs)

Bases: xobjects.dress.DressedLimitEllipseData, xtrack.base_element.BeamElement

to_dict()
set_half_axes(a, b)
set_half_axes_squ(a_squ, b_squ)
get_backtrack_element(_context=None, _buffer=None, _offset=None)

LimitRect

class xtrack.LimitRect(_xobject=None, **kwargs)

Bases: xobjects.dress.DressedLimitRectData, xtrack.base_element.BeamElement

get_backtrack_element(_context=None, _buffer=None, _offset=None)

Monitors

class xtrack.ParticlesMonitor(_context=None, _buffer=None, _offset=None, start_at_turn=None, stop_at_turn=None, num_particles=None, particle_id_range=None, auto_to_numpy=True)

Bases: xobjects.dress.DressedParticlesMonitorData

at_element
at_turn
beta0
charge_ratio
chi
delta
gamma0
p0c
parent_particle_id
particle_id
psigma
px
py
rpp
rvv
s
state
weight
x
y
zeta

BeamElement base class

class xtrack.base_element.BeamElement(_xobject=None, **kwargs)
compile_track_kernel(save_source_as=None)
copy(_context=None, _buffer=None, _offset=None)
classmethod from_dict(dct)
iscollective = False
to_dict()
track(particles, increment_at_element=False)
xoinitialize(_xobject=None, **kwargs)