Introduction
In our last lesson, we established the conceptual framework for Monte Carlo particle transport, viewing a particle's life as a random walk through the simulation geometry. We identified the core iterative loop: birth, travel, interaction, and termination. Now, we begin constructing the first functional piece of this simulation algorithm.
This lesson focuses on the "travel" step. Our objective is to determine how far a particle travels in a straight line before it interacts with the medium. To do this, we will sample the distance to the next collision from the total macroscopic cross section. We will start from the fundamental physics of particle attenuation, derive the underlying probability distribution for path lengths, and then use the inverse transform sampling method you learned in a previous module to develop a practical formula for our simulation.
The Physical Basis: Collision Probability and the Mean Free Path
Imagine a beam of particles entering a material. As they travel, some will interact and be removed from the beam. The probability that a particle will undergo an interaction within a small path length is given by , where is the total macroscopic cross section of the material at the particle's energy. You'll recall from your physics background that has units of inverse length (e.g., cm⁻¹), so this expression gives a dimensionless probability.
This simple relationship is the physical foundation for everything that follows. From it, we can derive the probability distribution governing the path length, , that a particle travels before its first interaction. A key quantity that emerges from this is the mean free path, , which is the average distance a particle travels between collisions. As we will see, it is simply the inverse of the total macroscopic cross section.
[PDF] Introduction to the Monte Carlo simulation of radiation transport
This presentation from a CERN training course provides a concise summary of the key definitions that connect cross sections to the mean free path.
Please read the slide titled "Terminology" (slide 3). Focus on how the macroscopic cross section, N\sigma, is defined as the interaction probability per unit length, and how this directly leads to the definition of the mean free path as its inverse, 1/(N\sigma).
Deriving the Path Length Distribution
Knowing the probability of interaction in an infinitesimal length allows us to derive the probability density function (PDF), , for the path length . Let's consider the probability that a particle survives (does not interact) over a distance , and then interacts in the next interval .
The probability of surviving a distance is . The probability of surviving a slightly longer distance, , is the probability of surviving and surviving :
Rearranging this gives a simple differential equation:
With the boundary condition that the survival probability at zero distance is 1 (i.e., ), the solution is the familiar exponential attenuation law:
This is the survival probability. The probability of having an interaction at or before a distance is therefore the cumulative distribution function (CDF), . The PDF, , is the derivative of the CDF:
This is the exponential probability distribution.
The following resource provides a slightly different but equivalent derivation, starting from the integral form of the relationship.
[PDF] Introduction to the Monte Carlo simulation of radiation transport
Let's return to the same CERN slides and look at the more formal derivation provided in the appendix.
In the "Additional material" section, find the slide titled "The mean free path and its distribution" (slide 39). Follow the derivation that starts by defining the interaction probability and arrives at the exponential distribution for path length, p(s). Note that N\sigma is simply another notation for \Sigma_t.
Sampling the Path Length
Now that we have the PDF and CDF for the path length, we can use the inverse transform sampling method to generate random path lengths. This is the crucial step that translates our physical model into a computational algorithm.
Recall the procedure:
- Generate a random number, , from a uniform distribution on the interval [0, 1).
- Set the CDF equal to this random number: .
- Solve the resulting equation for the path length, .
Let's apply this to our path length CDF, .
- Set .
- Rearrange to solve for :
Here, we can make a small but important simplification. If is a random number uniformly distributed between 0 and 1, then the quantity is also a random number uniformly distributed between 0 and 1. Therefore, to save a subtraction operation, we can substitute a new random number, , for :
This is the final, practical formula used in virtually all Monte Carlo codes to sample the distance to the next collision. Since is between 0 and 1, its natural logarithm is negative, ensuring that the sampled distance is always positive, as it must be.
The following document provides an excellent, step-by-step walkthrough of this exact derivation.
[PDF] Modeling Neutron Interaction Inside a 2D Reactor Using Monte ...
This master's thesis demonstrates the development of a Monte Carlo code for reactor physics. The section on sampling the interaction distance is particularly clear and directly relevant.
Please read Section 4.3, "SAMPLING NEUTRON DIRECTION AND INTERACTION DISTANCE". Follow the derivation starting from the survival probability, through the calculation of the PDF and CDF, to the final sampling formula derived by setting the CDF equal to a random number \xi. Note that the author uses x and d for distance where we have used s.
Implementation in Code
With your proficiency in Python, you can see how this elegant mathematical result translates directly into a single line of code. Assuming you have the total macroscopic cross section sigma_t and are using the NumPy library, the implementation is:
import numpy as np
# Assume sigma_t is defined (e.g., in cm^-1)
# sigma_t = 0.1
# Sample a random number xi from U(0, 1)
xi = np.random.random()
# Calculate the path length s
s = -(1 / sigma_t) * np.log(xi)
print(f"Sampled path length: {s:.4f} cm")
This is precisely the implementation used in the code attached to the thesis you just reviewed. If you were to look in the QualifyingMC function of the appendix, you would find the line d= -(1/sig[3])*np.log(np.random.random()), which performs this exact calculation (sig[3] is the total cross section, sig_t). This demonstrates how the core theoretical principle is applied directly in a working simulation.
Conclusion
In this lesson, we have taken a critical step from the conceptual random walk model to a concrete, implementable algorithm. We have connected a fundamental physical quantity, the macroscopic cross section, to the probabilistic nature of particle transport.
Key Takeaways:
- The probability of a particle interacting per unit path length is given by the total macroscopic cross section, .
- This physical principle leads to an exponential probability distribution for the path length between collisions: .
- The mean of this distribution is the mean free path, .
- Using the inverse transform sampling method, we can sample a path length from this distribution with the formula: , where is a uniform random number on [0, 1).
Preview of the Next Lesson:
We now know how to determine how far a particle travels. The next logical question is: what happens at the end of that path? In the next lesson, "Sample the interaction type using relative partial cross sections," we will develop the algorithm to decide whether the interaction is a scattering event, an absorption, or some other process, based on the relative probabilities defined by the material's partial cross sections.