MC/DC is a performant, scalable, and machine-portable Python-based Monte Carlo neutron transport software currently developed in the Center for Exascale Monte Carlo Neutron Transport (CEMeNT).
Please Note that this project is in the early stages of devlopment. We welcome any and all collaborators, feel free to reach out via comments or submit a PR! Enjoy!
In the root directory:
pip install -e .
As an example, let us consider a simple time-dependent transport problem based on the AZURV1 benchmark:
import numpy as np
import mcdc
# =============================================================================
# Set model
# =============================================================================
# Set materials
m = mcdc.material(capture = np.array([1.0/3.0]),
scatter = np.array([[1.0/3.0]]),
fission = np.array([1.0/3.0]),
nu_p = np.array([2.3]),
speed = np.array([1.0]))
# Set surfaces
s1 = mcdc.surface('plane-x', x=-1E10, bc="reflective")
s2 = mcdc.surface('plane-x', x=1E10, bc="reflective")
# Set cells
mcdc.cell([+s1, -s2], m)
# =============================================================================
# Set source
# =============================================================================
mcdc.source(point=[0.0,0.0,0.0], isotropic=True)
# =============================================================================
# Set tally, setting, and run mcdc
# =============================================================================
# Tally
mcdc.tally(scores=['flux'],
x=np.linspace(-20.5, 20.5, 202),
t=np.linspace(0.0, 20.0, 21))
# Setting
mcdc.setting(N_particle=1E3)
# Run
mcdc.run()
If we save the input script above as input.py
, we can run it as follows:
python input.py
A more advanced input example that includes setting up multigroup (in energy and
delayed precursor) materials, lattice geometry, and continuous movements of
control rods is provided in MCDC/example/c5g7/3d/TDX
.
MC/DC simulation results are stored in
HDF5 format, which can be processed
using H5Py (default file name: output.h5
) as follows:
import h5py
with h5py.File('output.h5', 'r') as f:
x = f['tally/grid/x'][:]
t = f['tally/grid/t'][:]
phi = f['tally/flux/mean'][:]
phi_sd = f['tally/flux/sdev'][:]
MC/DC supports transport kernel acceleration via Numba's Just-in-Time compilation (currently only the CPU implementation). Running in Numba mode takes an overhead of about 15 to 80 seconds depending on the physics/features simulated; however, once compiled, the simulation runs MUCH faster than the Python mode.
To run in the Numba mode:
python input.py --mode=numba
MC/DC supports parallel simulation via MPI4Py. As an example, to run on 36 processes in Numba mode with SLURM:
srun -n 36 python input.py --mode=numba