at.lattice.elements#
Module to define common elements used in AT.
Each element has a default PassMethod attribute for which it should have the appropriate attributes. If a different PassMethod is set, it is the caller’s responsibility to ensure that the appropriate attributes are present.
Functions
Classes
|
Aperture element |
|
Element to compute bunches mean and std |
alias of |
|
Mixin class for elements representing collective effects |
|
|
Collimator element |
|
Corrector element |
|
Dipole element |
|
Drift space element |
|
Base class for AT elements |
|
Base class for long elements |
Abstract Base class for all Element classes whose instances may modify the particle momentum |
|
|
Linear (6, 6) transfer matrix |
|
Marker element |
|
Monitor element |
|
Multipole element |
|
Octupole element, with no changes from multipole at present |
|
Quadrupole element |
|
Quantum diffusion element |
|
RF cavity element |
Mixin class for default radiating elements ( |
|
|
Sextupole element |
|
Thin multipole element |
|
Wiggler element |
- class Aperture(family_name, limits, **kwargs)[source]#
Bases:
ElementAperture element
- Parameters:
family_name – Name of the element
limits – (4,) array of physical aperture: [xmin, xmax, zmin, zmax] [m]
Default PassMethod:
AperturePass
- class BeamMoments(family_name, **kwargs)[source]#
Bases:
ElementElement to compute bunches mean and std
- Parameters:
family_name (str) – Name of the element
All keywords will be set as attributes of the element
- property means#
- property stds#
- class Collective[source]#
Bases:
_DictLongtMotionMixin class for elements representing collective effects
Derived classes will automatically set the
is_collectiveproperty when the element is active.The class must have a
default_passclass attribute, a dictionary such that:default_pass[False]is the PassMethod when collective effects are turned OFF,default_pass[True]is the default PassMethod when collective effects are turned ON.
The
Collectiveclass must be set as the first base class.Example
>>> class WakeElement(Collective, Element): ... ... default_pass = {False: 'IdentityPass', True: 'WakeFieldPass'}
Defines a class where the
is_collectiveproperty is handled
- class Collimator(family_name, length, limits, **kwargs)[source]#
Bases:
DriftCollimator element
- Parameters:
Default PassMethod:
DriftPass
- class Corrector(family_name, length, kick_angle, **kwargs)[source]#
Bases:
LongElementCorrector element
- Parameters:
Default PassMethod:
CorrectorPass
- class Dipole(family_name, length, bending_angle=0.0, k=0.0, **kwargs)[source]#
-
Dipole element
- Parameters:
- Keyword Arguments:
EntranceAngle=0.0 – entrance angle
ExitAngle=0.0 – exit angle
PolynomB – straight multipoles
PolynomA – skew multipoles
MaxOrder – Number of desired multipoles
NumIntSt=10 – Number of integration steps
FullGap – Magnet full gap
FringeInt1 – Fringe field extension
FringeInt2 –
FringeBendEntrance –
1: legacy version Brown First Order (default)
2: SOLEIL close to second order of Brown
3: THOMX
FringeBendExit – See
FringeBendEntranceFringeQuadEntrance –
0: no fringe field effect (default)
1: Lee-Whiting’s thin lens limit formula
2: elegant-like
FringeQuadExit – See
FringeQuadEntrancefringeIntM0 – Integrals for FringeQuad method 2
fringeIntP0 –
KickAngle – Correction deviation angles (H, V)
Default PassMethod:
BndMPoleSymplectic4Pass- DefaultOrder = 0#
- class Drift(family_name, length, **kwargs)[source]#
Bases:
LongElementDrift space element
Default PassMethod:
DriftPass- insert(insert_list)[source]#
insert elements inside a drift
- Parameters:
insert_list (Iterable[Tuple[float, Optional[Element]]]) –
iterable, each item of insert_list is itself an iterable with 2 objects:
the location where the center of the element will be inserted, given as a fraction of the Drift length.
an element to be inserted at that location. If
None, the drift will be divided but no element will be inserted.
- Returns:
elem_list – a list of elements.
Drifts with negative lengths may be generated if necessary.
Examples
>>> Drift('dr', 2.0).insert(((0.25, None), (0.75, None))) [Drift('dr', 0.5), Drift('dr', 1.0), Drift('dr', 0.5)]
>>> Drift('dr', 2.0).insert(((0.0, Marker('m1')), ... (0.5, Marker('m2')))) [Marker('m1'), Drift('dr', 1.0), Marker('m2'), Drift('dr', 1.0)]
>>> Drift('dr', 2.0).insert(((0.5, Quadrupole('qp', 0.4, 0.0)),)) [Drift('dr', 0.8), Quadrupole('qp', 0.4), Drift('dr', 0.8)]
- class Element(family_name, **kwargs)[source]#
Bases:
objectBase class for AT elements
- Parameters:
family_name (str) – Name of the element
All keywords will be set as attributes of the element
- divide(frac)[source]#
split the element in len(frac) pieces whose length is frac[i]*self.Length
- Parameters:
frac – length of each slice expressed as a fraction of the initial length.
sum(frac)may differ from 1.- Returns:
elem_list – a list of elements equivalent to the original.
Example
>>> Drift('dr', 0.5).divide([0.2, 0.6, 0.2]) [Drift('dr', 0.1), Drift('dr', 0.3), Drift('dr', 0.1)]
- equals(other)[source]#
Whether an element is equivalent to another.
This implementation was found to be too slow for the generic __eq__ method when comparing lattices.
- class LongElement(family_name, length, *args, **kwargs)[source]#
Bases:
ElementBase class for long elements
Other arguments and keywords are given to the base class
- divide(frac)[source]#
split the element in len(frac) pieces whose length is frac[i]*self.Length
- Parameters:
frac – length of each slice expressed as a fraction of the initial length.
sum(frac)may differ from 1.- Returns:
elem_list – a list of elements equivalent to the original.
Example
>>> Drift('dr', 0.5).divide([0.2, 0.6, 0.2]) [Drift('dr', 0.1), Drift('dr', 0.3), Drift('dr', 0.1)]
- class LongtMotion[source]#
Bases:
ABCAbstract Base class for all Element classes whose instances may modify the particle momentum
Allows to identify elements potentially inducing longitudinal motion.
Subclasses of
LongtMotionmust provide two methods for enabling longitudinal motion:_get_longt_motion(self)must return the activation state,set_longt_motion(self, enable, new_pass=None, copy=False, **kwargs)must enable or disable longitudinal motion.
- class M66(family_name, m66=None, **kwargs)[source]#
Bases:
ElementLinear (6, 6) transfer matrix
- Parameters:
family_name (str) – Name of the element
m66 – Transfer matrix. Default: Identity matrix
Default PassMethod:
Matrix66Pass
- class Marker(family_name, **kwargs)[source]#
Bases:
ElementMarker element
- Parameters:
family_name (str) – Name of the element
All keywords will be set as attributes of the element
- class Monitor(family_name, **kwargs)[source]#
Bases:
ElementMonitor element
- Parameters:
family_name (str) – Name of the element
All keywords will be set as attributes of the element
- class Multipole(family_name, length, poly_a, poly_b, **kwargs)[source]#
Bases:
_Radiative,LongElement,ThinMultipoleMultipole element
- Parameters:
- Keyword Arguments:
MaxOrder – Number of desired multipoles. Default: highest index of non-zero polynomial coefficients
NumIntSteps – Number of integration steps (default: 10)
KickAngle – Correction deviation angles (H, V)
Default PassMethod:
StrMPoleSymplectic4Pass
- class Octupole(family_name, length, poly_a, poly_b, **kwargs)[source]#
Bases:
MultipoleOctupole element, with no changes from multipole at present
- Parameters:
- Keyword Arguments:
MaxOrder – Number of desired multipoles. Default: highest index of non-zero polynomial coefficients
NumIntSteps – Number of integration steps (default: 10)
KickAngle – Correction deviation angles (H, V)
Default PassMethod:
StrMPoleSymplectic4Pass- DefaultOrder = 3#
- class Quadrupole(FamName, Length, Strength=0, **keywords)[source]#
-
Quadrupole element
- Parameters:
- Keyword Arguments:
PolynomB – straight multipoles
PolynomA – skew multipoles
MaxOrder – Number of desired multipoles
NumIntSteps=10 – Number of integration steps
FringeQuadEntrance –
0: no fringe field effect (default)
1: Lee-Whiting’s thin lens limit formula
2: elegant-like
FringeQuadExit – See
FringeQuadEntrancefringeIntM0 – Integrals for FringeQuad method 2
fringeIntP0 –
KickAngle – Correction deviation angles (H, V)
Default PassMethod:
StrMPoleSymplectic4Pass- DefaultOrder = 1#
- class QuantumDiffusion(family_name, lmatp, **kwargs)[source]#
Bases:
_DictLongtMotion,ElementQuantum diffusion element
- Parameters:
family_name (str) – Name of the element
lmatp (ndarray) – Diffusion matrix for generation (see
gen_quantdiff_elem())
Default PassMethod:
QuantDiffPass- default_pass = {False: 'IdentityPass', True: 'QuantDiffPass'}#
- class RFCavity(family_name, length, voltage, frequency, harmonic_number, energy, **kwargs)[source]#
Bases:
LongtMotion,LongElementRF cavity element
- Parameters:
- Keyword Arguments:
TimeLag=0 – Cavity time lag
Default PassMethod:
RFCavityPass- default_pass = {False: 'DriftPass', True: 'RFCavityPass'}#
- class Radiative[source]#
Bases:
_RadiativeMixin class for default radiating elements (
Dipole,Quadrupole,Wiggler)Radiativeis a base class for the subset of radiative elements considered as the ones to be turned on by default:Dipole,QuadrupoleandWiggler, excluding the higher order multipoles.Radiativeinherits from_Radiativeand does not add any new functionality. Its purpose is to identify the default set of radiating elements.Example
>>> class Dipole(Radiative, Multipole):
Defines a class belonging to the default radiating elements. It converts the PassMethod according to the “*Pass” or “*RadPass” suffix.
- class Sextupole(family_name, length, h=0.0, **kwargs)[source]#
Bases:
MultipoleSextupole element
- Parameters:
- Keyword Arguments:
PolynomB – straight multipoles
PolynomA – skew multipoles
MaxOrder – Number of desired multipoles
NumIntSteps=10 – Number of integration steps
KickAngle – Correction deviation angles (H, V)
Default PassMethod:
StrMPoleSymplectic4Pass- DefaultOrder = 2#
- class ThinMultipole(family_name, poly_a, poly_b, **kwargs)[source]#
Bases:
ElementThin multipole element
- Parameters:
family_name (str) – Name of the element
poly_a – Array of normal multipole components
poly_b – Array of skew multipole components
- Keyword Arguments:
MaxOrder – Number of desired multipoles. Default: highest index of non-zero polynomial coefficients
Default PassMethod:
ThinMPolePass
- class Wiggler(family_name, length, wiggle_period, b_max, energy, Nstep=5, Nmeth=4, By=(1, 1, 0, 1, 1, 0), Bx=(), **kwargs)[source]#
Bases:
Radiative,LongElementWiggler element
See atwiggler.m
- Parameters:
length (float) – total length of the wiggler
wiggle_period (float) – length must be a multiple of this
b_max (float) – peak wiggler field [Tesla]
energy (float) – beam energy [eV]
Nmeth (Optional[int]) – symplectic integration order: 2 or 4
Bx – harmonics for horizontal wiggler: (6, nHharm) array-like object
By – harmonics for vertical wiggler (6, nHharm) array-like object
Default PassMethod:
GWigSymplecticPass