OpenMC Guide
Installing OpenMC
What you'll learn
- Install OpenMC with conda-forge, or run it from the official Docker image.
- Download a nuclear data library and point OPENMC_CROSS_SECTIONS at it.
- Confirm the install works by building and exporting a one-material model.
Before you start
Choose Your Installation Method
Pick conda unless you already have a specific reason not to. It resolves OpenMC's C++ dependencies for you, and it is what the rest of this path — including the pin cell you are building toward — assumes you are running. Docker is worth it only if you need an identical environment across machines; a source build is for developing OpenMC itself, not for learning it.
Conda Installation
Pre-built binaries with automatic dependency management. Works on Windows, macOS, and Linux.
RecommendedDocker
Containerized installation for consistent environments across platforms.
ReproducibleSource Build
Compile from source for latest features and development work.
AdvancedConda Installation (Recommended)
Step 1: Install Conda
If you don't have conda installed, download and installMiniconda(recommended) orAnaconda.
Step 2: Create Environment and Install
# Create a dedicated environment for OpenMC
conda create -n openmc-env python=3.11
conda activate openmc-env
# Install OpenMC from conda-forge
conda install -c conda-forge openmc
# Install additional useful packages
conda install -c conda-forge jupyter matplotlib pandas scipy numpyTutorial snippet — no separate file in examples repo
Step 3: Verify Installation
# Test the installation
python -c "import openmc; print(f'OpenMC version: {openmc.__version__}')"
# Quick functionality test
python -c "
import openmc
mat = openmc.Material()
mat.set_density('g/cm3', 1.0)
print('OpenMC is working correctly!')
"Tutorial snippet — no separate file in examples repo
Pro Tip: Always activate your conda environment before using OpenMC:conda activate openmc-env
Docker Installation
Docker gives you the same environment on any machine, at the cost of an extra layer between you and your files. Install Docker Desktop first, then pull and run the image with your working directory mounted in:
docker pull openmc/openmc
# Windows PowerShell:
docker run -it --rm -v "${PWD}:/work" -w /work openmc/openmc
# Linux/macOS:
docker run -it --rm -v "$(pwd):/work" -w /work openmc/openmcTutorial snippet — no separate file in examples repo
Installing nuclear data
OpenMC ships no cross-section data of its own. Download an HDF5 library — ENDF/B-VIII.0 from openmc.org/data is the standard starting choice — and point OPENMC_CROSS_SECTIONS at the cross_sections.xml file inside that download, not at the folder that contains it.
export OPENMC_CROSS_SECTIONS=/path/to/endfb-viii.0-hdf5/cross_sections.xml
# Windows PowerShell:
# $env:OPENMC_CROSS_SECTIONS = "C:\path\to\cross_sections.xml"
# Set it permanently in your shell profile so every new session picks it up.Tutorial snippet — no separate file in examples repo
Skip this step, or point the variable at the directory instead of the file, and any run fails the same way: RuntimeError: No cross_sections.xml file was specified in materials.xml or in the OPENMC_CROSS_SECTIONS environment variable. That message means exactly what it says — check echo $OPENMC_CROSS_SECTIONS (or echo %OPENMC_CROSS_SECTIONS% on Windows) resolves to a file that exists, not a directory.
Test Your Installation
Here's a simple test to verify everything is working correctly. Save this as test_openmc.py and run it:
import openmc
# Create a simple material
water = openmc.Material()
water.set_density('g/cm3', 1.0)
water.add_nuclide('H1', 2.0)
water.add_element('O', 1.0)
water.add_s_alpha_beta('c_H_in_H2O')
# Create simple geometry
sphere = openmc.Sphere(r=10, boundary_type='vacuum')
cell = openmc.Cell(fill=water, region=-sphere)
geometry = openmc.Geometry([cell])
# Basic settings
settings = openmc.Settings()
settings.particles = 1000
settings.batches = 20
settings.inactive = 5
# Quick test run
model = openmc.Model(geometry, openmc.Materials([water]), settings)
print("Creating model files...")
model.export_to_xml()
print("Installation test successful!")
print("OpenMC is ready to use.")Tutorial snippet — no separate file in examples repo
Getting Help
Beyond the official installation guide, the OpenMC community forum is the fastest way to get an installation problem in front of people who have seen it before.
Check yourself
- Install OpenMC with conda-forge or the official Docker image?
- Download a nuclear data library and point
OPENMC_CROSS_SECTIONSat it? - Build and export a one-material model to confirm the install?