
10.5. TRACKING IN AN ELEMENTAL VOLUME 133
defined by the planes P
1
: z =0,P
2
: z = 1 and the cylinder C
1
: x
2
+ y
2
− R
2
=0. The
geometry is depicted in Figure 10.7 and some representative trajectories are given there.
Consider trajectory 1. It has intercepts with both C
1
and P
2
. However, the distance to the
intercept with C
1
is shorter and is the answer in this case. Contrast this with trajectory 2.
It has intercepts with both C
1
and P
2
. However, the distance to the intercept with P
2
is
shorter and is the answer in this case.
Recall that the interior of the right circular cylinder is represented by the condition P
1
∩C
1
∩
P
2
. Therefore, the distance to exit the elemental volume is given by the following coding:
TransportDistance = infinity ! (Some very large number)
! Check the distance to each bounding surface
! Check the leftmost plane
call zplane(0e0,z0,w,s,.false.,hit) ! 0e0 = zplane position, .false. => outside
if (hit .and. (s .le. TransportDistance)) TransportDistance = s
! Check the rightmost plane
call zplane(1e0,z0,w,s,.true.,hit) ! 1e0 = zplane position, .true. => inside
if (hit .and. (s .le. TransportDistance)) TransportDistance = s
! Check the cylinder
call ccylz(1e0,x0,y0,u,v,s,.true.,hit) ! 1e0 = radius, .true. => inside
if (hit .and. (s .le. TransportDistance)) TransportDistance = s
After this code segment is executed, the variable TransportDistance is the distance to exit
the elemental volume by any surface irrespective of its direction, as long as it is logically
placed within this elemental volume.
The equivalent coding for a general elemental volume would be:
TransportDistance = infinity ! (Some very large number)
! Check the distance to each bounding surface
! {...} are the parameters that define the particle’s position and direction
! [...] are the parameters that define the surface
! [.true.|.false.] true or false depending upon orientation of surface