at.tracking.utils#

Utility functions for tracking simulations

Functions

fortran_align(func)

decorator to ensure that r_in is Fortran-aligned

get_bunches(r_in, nbunch[, selected_bunches])

Function to get the bunches particles 6D coordinates

format_results(results, r_in, losses)

Function to format the ouput of parallelized tracking

get_bunches_std_mean(r_in, nbunch[, ...])

Function to get the bunches standard deviation and center of mass

unfold_beam(ring, beam, **kwargs)

Function to unfold the beam based on the ring fill pattern.

has_collective(ring)

True if any element involves collective effects

initialize_lpass(lattice, nturns, kwargs)

Function to initialize keyword arguments for lattice tracking

disable_varelem(ring)

Function to disable collective effects elements

variable_refs(ring)

disable_varelem(ring)[source]#

Function to disable collective effects elements

format_results(results, r_in, losses)[source]#

Function to format the ouput of parallelized tracking

fortran_align(func)[source]#

decorator to ensure that r_in is Fortran-aligned

fortran_align() ensures that the 2nd argument (usually r_in) of the decorated function is Fortran-aligned before calling the function

Example

>>> @fortran_align
... def element_pass(element: Element, r_in, **kwargs):
... ...

Ensure that r_in is Fortran-aligned

get_bunches(r_in, nbunch, selected_bunches=None)[source]#

Function to get the bunches particles 6D coordinates

Parameters:
  • r_in (ndarray) – 6 x n_particles Fortran-ordered numpy array.

  • nbunch (int) – integer, total number of bunches

  • selected_bunches (ndarray | None) – integer or array of integers, index

  • bunches (of the selected)

Returns:
  • List of ndarray containing the 6 x n particles coordinates

  • of the selected bunches

get_bunches_std_mean(r_in, nbunch, selected_bunches=None)[source]#

Function to get the bunches standard deviation and center of mass

Parameters:
  • r_in (ndarray) – 6 x n_particles Fortran-ordered numpy array.

  • nbunch (int) – integer, total number of bunches

  • selected_bunches (ndarray | None) – integer or array of integers, index

  • bunches (of the selected)

Returns:
  • Lists of ndarray containing the 6D standard deviation

  • and center of mass (std, mean)

has_collective(ring)[source]#

True if any element involves collective effects

initialize_lpass(lattice, nturns, kwargs)[source]#

Function to initialize keyword arguments for lattice tracking

unfold_beam(ring, beam, **kwargs)[source]#

Function to unfold the beam based on the ring fill pattern. The input particle distribution has to be in on bucket 0. Particle are distributed in bunches using i%ring.nbunch where i is the particle index. For each bunches the absolute ct is computed using the 6D closed orbit search, this closed orbit is added to the input particles.

Parameters:
  • ring (Lattice) – Lattice description

  • beam (ndarray) – array with shape(6, nparticles)

Keyword Arguments:
Returns:

beam (numpy.ndarray) – unfolded beam

Return type:

ndarray

variable_refs(ring)[source]#