OpenMC Python Tutorial & Guide

Master OpenMC - The modern, Python-powered Monte Carlo code for nuclear simulations. Free comprehensive tutorials and examples for reactor physics calculations.

Start Learning OpenMC →

Last Updated: February 2026

Why engineers choose OpenMC

OpenMC is a modern, open-source Monte Carlo code with a Python-first workflow. It pairs a high-performance transport engine with the flexibility of the Python ecosystem, making it a favorite for research groups, startups, and advanced university courses.

Python-first design

Model geometry, materials, and tallies with a clean Python API that works seamlessly with NumPy, pandas, and matplotlib.

High-performance engine

MPI & OpenMP parallelism plus support for continuous-energy and multigroup tallies make OpenMC scale on modern clusters.

Research friendly

Open source on GitHub with transparent development, extensive documentation, and an active community.

Modern tooling

Native plotting helpers, statepoint readers, and compatibility with Jupyter notebooks accelerate post-processing.

Quick start guides

Python API Example

Create a simple pin cell model using OpenMC's intuitive Python API:

python
import openmc

# Materials definitions
fuel = openmc.Material(name='Fuel')
fuel.add_nuclide('U235', 0.05)
fuel.add_nuclide('U238', 0.95)
fuel.add_nuclide('O16', 2.0)
fuel.set_density('g/cm3', 10.4)

clad = openmc.Material(name='Cladding')
clad.add_element('Zr', 1.0)
clad.set_density('g/cm3', 6.55)

water = openmc.Material(name='Water')
water.add_nuclide('H1', 2.0)
water.add_nuclide('O16', 1.0)
water.set_density('g/cm3', 1.0)

materials = openmc.Materials([fuel, clad, water])
materials.export_to_xml()

# Geometry definitions
fuel_radius = 0.4
clad_radius = 0.46
pin_pitch = 1.26

fuel_outer = openmc.ZCylinder(r=fuel_radius)
clad_outer = openmc.ZCylinder(r=clad_radius)

fuel_region = -fuel_outer
clad_region = +fuel_outer & -clad_outer
water_region = +clad_outer

pin_cells = []

# Create fuel pin cell
fuel_cell = openmc.Cell(fill=fuel, region=fuel_region)
clad_cell = openmc.Cell(fill=clad, region=clad_region)
water_cell = openmc.Cell(fill=water, region=water_region)

universe = openmc.Universe(cells=[fuel_cell, clad_cell, water_cell])

# Run settings
settings = openmc.Settings()
settings.batches = 100
settings.inactive = 30
settings.particles = 10000

# Create source
bounds = [-0.63, 0.63, -0.63, 0.63, -1, 1]
source = openmc.Source(space=openmc.stats.Box(bounds[:2], bounds[2:4], bounds[4:]))
settings.source = source
settings.export_to_xml()

# Run OpenMC
openmc.run()

Key Concepts Shown

  • Material definitions
  • Geometry construction
  • Run settings
  • Source specification

Common Variations

  • Change enrichment levels
  • Modify geometry
  • Add temperature effects
  • Include depletion

Frequently Asked Questions

How do I install OpenMC?

OpenMC can be installed via conda: conda install -c conda-forge openmc. This includes the Python API and all necessary dependencies.

What Python version is required?

OpenMC supports Python 3.7+ and is regularly tested with the latest Python versions. We recommend using Python 3.8 or newer.

Where do I get nuclear data?

OpenMC provides scripts to download pre-processed nuclear data libraries. You can also process your own data using NJOY.

Advanced capabilities

Multi-physics coupling

Use OpenMC's Python hooks to exchange data with CFD, thermal hydraulics, or fuel performance solvers.

Depletion & burnup

Run depletion calculations with Bateman solvers and analyze isotopic inventories at each burn step.

OpenMC applications

Reactor physics

  • Fuel pin and assembly benchmarking
  • Core design experimentation for SMRs and research reactors
  • Flux, power, and reaction rate mapping
  • Control rod worth and reactivity coefficients

Research & academic workflows

  • Monte Carlo method development in open source
  • Sensitivity/uncertainty studies using Python ecosystems
  • Neutronics coupling with machine learning workflows
  • Education and rapid prototyping

Ready to Master OpenMC?

Start with our step-by-step Python tutorials and become proficient in nuclear Monte Carlo simulations.