xsuite_tracking
This class is used to build a Xsuite collider from a madx sequence and optics.
XsuiteTracking
XsuiteTracking class for managing particle tracking simulations.
Attributes:
| Name | Type | Description |
|---|---|---|
context_str |
str
|
The context for the simulation (e.g., "cupy", "opencl", "cpu"). |
device_number |
int
|
The device number for GPU contexts. |
_context |
Context
|
The context object for the simulation. |
beam |
str
|
The beam configuration. |
distribution_file |
str
|
The file path to the particle data. |
delta_max |
float
|
The maximum delta value for particles. |
n_turns |
int
|
The number of turns for the simulation. |
nemitt_x |
float
|
The normalized emittance in the x direction. |
nemitt_y |
float
|
The normalized emittance in the y direction. |
Methods:
| Name | Description |
|---|---|
context |
Get the context object for the simulation. |
prepare_particle_distribution_for_tracking |
Prepare the particle distribution for tracking. |
track |
Track the particles in the collider. |
Source code in study_da/generate/master_classes/xsuite_tracking.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 | |
context: Any
property
Returns the context for the current instance. If the context is not already set,
it initializes the context based on the context_str attribute. The context can
be one of the following:
- "cupy": Uses
xo.ContextCupy. Ifdevice_numberis specified, it initializes the context with the given device number. - "opencl": Uses
xo.ContextPyopencl. - "cpu": Uses
xo.ContextCpu. - Any other value: Logs a warning and defaults to
xo.ContextCpu.
If device_number is specified but the context is not "cupy", a warning is logged
indicating that the device number will be ignored.
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
The initialized context. |
__init__(configuration, nemitt_x, nemitt_y)
Initialize the tracking configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
configuration
|
dict
|
A dictionary containing the configuration parameters. Expected keys: - "context": str, context string for the simulation. - "device_number": int, device number for the simulation. - "beam": str, beam type for the simulation. - "distribution_file": str, path to the particle file. - "delta_max": float, maximum delta value for the simulation. - "n_turns": int, number of turns for the simulation. |
required |
nemitt_x
|
float
|
Normalized emittance in the x-plane. |
required |
nemitt_y
|
float
|
Normalized emittance in the y-plane. |
required |
Source code in study_da/generate/master_classes/xsuite_tracking.py
prepare_particle_distribution_for_tracking(collider)
Prepare a particle distribution for tracking in the collider.
This method reads particle data from a parquet file, processes the data to generate normalized amplitudes and angles, and then builds particles for tracking in the collider. If the context is set to use GPU, the collider trackers are reset and rebuilt accordingly.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collider
|
Multiline
|
The collider object containing the beam and tracking information. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
tuple
|
A tuple containing: - xp.Particles: The particles ready for tracking. - np.ndarray: Array of particle IDs. - np.ndarray: Array of normalized amplitudes in the xy-plane. - np.ndarray: Array of angles in the xy-plane in radians. |
Source code in study_da/generate/master_classes/xsuite_tracking.py
track(collider, particles)
Tracks particles through a collider for a specified number of turns and logs the elapsed time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collider
|
Multiline
|
The collider object containing the beamline to be tracked. |
required |
particles
|
Particles
|
The particles to be tracked. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
A dictionary representation of the tracked particles. |