Skip to main content

Welcome to a Grasp lesson

Create a free account to keep studying and create your own study path.

Lesson 52

Benchmarking Flux Estimator Performance

Recommended resources

Introduction

In our last lesson, you implemented three fundamental flux estimators—track-length, collision, and surface-crossing—equipping your Monte Carlo code with the ability to measure quantities inside the simulation volume. We saw that while these estimators aim to calculate the same physical quantity, their behavior can differ. This lesson delves into that difference, addressing the crucial question: how do we rigorously evaluate and compare the performance of these estimators?

The goal today is to move beyond mere implementation and into quantitative analysis. You will learn to compare the statistical performance of different flux estimators for a given problem. We'll define what makes an estimator "good" by exploring concepts like statistical variance, error, and computational efficiency. By the end of this lesson, you will understand why one estimator might be superior to another in a specific physical scenario and know how to use standard metrics, like the Figure of Merit, to prove it.


What Makes a Good Estimator? Bias and Variance

First, let's clarify a critical point. For many standard problems, the track-length, collision, and surface-crossing estimators are all unbiased. This means that as you simulate an infinite number of particles, the average value of each estimator will converge to the same, true physical value. The fact that they are all "correct" in the long run is reassuring, but it doesn't help us choose between them for a practical simulation with a finite budget of time and particles.

The practical difference lies in their variance. For a finite number of histories, the results from a high-variance estimator will be more "spread out" or noisy around the true mean. A low-variance estimator will produce results that are more tightly clustered. Consequently, a low-variance estimator converges to a given level of precision much faster, making it more computationally efficient.

This trade-off is at the heart of choosing the right tool for the job. The following article provides an excellent discussion comparing the two most common volume estimators: track-length and collision.

Track-Length Estimator | Bohrium

This article explains the theoretical underpinnings of why track-length and collision estimators have different statistical variances. It connects the performance directly to the physical properties of the simulation medium.

Start by reading the section An Alternative View. This part reinforces that both the collision and track-length estimators are unbiased, meaning they converge to the same correct answer on average. Next, focus on the section A Tale of Two Variances. This is the core of the comparison. It explains intuitively and mathematically why the track-length estimator nearly always has a lower variance for estimating flux. Pay attention to the role of the scattering ratio, c = \Sigma_s / \Sigma_t. Finally, read The Art of Estimation. This section provides crucial practical context, explaining how the optical thickness of a region dictates which estimator is more efficient.

As the article explains, the performance of an estimator is not an abstract property but is deeply tied to the physics of the problem.

  • In optically thin regions (where the mean free path is long and collisions are rare), the track-length estimator is far superior. It gathers information from every particle that passes through the region, whereas the collision estimator scores nothing for most particles, leading to very high variance.
  • In optically thick regions (where particles are almost guaranteed to collide), the collision estimator can be very efficient because it gathers statistics frequently.

Quantifying Performance: The Figure of Merit

To move from qualitative understanding to quantitative comparison, we need a formal statistical framework. In Monte Carlo, we typically run a simulation consisting of total histories, grouped into batches of histories each. The tally result from each batch, , is treated as a single independent sample.

From these batch results, we can compute several key statistics. The documentation for the OpenMC code provides a concise and accurate summary of these calculations.

8. Tallies — OpenMC Documentation

This resource details the statistical quantities used to assess the quality of a Monte Carlo tally.

Please read the following subsections within the "Statistics" section: Mean: Our best estimate of the true value. Variance: The variance of the underlying batch distribution, s^2. Note the use of Bessel's correction (M-1) for an unbiased estimate. Variance of the Mean: The variance of our final answer, s_{\bar{x}}^2 = s^2/M. Its square root, s_{\bar{x}}, is the standard deviation of the mean, our uncertainty. Figure of Merit: The ultimate metric for efficiency. Focus on how the sample variance s^2 is calculated from the batch scores, and how the variance of the mean s_{\bar{x}}^2 is derived from it. This distinction is crucial: s^2 is a property of the problem and estimator, while s_{\bar{x}}^2 is what we reduce by running the simulation longer.

Let's summarize the key metrics for comparing two estimators, A and B, for the same problem:

  1. Mean Value (): The calculated mean flux from each estimator. For an unbiased estimator, should agree with within their statistical uncertainties.
  2. Relative Error (): This is the standard deviation of the mean divided by the mean itself, . It's the most common way to report statistical uncertainty. For a fixed number of histories, the estimator with the lower relative error is more precise.
  3. Figure of Merit (FOM): This metric combines precision and computational cost into a single number, defined as: where is the total computation time. The FOM tells you how efficiently an estimator reduces variance. Since variance decreases as (and thus decreases as , assuming time is proportional to N), the FOM should be roughly constant as a simulation runs longer. When comparing two simulations run for the same time, the one with the higher FOM is superior because it achieved a lower relative error for the same effort.

