Skip to main content

Monte Carlo / Dynamic Code, a pure python high preofmrance Monte Carlo neutronics package

Project description

MC/DC: Monte Carlo Dynamic Code

mcdc_logo v1

Build ReadTheDocs License

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).

We have documentation on, installation, contribution and a brief user guide using Read the Docs

Installation

We recommend using conda or some other environment manager to manage the MC/DC installation. This avoids the need for sudo access for MC/DC's dependencies and allows greater configurability for developers. For most users working on a single machine that they are administrators of MC/DC can be installed with:

pip install mcdc

Common issues with mpi4py

The pip mpi4py distribution commonly has errors when building due to incompatible local MPI dependencies it builds off of. While pip does have some reamdie for this we recommend the following:

  • Mac users: we recommend openmpi is installed via homebrew (note that more reliable mpi4py distribution can also be found on homebrew), alternatively you can use conda if you don't have admin privileges;
  • Linux users: we recommend openmpi is installed via a root package manager if possible (e.g. sudo apt install openmpi) or a conda distribution (e.g. conda install openmpi)
  • HPC users and developers on any system: we recommend you do not use the pip distribution and instead install MC/DC and its dependencies via install scripts we've included that will build mpi4py from source and use conda to manage your environment. This is the most reliable way MC/DC can be installed and configured. It also takes care of the Numba patch, and can configure the continuous energy data library if you have access.

Numba Configuration

MC/DC requires Numba to be patched to be able to run performantly in numba mode. There is a very simple patch file that will make it automatically. To patch numba

  1. Download the patch.sh file here (If you cloned the git packa)
  2. Make sure you have bash installed if nessacary (macOS)
  3. In your active conda environment run bash patch_numba.sh If you manage your environment with conda you will not need admin privileges

visualizer Config

MC/DC has a visualizer built from the netgen package. This is not included in the base install of MC/DC due to the size of the dependencies (~300MB). To install these dependencies use

pip install mcdc['viz']

Running

MC/DC has many different modes you can run in. A generous flexible pure python environment or a jit compiled fast, but restrictive, mode. Depending on your use case you will most likely favor one over the other.

Pure Python

To run a hypothetical input deck (for example this slab wall problem) in pure python mode run:

python input.py

Simulation outputs will be placed in the same directory the input.py file is located in.

Numba mode

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

Running in parallel

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

For system that do no use SLURM (i.e. a local system) try mpiexec or mpirun in its stead.

Contributions

We welcome any contributions to this code base. Please keep in mind our code of conduct that we do take seriously. We work off a forking development structure where you fork this repo, make contributions then open a pull request. That code will then be reviewed by the primary developers. For more information on how to do this see our Contribution guide

Bugs and Issues

Our documentation is in the early stages of development so bare with us while we bring that upto snuff. If you do feel that you have found a novel bug or we should be aware of feel free to open an issue *We are not your HPC's admins. We can only do so much

Testing

MC/DC uses CI to run it's unit and regression test suite. MC/DC also includes a verification and performance test that get ran on nightly builds on internal systems. For specifics on how to run these tests locally go here.

Cite

To provide proper attribution to MC/DC please cite,

@inproceedings{var_mc23_mcdc,
    Booktitle = {International Conference on Mathematics and Computational Methods Applied to Nuclear Science and Engineering},
    title = {Development of {MC/DC}: a performant, scalable, and portable Python-based {M}onte {C}arlo neutron transport code},
    year = {2023},
    author = {Ilham Variansyah and Joanna Piper Morgan and Kyle E. Niemeyer and Ryan G. McClarren},
    address = {Niagara Falls, Ontario, Canada},
    doi={10.48550/arXiv.2305.07636},
}

which should render something like this

Variansyah, Ilham, J. P. Morgan, K. E. Niemeyer, and R. G. McClarren. 2023. “Development of MC/DC: a performant, scalable, and portable Python-based Monte Carlo neutron transport code.” In International Conference on Mathematics and Computational Methods Applied to Nuclear Science and Engineering, Niagara Falls, Ontario, Canada. DOI. 10.48550/arXiv.2305.07636

License

MC/DC is licensed under a BSD-3 clause license. We believe in open source software

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcdc-0.9.0.tar.gz (15.9 MB view details)

Uploaded Source

Built Distribution

mcdc-0.9.0-py3-none-any.whl (70.9 kB view details)

Uploaded Python 3

File details

Details for the file mcdc-0.9.0.tar.gz.

File metadata

  • Download URL: mcdc-0.9.0.tar.gz
  • Upload date:
  • Size: 15.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for mcdc-0.9.0.tar.gz
Algorithm Hash digest
SHA256 c3b5ffae9d8899a6d628558ad61f025620e5cee6abb8efe51a1d9b90c4c46891
MD5 3a1654579c3516b4c26eef2eac970ad5
BLAKE2b-256 cf9f710e4a02421195fa0b4b9c62efdd1a8438c5c15d1098818abaf7cfdb7aec

See more details on using hashes here.

File details

Details for the file mcdc-0.9.0-py3-none-any.whl.

File metadata

  • Download URL: mcdc-0.9.0-py3-none-any.whl
  • Upload date:
  • Size: 70.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for mcdc-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9142b740bc5df64719c840d6ec675750f7070230953dc2ed53334b84cc683498
MD5 e9a68a7348734584ff1b2ff7e17ec424
BLAKE2b-256 8fb2f81f01d0ca3d6d8c482d295a447cdc019122db168b9507aad43467bdff31

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page