I want to know does the Monte Carlo keeps track of the particle position relative to different surfaces it encounter or it checks it only if a surface is encountered.
Monte Carlo it is only the common method name. Different codes used for radiation transport can keep the track (if necessary) or not (if not necessary). The way of keeping this data may be different depending on the considered problem and the type of code.
Thanks Marek Brancewicz. Can you please suggest some references containing information how the track information is kept. And how the code decides whether the tracking is required or not?
Dear Dk Akar. It seems like You are using the already prepared program code. There are many of codes using Monte Carlo. The method for keeping the track information is very individual. You should propably ask the author of the program.
There are many different ways to do so. Since every movement in simulation is made in a finite step, it is very hard to track when the particle is exactly on the surface. I would say that the two simplest approaches is either to extrapolate the trajectory to the nearest surface and to check is particle will cross it in the following step, or check if particle left or entered the volume after each step.
As Marek Brancewicz already mentioned, if you use specific code, you should look for its documentation, since the method used is probably much more complicated.
Dk Akar, I think, that book could be very usefull for You: Caswell, E.D., and Everett, C.J., 1959, The Monte-Carlo Method for Random Walk Problems (New York: Pergamon Press).
If you have a particular code you intend to work with, the best approach is to read the source code. I worked with Monte Carlo transport codes many years ago which were written in Fortran and there was no problem about reading the code.
It is just a geometrical problem. Basically, you have to find the intersection of the straight line defined by the actual particle step with the surfaces in question. Afterwards, you have to determine which are the closest surfaces to the particle in order to find the region in which the particle are currently located.
I had developed a program for photon transport in MIRD phantom which has quadratic or planar surfaces. In that number of surfaces were finite and the position of the particle was determined by checking the condition whether the particle is in the volume (constructed by surfaces and the medium was assigned) where it started or in some other volume. The path length was determined using highest attenuation coefficient encountered in the problem weighted with the attenuation coefficient of the medium present.
But in case of large number of surfaces encountered in voxel geometries generated using CT data it is causing difficulty as the particle crosses many surfaces and media before interacting.
I think that the more appropriate solution of this problem is to propagate photons through every layer in the loop. You can check if the photon leaves the layer or not, according to the total attenuation coefficient for the layer material. If not - interaction will take place in the present layer. If yes - check again if the photon leaves this second layer or not. Repeat this procedure untill the remaining photons leave the phantom area.
I thought about this problem for a lot of time. In some specific cases You can make some approximations (depends on what You want to calculate), but in general case all this approximations may easilly fail. For the moment I don't see a better solution.