Giter Site home page Giter Site logo

mcdc's Introduction

MC/DC: Monte Carlo Dynamic Code

mcdc_logo v1

License Code of Conduct Code style: black

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!

Installation

In the root directory:

pip install -e .

Usage

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.

Output

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'][:]

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

mcdc's People

Contributors

ilhamv avatar spasmann avatar jpmorgan98 avatar braxtoncuneo avatar northroj avatar goodman17c avatar clemekay avatar rohanpankaj avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.