Difference between revisions of "Simulating Particle Trajectories"
Line 23: | Line 23: | ||
In "scan" mode, the program randomly selects an electron energy, angle of the magnet axis relative to the beam, and a conversion site "Y" coordinate, all subject to appropriate reasonable limits and kinematic constraints. It then models the trajectory of the particle until either the particle is sufficiently far from the detector, or a certain maximum time is reached. The program then evaluates the angles of the particles' final trajectories relative to the initial photon beam and assigns a flag as follows: | In "scan" mode, the program randomly selects an electron energy, angle of the magnet axis relative to the beam, and a conversion site "Y" coordinate, all subject to appropriate reasonable limits and kinematic constraints. It then models the trajectory of the particle until either the particle is sufficiently far from the detector, or a certain maximum time is reached. The program then evaluates the angles of the particles' final trajectories relative to the initial photon beam and assigns a flag as follows: | ||
− | {| class="wikitable" | + | {| class="wikitable" border=1 |
|+ Flag codes for "scan" mode | |+ Flag codes for "scan" mode | ||
|- | |- |
Revision as of 20:02, 10 June 2009
This article discusses numerical simulations of particle trajectories in the "silver" permanent magnet.
Description of Problem
The general problem of modeling relativistic particle trajectories in electromagnetic fields boils down to solving the following system of six differential equations:
where
is the position of the particle, is the momentum of the particle, is the rest energy of the particle, and is the usual relativistic factor. These equations are solved subject to an appropriate set of boundary conditions, usually the initial position and momentum of the particle.In simple cases, such as when the fields are uniform, this set of equations can be solved analytically. However, for the "silver" permanent magnet we plan on using for the pair spectrometer, the fields are anything but uniform. In such a case, the system must be solved numerically.
Description of Code
The code, found here, solves the above system of equations using an embedded 8th order Runge-Kutta Prince-Dormand method with 9th order error estimates with adaptive stepsize control, as implemented in the GNU Scientific Library [1]. The zip file contains the relevant source and a script which should build the executable on any unix system with GSL installed in the usual place.
When executing the code, you must specify an input file on the command line. The input file is fairly simple. The first line of the input file is either a "0" or some integer greater than zero, and tells the program to run in "detailed output" or "scan" mode, respectively. In "detailed output" mode, the next five lines specify the energy of the initial gamma ray, the energy of the electron (the energy of the positron is assumed to be the difference of these two numbers), the angle between the axis of the magnet and the photon beam, the "Y" position of the conversion site above the magnet yoke, and the "X" position of the conversion site relative to the left edge of the magnet. In "scan" mode, the integer on the first line tells the program how many cases to run. Only two additional lines are needed: the energy of the photon and the "X" position of the conversion site. Examples of such input files are provided here (detailed mode) and here (scan mode).
The program output also depends on the program mode. In the "detailed output" mode, everything is written to stdout, and can be directed to a file using the ">" director. The output begins with a header, each line of which begins with the "#" character. The header lists the physical properties of the particle, the conditions read from the input file, and the corresponding initial positions and momenta of the electron and positron. Following the header, the program writes four columns of data: the time (in seconds) and the x, y, and z coordinates (in meters).
In "scan" mode, the program randomly selects an electron energy, angle of the magnet axis relative to the beam, and a conversion site "Y" coordinate, all subject to appropriate reasonable limits and kinematic constraints. It then models the trajectory of the particle until either the particle is sufficiently far from the detector, or a certain maximum time is reached. The program then evaluates the angles of the particles' final trajectories relative to the initial photon beam and assigns a flag as follows:
0 | Electron hits the yoke |
1 | Neither particle has an exit angle greater than 90 degrees |
2 | Only the electron has an exit angle greater than 90 degrees |
3 | Only the positron has an exit angle greater than 90 degrees |
4 | Both particles have exit angles greater than 90 degrees (ideal) |
5 | The electron gets trapped in the magnetic field |
6 | The positron gets trapped in the magnetic field |
Ideally we want to tag both particles in coincidence with both particles exiting the beam at an angle greater than 90 degrees, hence the classifications in the table above.
Also, in "scan" mode, the program writes output to three places. The primary output is written to stdout, and can be directed to a file. This output consists of a header (each line of which begins with "#") listing the parameters passed to the program in the input file. The output itself is in five columns, consisting of the iteration number, the energy of the electron (in MeV), the angle of the magnet axis relative to the beam (in degrees), the height of the conversion site above the yoke (in meters), and the output flag as described above. Each line of output ends with a character "X" to facilitate extracting iterations that returned a particular flag using the grep command.
The magnetic field, as implemented in the code
Limitations of the Code
Results of parameter space scans
"Ideal" orientation of magnet for 5 MeV photons
Pairs produced elsewhere on the beam