Members - short description
Member |
Description |
|---|---|
Load an aperture from JSON and bind it to |
|
Build an aperture from Xsuite elements that reference associated apertures. |
|
Build an aperture from limit elements installed in the line. |
|
Build an aperture from MAD-X layout metadata attached to a line. |
|
Serialize the aperture model and halo parameters to JSON. |
Member |
Description |
|---|---|
Return aperture cross-sections sampled across an element. |
|
Return aperture cross-sections at the requested s positions. |
|
Compute the maximum number of sigmas at which the beam fits in the aperture at element |
|
Compute the maximum number of sigmas at which the beam fits in the aperture at the given |
|
Compute the maximum aperture sigmas from an already sampled Twiss table. |
|
Compute beam-envelope polygons at the cuts of |
|
Compute beam-envelope polygons at the requested |
|
Compute beam envelopes from an already sampled Twiss table. |
|
Compute horizontal, vertical and diagonal (45°) max aperture sigmas at element |
|
Compute horizontal, vertical and diagonal (45°) max aperture sigmas at the given |
|
Obtain interpolated cross-sections as limit beam elements. |
|
Return a local coordinate system (each represented by a homogeneous matrix) at all |
Member |
Description |
|---|---|
Return per-profile aperture-bound information as a table. |
|
Return installed-pipe interval information as a table. |
|
Return sampling positions around aperture-profile transitions. |
|
Dictionary of halo parameters controlling beam-envelope and aperture-sigma computations. |
|
Return the pipe-position collection view. |
|
Return the pipe collection view. |
|
Return the profile collection view. |
Member |
Description |
|---|---|
Plot beam-envelope and aperture extents along the beam line. |
|
Plot installed pipe segments projected onto the floor plane. |
|
Display transverse aperture cross-sections and beam envelopes. |
Members - full description
Loading and Serialization
Go to Summary table
- classmethod Aperture.from_json(filename, line, **kwargs)
Load an aperture from JSON and bind it to
line.
- classmethod Aperture.from_line_with_associated_apertures(line, context=None, **kwargs)
Build an aperture from Xsuite elements that reference associated apertures.
- classmethod Aperture.from_line_with_limits(line, context=None, **kwargs)
Build an aperture from limit elements installed in the line.
- classmethod Aperture.from_line_with_madx_metadata(line, include_offsets=True, context=None, **kwargs)
Build an aperture from MAD-X layout metadata attached to a line.
- Aperture.to_json(filename)
Serialize the aperture model and halo parameters to JSON.
Aperture Computations
Go to Summary table
- Aperture.cross_sections_at_element(element_name: str, resolution: float | None, extents: bool = False) Table
Return aperture cross-sections sampled across an element.
- Aperture.cross_sections_at_s(s_positions: Collection[float], extents: bool = False, polygons: bool = True) Table
Return aperture cross-sections at the requested s positions.
- Parameters:
s_positions – Longitudinal positions at which to evaluate the aperture.
extents – Whether to include the aperture intersections with the transverse coordinate axes.
polygons – Whether to include the interpolated cross-section polygons.
- Aperture.get_aperture_sigmas_at_element(element_name: str, resolution: float | None = None, twiss: xtrack.twiss.TwissTable | None = None, **kwargs) tuple[xdeps.table.Table, xtrack.twiss.TwissTable]
Compute the maximum number of sigmas at which the beam fits in the aperture at element
element_name.- Parameters:
elment_name – The name of the element at which the sigmas should be computed.
resolution – The desired resolution, in meters along s, at which the sigmas should be computed. If not provided only the values at the entry and exit will be output.
twiss – Optionally provided twiss table from which to derive the initial beam parameters at the element.
**kwargs – Other parameters to be forwarded to
get_aperture_sigmas_at_s().
- Return type:
- Aperture.get_aperture_sigmas_at_s(s_positions: Iterable[float], twiss_init: xtrack.twiss.TwissInit | None = None, method: Literal['bisection', 'rays', 'exact'] = 'rays', envelopes_num_points: int = 36, num_rays: int = 32, output_max_envelopes: bool = False, output_cross_sections: bool = False) tuple[xdeps.table.Table, xtrack.twiss.TwissTable]
Compute the maximum number of sigmas at which the beam fits in the aperture at the given
s_positions.- Parameters:
s_positions – List of s positions at which to calculate the sigmas.
twiss_init – Optionally provided initial twiss conditions.
method –
A method to use for the computation: - ‘rays’ - the aperture sigma is estimated from sampled rays and the minimum over the sampled directions
is returned (faster method, O(R) where R is the number of rays)
’exact’ - the aperture sigma is estimated from sampled points on the halo racetrack, at which new sample rays are emitted to compare the local directional sigma to the aperture (O(R^2), where R is the number of rays).
’bisection’ - the smallest number of sigmas for the beam to fit in the aperture is computed by bisecting on a polygon-inside-polygon problem (slower method, O(EAK), where E is the number of envelope points, A is the number of aperture points, and K is the number of bisection steps; currently K <= 25, this depends on the tolerance and search space set in
beam_aperture.h).
envelopes_num_points – Number of points to use when discretising the beam cross-section.
num_rays – Only for methods rays and exact: number of evenly-spaced ray directions to sample in [0, 2 * pi).
output_max_envelopes – If true, output beam-envelope polygons at the computed n1.
output_cross_sections – If true, output interpolated aperture cross-sections.
- Returns:
A two-tuple
(table, sliced_twiss), wheretableis anxdeps.table.Tablewith columnssandn1.
if
output_cross_sectionsis true,tablealso containscross_section.
if
output_max_envelopesis true,tablealso containsenvelope.
sliced_twissis the twiss table computed as part of the calculation.
- Aperture.get_aperture_sigmas_for_twiss(sliced_twiss: TwissTable, method: Literal['bisection', 'rays', 'exact'] = 'rays', envelopes_num_points: int = 36, num_rays: int = 32, output_max_envelopes: bool = False, output_cross_sections: bool = False) Table
Compute the maximum aperture sigmas from an already sampled Twiss table.
Unlike
get_aperture_sigmas_at_s(), this method does not slice the line or calculate Twiss parameters. Each row ofsliced_twissis used directly to determine the maximum beam size that fits in the aperture.- Parameters:
sliced_twiss – Twiss table containing the longitudinal positions and optical quantities at which to compute the aperture sigmas.
method –
Algorithm used to determine the limiting sigma:
'rays'estimates the limit along evenly spaced ray directions.'exact'samples the halo racetrack and emits additional rays from those points.'bisection'searches for the largest envelope polygon contained in the aperture polygon.
envelopes_num_points – Number of points used to discretise beam-envelope polygons.
num_rays – Number of evenly spaced ray directions used by the
'rays'and'exact'methods.output_max_envelopes – Whether to include beam-envelope polygons at the computed sigma.
output_cross_sections – Whether to include the interpolated aperture cross-sections.
- Returns:
Table with one row per row of
sliced_twissand the following columns:index: row index.s: longitudinal position.n1: maximum number of beam sigmas that fit in the aperture.cross_section: aperture polygon, included whenoutput_cross_sectionsis true.envelope: beam-envelope polygon atn1, included whenoutput_max_envelopesis true.
- Return type:
table
- Aperture.get_envelope_at_element(element_name: str, sigmas: float, resolution: float | None = None, twiss: xtrack.twiss.TwissTable | None = None, **kwargs) tuple[xdeps.table.Table, xtrack.twiss.TwissTable]
Compute beam-envelope polygons at the cuts of
element_namefor a fixed sigma value.- Parameters:
element_name – The name of the element at which the envelope should be computed.
sigmas – The beam size, in sigmas, at which the envelope should be evaluated.
resolution – The desired resolution, in meters along s, at which the envelope should be computed. If not provided only the values at the entry and exit will be output.
twiss – Optionally provided twiss table from which to derive the initial beam parameters at the element.
**kwargs – Other parameters to be forwarded to
Aperture.get_envelope_at_s.
- Returns:
A two-tuple
(envelopes, sliced_twiss), whereenvelopesis the table returned byget_envelope_at_s().
sliced_twissis the twiss table computed as part of the calculation.
- Aperture.get_envelope_at_s(s_positions: Iterable[float], sigmas: float, twiss_init: xtrack.twiss.TwissInit | None = None, envelopes_num_points: int = 128, include_aper_tols: bool = True, polygons: bool = True, extents: bool = False) tuple[xdeps.table.Table, xtrack.twiss.TwissTable]
Compute beam-envelope polygons at the requested
s_positionsfor a fixed sigma value.- Parameters:
s_positions – List of s positions at which to compute the envelope.
sigmas – The beam size, in sigmas, at which the envelope should be evaluated.
twiss_init – Optionally provided initial twiss conditions.
envelopes_num_points – Number of points to use when discretising the beam cross-section polygon.
include_aper_tols – If true, include the aperture mechanical tolerances associated with the active profile at each
s.polygons – Whether to include the beam-envelope polygons in the output table.
extents – Whether to include the horizontal and vertical envelope extents.
- Returns:
A two-tuple
(envelopes, sliced_twiss), whereenvelopesis a table containing the sampled longitudinal positions and – the requested polygon and extent outputs.
sliced_twissis the twiss table computed as part of the calculation.
- Aperture.get_envelope_for_twiss(sliced_twiss: TwissTable, sigmas: float, envelopes_num_points: int, include_aper_tols: bool, polygons: bool, extents: bool) Table
Compute beam envelopes from an already sampled Twiss table.
Unlike
get_envelope_at_s(), this method does not slice the line or calculate Twiss parameters. Each row ofsliced_twissis used directly to construct the beam envelope at the requested sigma level.- Parameters:
sliced_twiss – Twiss table containing the longitudinal positions and optical quantities at which to compute the envelopes.
sigmas – Sigma level at which to evaluate the beam envelope.
envelopes_num_points – Number of points used to discretise each envelope polygon.
include_aper_tols – Whether to enlarge the beam envelope by the mechanical tolerances of the active aperture profile at each longitudinal position.
polygons – Whether to include the discretised envelope polygons in the output.
extents – Whether to include the minimum and maximum horizontal and vertical coordinates of each envelope.
- Returns:
Table with one row per row of
sliced_twissand the following columns:index: row index.s: longitudinal position.cross_section: envelope polygon, included whenpolygonsis true.min_xandmax_x: horizontal extents, included whenextentsis true.min_yandmax_y: vertical extents, included whenextentsis true.
- Return type:
table
- Aperture.get_hvd_aperture_sigmas_at_element(element_name: str, resolution: float | None = None, twiss: xtrack.twiss.TwissTable | None = None) tuple[xdeps.table.Table, xtrack.twiss.TwissTable]
Compute horizontal, vertical and diagonal (45°) max aperture sigmas at element
element_name.- Parameters:
elment_name – The name of the element at which the sigmas should be computed.
resolution – The desired resolution, in meters along s, at which the sigmas should be computed. If not provided only the values at the entry and exit will be output.
twiss – Optionally provided twiss table from which to derive the initial beam parameters at the element.
**kwargs – Other parameters to be forwarded to
get_hvd_aperture_sigmas_at_s().
- Return type:
- Aperture.get_hvd_aperture_sigmas_at_s(s_positions: Iterable[float], twiss_init: xtrack.twiss.TwissInit | None = None) tuple[xdeps.table.Table, xtrack.twiss.TwissTable]
Compute horizontal, vertical and diagonal (45°) max aperture sigmas at the given
s_positions.- Parameters:
s_positions – Locations at which to compute the desired quantities.
twiss_init – Initial conditions for the twiss.
- Returns:
A two-tuple
(table, sliced_twiss)tableis anxdeps.table.Tablewith columnss, –n1_horizontal,n1_vertical,n1_diagonal, and
cross_section.sliced_twissis the twiss table computed as part of the calculation.
- Aperture.get_limit_elements(s_positions: list[float]) dict[float, Union[xtrack.beam_elements.apertures.LimitRect, xtrack.beam_elements.apertures.LimitEllipse, xtrack.beam_elements.apertures.LimitRectEllipse, xtrack.beam_elements.apertures.LimitRacetrack, xtrack.beam_elements.apertures.LimitPolygon]]
Obtain interpolated cross-sections as limit beam elements.
- Aperture.poses_at_s(s_positions: Collection[float]) dtype[dtype('float64')]]
Return a local coordinate system (each represented by a homogeneous matrix) at all
s_positions.
Introspection
Go to Summary table
- Aperture.get_bounds_table() Table
Return per-profile aperture-bound information as a table.
- Returns:
Table with the following columns: -
name: name of the aperture bound, formed from the pipe-positionname and, when needed, a
::isuffix identifying the profile order within the pipepipe_name: name of the pipe in which the installed profile appearsprofile_name: name of the installed profiles: survey position at which the installed profile plane intersects the reference curves_start,s_end: longitudinal footprint of the installed profile on the surveyshape: profile shape nameshape_param: dictionary of profile shape parameters
- Return type:
bounds_table
- Aperture.get_pipe_table()
Return installed-pipe interval information as a table.
- Returns:
Table with the following columns: -
name: pipe-position name -pipe_name: underlying pipe (type) name -survey_reference: survey element used as the placement reference -s_start,s_end: interval covered by the installed profilecentre positions
length: length of that centre-position intervals_span_start,s_span_end: longitudinal footprint of the projected aperture itselfspan: length of that aperture-footprint interval
For rings, wrapped intervals are represented with
s_start > s_endand likewise fors_span_start > s_span_end.- Return type:
pipe_table
- Aperture.s_around_transitions(tol: float | None = None, resolution: float | None = None, s_range: tuple[float, float] | None = None) ndarray
Return sampling positions around aperture-profile transitions.
The positions are built from the longitudinal locations of the installed aperture bounds. For each stored
sposition, the method emits points ats - tolands + tol. This is useful when sampling quantities that can change abruptly at profile transitions.- Parameters:
tol – Offset applied on both sides of each transition bound. If omitted, use
self.s_tol.resolution – If provided, add a regular grid of sampling points spaced by this step size and union it with the transition-based points.
s_range – If provided, restrict the returned positions to this longitudinal interval. For rings, wrapped intervals are supported.
- Returns:
Sorted, unique
spositions clipped to the line extent.- Return type:
np.ndarray
- property Aperture.halo_params: dict
Dictionary of halo parameters controlling beam-envelope and aperture-sigma computations.
The keys and their default values are:
Key
Default
Description
emitx_norm3.5e-6
Normalised horizontal emittance [m·rad]
emity_norm3.5e-6
Normalised vertical emittance [m·rad]
delta_rms0.0
RMS momentum spread
tol_co0.0
Closed-orbit tolerance [m]
tol_disp0.0
Normalised dispersion tolerance [m]
tol_disp_ref1.8
Reference dispersion derivative tolerance [m]
tol_disp_ref_beta170
Reference dispersion beta-function [m]
tol_beta_beating1.0
Beta-beating tolerance [sigma]
halo_x6.0
Horizontal halo size [sigma]
halo_y6.0
Vertical halo size [sigma]
halo_r6.0
45° halo size [sigma]
halo_primary6.0
Primary halo size [sigma]
The dictionary is mutable; individual entries can be changed with
aperture.halo_params['key'] = valueor in bulk withaperture.halo_params.update({...}).
- property Aperture.pipe_positions: PipePositionsView
Return the pipe-position collection view.
- property Aperture.pipes: PipesView
Return the pipe collection view.
- property Aperture.profiles: ProfilesView
Return the profile collection view.
Visualization
Go to Summary table
- Aperture.plot_extents(s_positions: Collection[float], sigmas: float | None = None, twiss_init: xtrack.twiss.TwissInit | None = None, method: Literal['bisection', 'rays', 'exact'] = 'rays', envelopes_num_points: int = 64, include_aper_tols: bool = False, plot_s_positions: collections.abc.Collection[float] | None = None, axs=None)
Plot beam-envelope and aperture extents along the beam line.
- Parameters:
s_positions – Longitudinal positions at which the aperture cross-sections and beam envelopes are evaluated.
sigmas – Sigma level used to build the beam envelope. If omitted, the minimum available aperture sigma across
s_positionsis computed usingmethod.twiss_init – Twiss initial conditions forwarded to the envelope and aperture-sigma computations.
method – Method used to compute the maximum aperture sigmas when
sigmasis not given.envelopes_num_points – Number of points used to discretise each transverse beam envelope.
include_aper_tols – Whether aperture tolerances should be included in the beam-envelope computation.
plot_s_positions – Coordinates to be used on the horizontal axis. If omitted,
s_positionsare used directly. This is useful when the data are evaluated at one set of longitudinal positions but should be displayed against another abscissa, for example a shifted, reversed, or externally defined coordinate.axs – Two axes on which to draw the horizontal and vertical extents. If not provided, a new figure with two shared-x subplots is created.
- Returns:
fig (matplotlib.figure.Figure) – Figure containing the plots.
axs (sequence of matplotlib.axes.Axes) – The x- and y-extent axes, in that order.
- Aperture.plot_floor_projection(ax=None, max_curve_angle_rad: float = np.float64(0.017453292519943295), origin: str | None = None, s_range: tuple[float, float] | None = None, aspect: Literal['auto', 'equal'] = 'auto')
Plot installed pipe segments projected onto the floor plane.
- Parameters:
ax – Axes object to plot on. If not given, use the current axes.
max_curve_angle_rad – Maximum angular step used to draw curved pipe boundaries and axes.
origin – Name of a pipe position to use as the plotting origin. When given, the floor projection is expressed in the local frame of that pipe position.
s_range – Longitudinal window, relative to
originwhen provided, used to restrict which pipe segments are plotted. On rings, wrapped ranges are handled across the end of the line.aspect – Aspect ratio applied to the axes after plotting.
- Returns:
ax – Axes containing the floor projection.
- Return type:
matplotlib.axes.Axes
- Aperture.plot_transverse(name: str | None = None, s_positions: collections.abc.Collection[float] | None = None, resolution: float = 0.1, sigmas: float | None = None, method: Literal['bisection', 'rays', 'exact'] = 'rays', twiss_init: xtrack.twiss.TwissInit | None = None, middle='beam', ax=None)
Display transverse aperture cross-sections and beam envelopes.
- Parameters:
name – Name of the element at which to plot. If given,
s_positionsare obtained from the element entry, exit, and optional resolution cuts.s_positions – Longitudinal positions to plot directly. Provide either
nameors_positions.resolution – The desired resolution, in metres along s, when plotting an element.
sigmas – The number of sigmas to plot. If
None, compute and plot the limitingn1usingmethod.method – If
sigmasisNone, method used to compute the limitingn1.twiss_init – Optional initial Twiss conditions forwarded to the envelope and aperture-sigma calculations.
middle – Whether the plot should be centred around the
aperturemiddle, orbeamreference.ax – Axes object to plot on, if not given, spawn a new one.
- Returns:
ax – Plot’s axes object.
- Return type:
matplotlib.axes.Axes