at.acceptance.floodfill_acceptance#
This is an implementation of the Flood Fill algorithm for pyat.
Functions
- floodfill(ring, nturns=1024, planes=('x', 'y'), amplitudes=(0.01, 0.01), bounds=((-1, 1), (0, 1)), npoints=(10, 10), 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: 1024
planes (list | tuple) – max. dimension 2, Plane(s) to scan for the acceptance. Allowed values are:
'x','px','y','py','dp','ct'amplitudes (list | tuple) – (2,) array, set the search range per plane. Default [10e-3,10e-3]
bounds (list | tuple) – (2,2) array, defines the tracked range: range=bounds*amplitude Default ((-1,1),(0,1))
npoints (list | tuple) – Number of steps per axis. Default (10,10).
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 Number of turns the n particle did during tracking Flag set to 1 if the nth particle is lost, otherwise 0
Example
>>> ff_data = floodfill(ring, nturns=500) >>> alive_mask = ff_data[3,:] == 0
Note
This method is recommended for single or low number of CPUs, and does not scale well for parallel computing.
References