A Practical Benchmark

Now, let's put this theory into practice. You can set up a simple benchmark problem with your Python code to observe these effects directly.

Benchmark Problem Setup:

  • A slab of a single material, say 10 cm thick.
  • A monoenergetic, normally incident photon beam (e.g., 1 MeV).
  • Define a spatial mesh of, for example, 100 bins across the slab to tally the flux.
  • Run the simulation for a fixed number of histories (e.g., ) and batches (e.g., 100).

Experiment:
Run this benchmark for two different physical scenarios:

  1. Optically Thin Case: Set the total macroscopic cross section to a low value, e.g., 0.05 cm. This corresponds to a mean free path of 20 cm, which is larger than the slab thickness.
  2. Optically Thick Case: Set to a high value, e.g., 2.0 cm. This corresponds to a mean free path of 0.5 cm, much smaller than the slab thickness.

For each case, run the simulation and collect the results from both the track-length and collision estimators. For each estimator, calculate the mean flux, relative error, and total computation time for each spatial bin. Then, calculate the FOM for an integral quantity, like the average flux across the entire slab.

Analysis and Visualization:
You should produce plots similar to those used in professional analysis. The image below shows an excellent example of how to compare two estimators for an energy spectrum tally.

These plots show a comprehensive comparison between two estimators (red vs. blue). (A, B) show the calculated energy spectra. (C) shows their relative difference, highlighting any bias. (D) shows their relative uncertainties, directly comparing statistical performance.

For your slab problem, you would plot flux as a function of depth instead of energy. You should create:

  1. A plot showing the flux profiles from both estimators on the same axes, with error bars representing the standard deviation of the mean. Do they agree?
  2. A plot showing the relative error for each estimator as a function of depth. Which estimator has a lower error? Does it change with depth?
  3. Compare the overall FOMs. Which estimator was more efficient in the optically thin case? And in the optically thick case?

You should find that in the optically thin case, the track-length estimator yields a dramatically lower relative error and a much higher FOM. In the optically thick case, the performance of the collision estimator will be much more competitive and may even surpass the track-length estimator.


Beyond the Figure of Merit: The Reliability of Error

One final, more advanced consideration is the reliability of the calculated error itself. The Central Limit Theorem suggests that the distribution of batch means will approach a normal distribution, which is what allows us to calculate confidence intervals from the standard deviation. However, this is only true for a large number of batches and a well-behaved underlying score distribution.

Some estimator/problem combinations can produce "pathological" tallies, where a very rare event contributes an enormous score. This can skew the distribution of batch scores, making the calculated sample variance an unreliable measure of the true variance. This is quantified by the variance of the variance (VOV). A high VOV (e.g., > 0.1) suggests your error estimate itself is noisy, and you cannot be confident in your confidence intervals.

The collision estimator in an optically thin region is a classic example of a high-VOV tally. Most batches score zero, but one batch might by chance see a collision and get a huge score, which completely dominates the statistics. The track-length estimator is far more "robust" in this regard, as it collects contributions more smoothly, leading to a more stable and trustworthy error estimate.


Conclusion

Today, we have moved from implementing estimators to critically evaluating them. You have learned that while different estimators may be unbiased, their efficiency can vary dramatically depending on the physical context of the problem.

Key Takeaways:

  • Estimator performance is primarily judged by variance and computational efficiency.
  • The Figure of Merit (FOM) is the standard metric for comparing the overall efficiency of different simulation setups, as it balances statistical precision () with computational cost ().
  • The choice between the track-length (TL) and collision (C) estimators depends heavily on the optical thickness of the medium.
    • TL is generally superior and far more robust, especially in optically thin regions.
    • C can be competitive or even more efficient in very optically thick, highly absorbing regions.
  • Comparing estimators requires setting up a benchmark problem and analyzing key statistical outputs: the mean value, the relative error, and the FOM.

Preview of the Next Lesson:
You are now fully equipped to score scalar flux with confidence in your results. In the next lesson, we will use this capability to achieve a central goal of this course: calculating dosimetric quantities. You will learn how to "Score collision kerma in a Monte Carlo simulation and approximate absorbed dose under CPE." We will adapt our estimators to score reaction rates, and you'll see that the same principles of statistical performance apply.