track_generator Module
The code defining a trajectory interpolation object and its creation.
MeshParameters
dataclass
Wrapper for the general parameters required to generate a mesh of ODE solutions
A mesh for Spyral is a 4 dimensional array of solutions to the equations of motion (also called track or trajectory) through the AT-TPC detector. These parameters describe the shape of the mesh as well as the physical properties used to generate it.
Attributes:
Name | Type | Description |
---|---|---|
target |
GasTarget | GasMixtureTarget
|
The target material |
particle |
NucleusData
|
The projectile |
bfield |
float
|
The magnetic field magnitude in T |
efield |
float
|
The electric field magnitude in V/m |
n_time_steps |
int
|
The number of ODE solver timesteps |
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 |
shape |
tuple[int, int, int, int]
|
The shape of the mesh array |
dtype |
str
|
The stringified numpy dtype of the mesh array |
Methods:
Name | Description |
---|---|
serialize_json |
Serialize the class to a JSON string |
Source code in src/spyral/core/track_generator.py
serialize_json()
Serialize the class to a JSON string
Returns:
Type | Description |
---|---|
str
|
A JSON string |
Source code in src/spyral/core/track_generator.py
backward_z_bound_condition(t, state, Bfield, Efield, target, ejectile)
Detect if a solution has reached the end-of-detector-in-z condition
Terminate the integration of the ivp if the condition specified has been reached. Scipy finds the roots of this function with the ivp. The parameters must match those given to the equation to be solved
Parameters:
Name | Type | Description | Default |
---|---|---|---|
t |
float
|
time step, unused |
required |
state |
ndarray
|
the state of the particle (x,y,z,vx,vy,vz) |
required |
Bfield |
float
|
the magnitude of the magnetic field, unused |
required |
Efield |
float
|
the magnitude of the electric field, unused |
required |
target |
GasTarget | GasMixtureTarget
|
the material through which the particle travels, unused |
required |
ejectile |
NucleusData
|
ejectile (from the reaction) nucleus data, unused |
required |
Returns:
Type | Description |
---|---|
float
|
The difference between the current z position and the beginning of the detector (-1.0 m). When this function returns zero the termination condition has been reached. |
Source code in src/spyral/core/track_generator.py
check_mesh_metadata(track_path, params)
Check if track mesh meta data matches or if track mesh doesn't exist
Parameters:
Name | Type | Description | Default |
---|---|---|---|
track_path |
Path
|
Path to the track mesh data |
required |
params |
MeshParameters
|
The parameters for this track mesh |
required |
Returns:
Type | Description |
---|---|
bool
|
Returns False if the given meta data does not match If the metadata matches, the mesh shape and dtype are extracted from the meta file and placed into the parameters |
Source code in src/spyral/core/track_generator.py
equation_of_motion(t, state, Bfield, Efield, target, ejectile)
The equations of motion for a charged particle in a static electromagnetic field which experiences energy loss through some material.
Field directions are chosen based on standard AT-TPC configuration
Parameters:
Name | Type | Description | Default |
---|---|---|---|
t |
float
|
time step |
required |
state |
ndarray
|
the state of the particle (x,y,z,gvx,gvy,gvz) |
required |
Bfield |
float
|
the magnitude of the magnetic field |
required |
Efield |
float
|
the magnitude of the electric field |
required |
target |
GasTarget | GasMixtureTarget
|
the material through which the particle travels |
required |
ejectile |
NucleusData
|
ejectile (from the reaction) nucleus data |
required |
Returns:
Type | Description |
---|---|
ndarray
|
the derivatives of the state |
Source code in src/spyral/core/track_generator.py
forward_z_bound_condition(t, state, Bfield, Efield, target, ejectile)
Detect if a solution has reached the end-of-detector-in-z condition
Terminate the integration of the ivp if the condition specified has been reached. Scipy finds the roots of this function with the ivp. The parameters must match those given to the equation to be solved
Parameters:
Name | Type | Description | Default |
---|---|---|---|
t |
float
|
time step, unused |
required |
state |
ndarray
|
the state of the particle (x,y,z,vx,vy,vz) |
required |
Bfield |
float
|
the magnitude of the magnetic field, unused |
required |
Efield |
float
|
the magnitude of the electric field, unused |
required |
target |
GasTarget | GasMixtureTarget
|
the material through which the particle travels, unused |
required |
ejectile |
NucleusData
|
ejectile (from the reaction) nucleus data, unused |
required |
Returns:
Type | Description |
---|---|
float
|
The difference between the current z position and the length of the detector (1m). When this function returns zero the termination condition has been reached. |
Source code in src/spyral/core/track_generator.py
generate_interpolated_track(vx, vy, vz, polar, azim, ke, particle, bfield, efield, target, n_time_steps=1000)
Get a single interpolated trajectory given some initial state and system parameters
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 |
particle |
NucleusData
|
The particle of interest |
required |
bfield |
float
|
The magnetic field in Tesla |
required |
efield |
float
|
The electric field in V/m |
required |
target |
GasTarget | GasMixtureTarget
|
The target material |
required |
n_time_steps |
int
|
The number of timesteps used by the solver |
1000
|
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/core/track_generator.py
557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 |
|
generate_track_mesh(params, track_path, meta_path)
Generate a mesh of tracks given some parameters and write them to an npy file at a path.
Creates a 4-dimensional array (mesh) of ODE solutions (also called tracks or trajectories) and writes them to disk. The dimensions are as follows: time x initial energy x inital polar angle x position. This mesh can then be used to interpolate and find an approximate solution for a given energy, polar angle.
In many cases of AT-TPC analysis, it is diffcult to pre-estimate the time window needed to cover the full trajectory. To compensate, Spyral will do a first pass over the mesh using a coarse 1us time window. It will then estimate a finer time window based off of the results of this first pass, and then generate the mesh.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
params |
MeshParameters
|
parameters which control the tracks |
required |
track_path |
Path
|
where to write the tracks to |
required |
meta_path |
Path
|
where to write the track metadata to |
required |
Source code in src/spyral/core/track_generator.py
395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 |
|
rho_bound_condition(t, state, Bfield, Efield, target, ejectile)
Detect if a solution has reached the end-of-detector-in-rho condition
Terminate the integration of the ivp if the condition specified has been reached. Scipy finds the roots of this function with the ivp. The parameters must match those given to the equation to be solved
Note here that the edge in rho (292 mm) is padded by 30 mm to account for conditions where the vertex is off axis
Parameters:
Name | Type | Description | Default |
---|---|---|---|
t |
float
|
time step, unused |
required |
state |
ndarray
|
the state of the particle (x,y,z,vx,vy,vz) |
required |
Bfield |
float
|
the magnitude of the magnetic field, unused |
required |
Efield |
float
|
the magnitude of the electric field, unused |
required |
target |
GasTarget | GasMixtureTarget
|
the material through which the particle travels, unused |
required |
ejectile |
NucleusData
|
ejectile (from the reaction) nucleus data, unused |
required |
Returns:
Type | Description |
---|---|
float
|
The difference between the current z position and the maximum rho of the detector (332 mm). When this function returns zero the termination condition has been reached. |
Source code in src/spyral/core/track_generator.py
stop_condition(t, state, Bfield, Efield, target, ejectile)
Detect if a solution has reached the low-energy stopping condition
Terminate the integration of the ivp if the condition specified has been reached. Scipy finds the roots of this function with the ivp. The parameters must match those given to the equation to be solved
Parameters:
Name | Type | Description | Default |
---|---|---|---|
t |
float
|
time step, unused |
required |
state |
ndarray
|
the state of the particle (x,y,z,vx,vy,vz) |
required |
Bfield |
float
|
the magnitude of the magnetic field, unused |
required |
Efield |
float
|
the magnitude of the electric field, unused |
required |
target |
GasTarget | GasMixtureTarget
|
the material through which the particle travels, unused |
required |
ejectile |
NucleusData
|
ejectile (from the reaction) nucleus data |
required |
Returns:
Type | Description |
---|---|
float
|
The difference between the kinetic energy and the lower limit. When this function returns zero the termination condition has been reached. |