GALILEO

## Galileo EPD Handbook

### Numerical Calculation of Three-Dimensional Electron and Proton Trajectories in the Galileo EPD LEMMS Sensor Assembly (continued)

Appendix C The Computer Program

Description of the Program (below; please scroll down)
The Input Parameters
Code: Common Blocks
Code: Computer Simulation Code

Description of the Program

The program consists of a main program, twenty-one subroutines, nine functions and five common blocks. All of them are written in FORTRAN-77.  The structure of the entire program is given in the flowchart. Several important subroutines and functions deserve some special attention. The relevant theoretical approach and mechanism of these routines are discussed in the previous sections or appendices.  These subroutines are FDMOD, CHECKHIT, HITMISS, and TRAJECT.

Subroutine FDMOD can be used to obtain three components of the magnetic field for a given location.  This model employs the cartesian coordinate system.  The location is input in terms of cartesian coordinates x, y, and z in units of cm. The field strength of Bx, By, and Bz is in units of Gauss.  The subroutine is used in the computation of the particle trajectories according to Lorentz interaction.

Function CHECKHIT determines if a line segment of the trajectory is inside the sensor or intersects the boundary surfaces (i.e., the particle hits or misses the surfaces or eventually escapes the sensor). The procedure depends on the geometric structure of the sensor and its detectors.  There is some special arrangement made to examine the detector surface, sensor side surfaces, aperture surface, and channel surfaces. The potential users are urged to study the function thoroughly with the assistance of the graphs since the structure of the sensor is very complicated.  This function is called in subroutine OUT and it calls subroutine HITMISS for further investigation of a line segment's relationship with a particular surface, i.e., hit-or-miss determination.

Subroutine HITMISS determines whether a line segment intersects with a polygon and lies inside the polygon.  This subroutine uses the method of cross product to determine if the intersection point lies inside or outside the polygon if the intersection point between the line segment and the polygon exists.  If the intersection point hits the boundary of the polygon, the intersection point will be considered to be inside the polygon. Some modification can be made in this routine to include the computation of the plane coefficients of the polygon for some general applications. In this project, the coefficients are calculated earlier by calling subroutine PLANECOEFF since the surfaces of the sensor are fixed.

In addition, the program also uses subroutine TRAJECT to compute the trajectory of the particle.  It is a modified version of subroutine DHPCG from IBM scientific subroutine package (SSP). The original version was written in FORTRAN-IV with no indentation and poorly structured.  The new version of the subroutine is modernized to a well-structured code in FORTRAN-77 with appropriate indentation.  The subroutine uses Hamming's modified predictor-corrector method, and fourth order Runge-Kutta method is used to adjust the initial values.  The potential users are referred to the report of SSP for further information about the subroutine.