at.acceptance.floodfill_acceptance#

This is an implementation of the Flood Fill algorithm for pyat.

Functions

floodfill(ring[, nturns, window, grid_size, ...])

Find the 2D acceptance of the ring using Flood Fill [1].

floodfill(ring, nturns=1000, window=(-0.01, 0.01, -0.01, 0.01), grid_size=(10, 10), axes=(0, 2), offset=None, verbose=False, use_mp=True, pool_size=10)[source]#

Find the 2D acceptance of the ring using Flood Fill [1].

Flood fill [1] tracks particles from the exterior to the border of the acceptance. The lost particles are returned in plost. The not lost particles are returned in pnotlost.

Parameters:
  • ring (Lattice) – pyat lattice

  • nturns (int) – Number of turns for the tracking. Default: 1000

  • window (list | tuple) – Min and max coordinate range, [Axis1min,Axis1max, Axis2min,Axis2max]. Default [-10e-3,10e-3,-10e-3,10e-3]. Axis1 and Axis2 are defined by ‘axes’.

  • grid_size (list | tuple) – Number of steps per axis. Default [10,10].

  • axes (list | tuple) – Indexes of axes to be scanned. Default is [0,2], i.e. x-y

  • offset (list | ndarray | None) – Offset to be added. Default np.zeros((6)). This is useful to study off-axis acceptance on any plane, or off-momentum acceptance by adding dp to the 5th coord., to track particles on the closed orbit, or to add a small deviation to the tracked coordinates, e.g. [10e-5 10e-5] in the transverse planes.

  • verbose (bool) – Print extra info. Default 0.

  • use_mp (bool | MPMode) – Parallel tracking, default True. It uses at.MPMode.CPU, not at.MPMode.GPU.

  • pool_size (int) – Number of cpus.

Returns:

A (4,n) – Position on axis 1 of the n tracked particles Position on axis 2 of the n tracked particles Flag set to 1 if the nth particle is lost, otherwise 0 Number of turns the n particle did during tracking

Example

>>> ff_data = floodfill(ring, nturns=500)
>>> alive_mask = ff_data[2,:] == 0

Note

This method is recommended for single or low number of CPUs, and does not scale well for parallel computing.

References