Understanding Variation in Barracuda Simulation Results
Randomness in Barracuda
Simulations in Barracuda Virtual Reactor often necessitate modelling the interactions of millions, if not billions, of particles while simultaneously accounting for fluid dynamics, chemistry, and thermal calculations. The computational load to model each of these particles discretely would be prohibitively high, so Barracuda instead makes use of a statistical approach to modelling the particles within a system. With this method, a collection of particles is represented by a single computational particle.
As part of this statistical approach, various randomizations are used (e.g., when selecting particle sizes for a PSD at a feed, when particles bounce off walls, when modeling particle collisions). While an initial variation may be quite small, these deviations can cascade into larger differences that can become easily identified via inspection of simulation results. For instance, at a given time in one run of a simulation, a cluster of closely-packed particles may temporarily form in a region of the system geometry. However, if the simulation were run again, the cluster may form in a different region or at a different time.
This aspect of Barracuda is important to understand while interpreting simulation results. In this post, we will cover the parts of a simulation that can cause these variations and how to gauge which variations may be caused due to randomness versus other potential sources, such as project setup choices, cell resolution, and particle resolution.
CPU-Only and Random Seeds
In software, the outcomes of randomized events are calculated by a random number generator (RNG). Since it is impossible for computers to achieve true randomness, the RNG is initialized by a seed value which will determine the sequence of random numbers that the generator will output. When running in CPU-only mode, this seed is the only factor that determines the outcomes of random events in the simulation.
In Barracuda, the seed for your simulation run can be set by using the -seed option on the command line interface. Since the seed will determine the sequence of numbers that are produced whenever a random event occurs, an identical project run with the same seed will output the exact same results every time it is run. By default, a random seed is used if not specified, which will approximate the randomness experienced by systems in the real world. For this reason, it is generally not recommended to use the -seed command for most applications with Barracuda.
Effects of GPU Acceleration
The main benefit of GPU over CPU calculation when running Barracuda is that CPUs, by their nature, must run all calculations sequentially whereas GPUs will run many calculations in parallel. One side effect of the parallel calculation method used by GPUs is that the order of certain floating-point operations carried out by a GPU is not guaranteed.
This introduces small variations in the order of floating-point summations which is enough entropy to cause a particle to act slightly differently from one run to another. Any order of these summations is valid, so there is no effect on the realism of Barracuda’s simulation results when using GPU acceleration. All outcomes will still adhere to the models that Barracuda uses in calculations, so running with GPUs is only another source of variation in the results that is not present when running in CPU-only. Simply put, the effects of GPU acceleration over the course of multiple runs can be viewed analogously to running with different RNG seeds.
Differentiating Randomness versus Other Sources of Variation
While an identical project may produce slightly different results due to the sources of random behavior discussed above, the results should always adhere to the physical realities and limitations set in place by the sophisticated models Barracuda utilizes in its calculations. A surefire way to differentiate between variation due to randomness versus variation due to issues with the setup of a simulation, or potentially a software bug is by analyzing your results for anything that falls outside of the bounds of what would be reasonable for a real system.
For instance, a quantitative analysis could involve checking the particle outflow rate at a boundary condition. If this quantity varies by 1% or so between runs, this is likely just variation due to randomness in the system and is not a cause for concern; however, if this quantity varies by several orders of magnitude for no apparent reason, this could be due to a problem in the setup of the project or (less commonly) a software bug. One aspect of project setup that commonly causes unexpected variations is using particle resolution settings that are too low.
We hope this has given you a better understanding of the sources of randomness in Barracuda and how the software uses randomization to better approximate the subtle physical nuances of actual systems. In most simulations, these variations will be relatively slight and only noticeable with careful analysis. However, both the size and resolution of your simulation play a role in the range of randomness your model can experience. If you are ever uncertain about your simulation results, please contact support@cpfd-software.com for further assistance.