OpenMC Guide
Installing OpenMC
Choose Your Installation Method
The easiest way to install OpenMC is using conda, which handles all dependencies automatically. For most users, this is the recommended approach. More advanced users may prefer Docker for reproducible environments or building from source for development.
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.9
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 provides a completely isolated OpenMC environment that works identically across all platforms. This is ideal for reproducible research or when you want to avoid modifying your system.
Quick Setup
# Pull the OpenMC Docker image
docker pull openmc/openmc
# Run OpenMC in a container (mount current directory)
# 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
This gives you a complete OpenMC environment with Python, Jupyter, and all dependencies pre-installed. Your current directory is mounted as /work in the container, so you can access your files normally.
Note: Install Docker Desktop fromdocker.combefore using this method.
Installing Nuclear Data
OpenMC requires nuclear cross-section data to run simulations. The easiest way to get started is to download a basic data library.
# Option 1: Download pre-built HDF5 data from the OpenMC website
# Visit https://openmc.org/data/ and download the ENDF/B-VIII.0 library
# Or grab it from the GitHub releases page
# Option 2: If you installed via conda, nuclear data may already be available.
# Check with: echo $OPENMC_CROSS_SECTIONS (Linux/macOS)
# echo %OPENMC_CROSS_SECTIONS% (Windows)
# After downloading, tell OpenMC where to find the data:
import os
os.environ['OPENMC_CROSS_SECTIONS'] = '/path/to/cross_sections.xml'
# Or set it permanently in your shell profile (~/.bashrc, etc.):
# export OPENMC_CROSS_SECTIONS=/path/to/cross_sections.xmlTutorial snippet — no separate file in examples repo
OpenMC needs pre-built HDF5 nuclear data files to run simulations. Download them from theOpenMC websiteand point the OPENMC_CROSS_SECTIONS environment variable at the cross_sections.xml file included in the download.
First Time Setup: The nuclear data download is a one-time process but requires ~1.5 GB of disk space and a good internet connection.
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
If you encounter issues during installation, here are the best resources for help:
- Official OpenMC Documentation - comprehensive installation guide
- OpenMC Community Forum - ask questions and get help from users
- GitHub Issues - report bugs or installation problems
For most users, conda is the most reliable installation method.