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.

Recommended

Docker

Containerized installation for consistent environments across platforms.

Reproducible

Source Build

Compile from source for latest features and development work.

Advanced

Conda Installation (Recommended)

Using conda is the simplest way to install OpenMC for most users. It automatically handles dependencies and provides pre-built binaries that work reliably across platforms.

Step 1: Install Conda

If you don't have conda installed, download and installMiniconda(recommended) orAnaconda.

Step 2: Create Environment and Install

bash
# 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 numpy

Step 3: Verify Installation

bash
# 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!')
"

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

bash
# 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/openmc

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.

python
# Download ENDF/B-VIII.0 data (recommended for beginners)
python -c "import openmc.data; openmc.data.download_endf_data(release='endfb80_hdf5')"

# This downloads ~1.5 GB of data to your system
# The data will be automatically found by OpenMC

This command downloads essential nuclear data files that OpenMC needs for physics calculations. The download is automatic and the data is stored in a standard location that OpenMC can find.

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:

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

Getting Help

If you encounter issues during installation, here are the best resources for help:

For beginners, we strongly recommend starting with the conda installation method. It's the most reliable and requires the least troubleshooting.