Monte Carlo / Dynamic Code (MC/DC): An accelerated Python package for fully transient neutron transport and rapid methods development

pseudo-random

neutron sources, and nuclear criticality safety experiments, among other systems.This can be modeled with a Monte Carlo simulation, where particles with statistical importance are created and transported to produce a particle history (Lewis & Miller, 1984).A particle's path and the specific set of events that occur within its history are governed by pseudo-random numbers, known probabilities (e.g., from material data), and known geometries.Information about how particles move and/or interact with the system is tallied to construct a histogram solution of parameters of interest with an associated statistical error from the Monte Carlo process.Simulating dynamic systems that vary in time requires novel numerical methods to compute a solution performantly.We designed Monte Carlo / Dynamic Code (MC/DC) to explore such novel numerical methods on modern high-performance computing systems.We avoid the need for a compiled or domain-specific language by using the Numba compiler for Python to accelerate and abstract our compute kernels to near compiled code speeds.We have implemented novel algorithms using this scheme and, in some verification tests, have approached the performance of industry-standard codes at the scale of tens of thousands of processors.

Statement of need
MC/DC is a performant software platform for rapidly developing and applying novel, dynamic, neutron-transport algorithms on modern high-performance computing systems.It uses the Numba compiler for Python to compile compute kernels to a desired hardware target, including support for graphics processing units (GPUs) (Lam et al., 2015).MC/DC uses mpi4py for distributed-memory parallelism (Dalcin & Fang, 2021) and has run at the scale of tens of thousands of processors (Variansyah et al., 2023).These acceleration and abstraction techniques allow MC/DC developers to remain in a pure Python development environment without needing to support compiled or domain-specific languages.This has allowed MC/DC to grow from its initialization less than two years ago into a codebase that supports full performant neutron transport and investigation of novel transport algorithms, with development mostly from relative novices.
Many traditionally developed neutron-transport codes are export-controlled (e.g.MCNP (Rising et al., 2023), Shift (Hamilton & Evans, 2019), and MCATK (Adams et al., 2015)) and some are known to be difficult to install, use, and develop in.MC/DC is open-source, and thus, similar to other open-source Monte Carlo neutron-transport codes (e.g., OpenMC (Romano et al., 2015)), it promotes knowledge sharing, collaboration, and inclusive, community-driven development.What makes MC/DC unique is that its code base is exclusively written in Python, making it a good method exploration tool and an excellent entry point for students.Furthermore, MC/DC is wrapped as a Python package that can be conveniently installed via the pip distribution, and its development is assisted by a suite of unit, regression, verification, and performance tests, which are mostly run using continuous integration via GitHub Actions.This all together makes MC/DC ideal for use in an academic environment for both research and education.
MC/DC has support for continuous and multi-group energy neutron transport physics with constructive solid geometry modeling.It can solve k-eigenvalue problems (used to determine neutron population growth rates in reactors) as well as fully dynamic simulations.It also supports some simple domain decomposition, with more complex algorithms currently being implemented.In an initial code-to-code performance comparison, MC/DC was found to run about 2.5 times slower than the Shift Monte Carlo code for a simple problem and showed similar scaling on some systems (Variansyah et al., 2023).

Future Work
The main MC/DC branch currently only supports CPU architectures enabled by Numba (x86-64, arm64, and ppc64) but we are rapidly extending support to GPUs.We currently have operability on Nvidia GPUs (supported via Numba), and work is ongoing to enable compilation for AMD GPUs.On GPUs, MC/DC will use the harmonize asynchronous GPU scheduler to increase performance (B.Cuneo & Bailey, 2023).harmonize works by batching jobs during execution such that similar operations get executed simultaneously, reducing the divergence between parallel threads running on the GPU.
We will continue to explore novel methods for dynamic neutron transport and will keep pushing to make MC/DC not only a proven platform for rapidly exploring neutron-transport methods, but also a fully-fledged simulation code for academic and industrial use.