at.acceptance.floodfill_acceptance#
This is an implementation of the Flood Fill algorithm for pyat.
Functions
|
Find the 2D acceptance of the ring using Flood Fill [1]. |
|
Find the 1D acceptance of the ring using Flood Fill. |
- floodfill(ring, nturns=1024, planes=('x', 'y'), amplitudes=(0.01, 0.01), bounds=((-1, 1), (0, 1)), npoints=(10, 10), offset=None, shift_zero=1e-06, dp=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.
- 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.
1e-6. (shift_zero = small offset added to the 6d coordinates. Default)
dp (float | None) – static momentum offset. Default None.
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
- floodfill_1d(ring, nturns=1024, plane=('dp',), amplitude=(0.1,), bounds=((-1, 1),), npoints=(10,), offset=None, shift_zero=1e-06, dp=None, obspt=None, verbose=False, use_mp=True, pool_size=10)[source]#
Find the 1D acceptance of the ring using Flood Fill.
Flood fill tracks particles from the exterior to the border of the acceptance.
- Parameters:
ring (Lattice) – pyat lattice
nturns (int) – Number of turns for the tracking. Default: 1024
plane (list | tuple) – max. dimension 1, Plane to scan for the acceptance. Allowed values are:
'x','px','y','py','dp','ct'Default (“dp”)amplitude (list | tuple) – (1,) array, set the search range. Default [10e-3]
bounds (list | tuple) – (2,) array, defines the tracked range: range=bounds*amplitude Default ((-1,1),)
npoints (list | tuple) – Number of steps per axis, at least 2. Default (10,).
offset (list | ndarray | None) – (6,len(obspt)) Offset to be added. Default is the closed orbit per obspt. This is useful to study to add a small deviation in the transverse plane to the tracked coordinates e.g. 10e-5 in the transverse planes.
1e-6. (shift_zero = small offset added to the 6d coordinates. Default)
dp (float | None) – static momentum offset. Default None.
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 (5,n) – 1) Observation points. 2) offset of the tracked points 3) s postions of the observation points. 4) Number of turns the n particle did during tracking. 5) Flag set to 1 if the nth particle is lost, otherwise 0.
Example
>>> data_ff1d = floodfill_1d(ring, plane=["dp"], nturns=1024) >>> alive_mask = data_ff1d[4,:] == 0
>>> particle_turns = data_ff1d[3,:] >>> particle_refpts = data_ff1d[0,:] >>> particle_spos = data_ff1d[2,:] >>> particle_offset = data_ff1d[1,:] >>> plt.scatter(particle_spos,particle_offset,c=particle_turns) >>> plt.show()
Note
This method is recommended for single or low number of CPUs, and does not scale well for parallel computing.