track_interpolator Module
This module contains the code defining a JIT-compatible track (trajectory) interpolation scheme.
TrackInterpolator
Represents an interpolation scheme used to generate trajectories.
Solving ODE's can be expensive, so to save time pre-generate a range of solutions (mesh) and then interpolate on these solutions. TrackInterpolator uses bilinear interpolation to interpolate on the energy and polar angle (reaction angle) of the trajectory.
We use numba to just-in-time compile these methods, which results in a dramatic speed up on the order of a factor of 50.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
track_path |
str
|
Path to an interpolation file |
required |
interpolators |
ListType(instance_type)
|
A set of BilinearInterpolators |
required |
particle_name |
str
|
The isotopic symbol of the particle |
required |
gas_name |
str
|
The gas target name |
required |
bfield |
float
|
The magnetic field magnitude in T |
required |
efield |
float
|
The electric field magnitude in V/m |
required |
ke_min |
float
|
The minimum kinetic energy of the mesh in MeV |
required |
ke_max |
float
|
The maximum kinetic energy of the mesh in MeV |
required |
ke_bins |
int
|
The number of kinetic energy bins in the mesh |
required |
polar_min |
float
|
The minimum polar angle of the mesh in degrees |
required |
polar_max |
float
|
The maximum polar angle of the mesh in degrees |
required |
polar_bins |
int
|
The number of polar angle bins in the mesh |
required |
Attributes:
Name | Type | Description |
---|---|---|
file_path |
str
|
The track save file |
particle_name |
str
|
The isotopic symbol of the ejectile |
gas_name |
str
|
The target gas name |
bfield |
float
|
The magnetic field magnitude in T |
efield |
float
|
The electric field magnitude in V/m |
ke_min |
float
|
The minimum kinetic energy of the mesh in MeV |
ke_max |
float
|
The maximum kinetic energy of the mesh in MeV |
ke_bins |
int
|
The number of kinetic energy bins in the mesh |
polar_min |
float
|
The minimum polar angle of the mesh in degrees |
polar_max |
float
|
The maximum polar angle of the mesh in degrees |
polar_bins |
int
|
The number of polar angle bins in the mesh |
interpolators |
ListType[BilinearInterpolator]
|
A list of BilinearInterpolators, one for each time step in the mesh |
Methods:
Name | Description |
---|---|
TrackInterpolator |
Construct a TrackInterpolator |
get_interpolated_trajectory |
Given some initial state, get an interpolated trajectory |
check_interpolator |
Check if this interpolator matches the given values |
check_values_in_range |
Check if the given ke, polar point is within the mesh |
Source code in src/spyral/interpolate/track_interpolator.py
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 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 |
|
check_interpolator(particle, bfield, efield, target, ke_min, ke_max, ke_bins, polar_min, polar_max, polar_bins)
Check to see if this interpolator matches the given parameters
Parameters:
Name | Type | Description | Default |
---|---|---|---|
particle |
str
|
The isotopic symbol of the particle |
required |
bfield |
float
|
The magnetic field magnitude in T |
required |
efield |
float
|
The electric field magnitude in V/m |
required |
target |
str
|
The gas target name |
required |
ke_min |
float
|
The minimum kinetic energy of the mesh in MeV |
required |
ke_max |
float
|
The maximum kinetic energy of the mesh in MeV |
required |
ke_bins |
int
|
The number of kinetic energy bins in the mesh |
required |
polar_min |
float
|
The minimum polar angle of the mesh in degrees |
required |
polar_max |
float
|
The maximum polar angle of the mesh in degrees |
required |
polar_bins |
int
|
The number of polar angle bins in the mesh |
required |
Returns:
Type | Description |
---|---|
bool
|
Returns true if the interpolator matches |
Source code in src/spyral/interpolate/track_interpolator.py
check_values_in_range(ke, polar)
Check if these values of energy, angle are within the interpolation range
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ke |
float
|
The kinetic energy to check in MeV |
required |
polar |
float
|
The polar angle to check in radians |
required |
Returns:
Type | Description |
---|---|
bool
|
Returns true if they are within the interpolation range |
Source code in src/spyral/interpolate/track_interpolator.py
get_interpolated_trajectory(vx, vy, vz, polar, azim, ke)
Get an interpolated trajectory given some initial state.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vx |
float
|
Vertex x-coordinate in m |
required |
vy |
float
|
Vertex y-coordinate in m |
required |
vz |
float
|
Vertex z-coordinate in m |
required |
polar |
float
|
Polar angle in radians |
required |
azim |
float
|
azimuthal angle in radians |
required |
ke |
float
|
Kinetic energy in MeV |
required |
Returns:
Type | Description |
---|---|
LinearInterpolator | None
|
Returns a LinearInterpolator, which interpolates the trajectory upon z for x,y or None when the algorithm fails |
Source code in src/spyral/interpolate/track_interpolator.py
get_trajectory(vx, vy, vz, polar, azim, ke)
Get a trajectory given some initial state.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vx |
float
|
Vertex x-coordinate in m |
required |
vy |
float
|
Vertex y-coordinate in m |
required |
vz |
float
|
Vertex z-coordinate in m |
required |
polar |
float
|
Polar angle in radians |
required |
azim |
float
|
azimuthal angle in radians |
required |
ke |
float
|
Kinetic energy in MeV |
required |
Returns:
Type | Description |
---|---|
ndarray | None
|
Returns a Nx3 ndarray of the trajectory data or None when the algorithm fails |
Source code in src/spyral/interpolate/track_interpolator.py
create_interpolator(track_path)
Create a TrackInterpolator, loading a mesh of trajectories from disk.
This is a utility function wrapping the creation of a TrackInterpolator. We do this outside of the jitclass as I/O seems to only be somewhat supported in numba.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
track_path |
Path
|
Path to the track mesh data |
required |
Returns:
Type | Description |
---|---|
TrackInterpolator
|
The constructed interpolator |
Source code in src/spyral/interpolate/track_interpolator.py
create_interpolator_from_array(track_path, array)
Create a TrackInterpolator, loading a mesh of trajectories from a shared memory buffer
This is a utility function wrapping the creation of a TrackInterpolator. We do this outside of the jitclass as I/O seems to only be somewhat supported in numba.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
track_path |
Path
|
Path to the track mesh data |
required |
array |
ndarray
|
The numpy array wrapping the shared memory. Contains the data to interpolate on. |
required |
Returns:
Type | Description |
---|---|
TrackInterpolator
|
The constructed interpolator |