Source Definition in OpenMC

Introduction to Sources

Sources define where particles originate in your simulation. OpenMC supports two main simulation modes:

Eigenvalue Mode

Initial source only starts the simulation. Fission sites become sources for later generations. Common for reactor calculations.

Fixed-source Mode

Source definition affects all results. Must accurately represent your physical source. Common for shielding calculations.

Basic Source Setup

A source has three main components: where particles start (space), their energy, and their direction (angle). Current OpenMC uses openmc.IndependentSource to build sources (the older openmc.Source name is not what you want in recent releases).

Simple Point Source

python
# Create point source at origin with default settings
source = openmc.IndependentSource(
    space=openmc.stats.Point((0., 0., 0.)),     # Location
    energy=openmc.stats.Discrete([1.0e6], [1.0]), # 1 MeV neutrons
    angle=openmc.stats.Isotropic()               # All directions
)

# Add to settings
settings = openmc.Settings()
settings.source = source

Tutorial snippet — no separate file in examples repo

Common Source Types

Box Source

python
# Uniform distribution in a box
box_source = openmc.IndependentSource(
    space=openmc.stats.Box(
        (-10., -10., -10.),  # Lower-left
        (10., 10., 10.)      # Upper-right
    )
)

Tutorial snippet — no separate file in examples repo

Cylindrical Source

python
import numpy as np

# Uniform in a cylinder
r = openmc.stats.Uniform(0., 5.0)
phi = openmc.stats.Uniform(0., 2*np.pi)
z = openmc.stats.Uniform(-10., 10.)

cyl_source = openmc.IndependentSource(
    space=openmc.stats.CylindricalIndependent(
        r, phi, z
    )
)

Tutorial snippet — no separate file in examples repo

Tip: For reactor simulations, you often don't need to specify a detailed source - a simple uniform distribution in the fuel region is sufficient as the fission source will quickly converge.

Energy Distributions

Common Sources

python
# Fusion source (14.1 MeV)
fusion = openmc.stats.Discrete([14.1e6], [1.0])

# Fission spectrum
fission = openmc.stats.Watt(a=0.988e6, b=2.249e-6)

# Thermal source
thermal = openmc.stats.Maxwell(1.2e6)

Tutorial snippet — no separate file in examples repo

Custom Distribution

python
# Define energy points and probabilities
energies = [0.0, 1e6, 2e6, 3e6]  # eV
probs = [0.0, 0.5, 1.0, 0.0]

custom = openmc.stats.Tabular(energies, probs)

Tutorial snippet — no separate file in examples repo

Multiple Sources

You can combine multiple sources with different strengths:

python
# Create two sources
src1 = openmc.IndependentSource(space=openmc.stats.Point((0., 0., 0.)))
src1.strength = 2.0  # Twice as strong

src2 = openmc.IndependentSource(space=openmc.stats.Point((10., 0., 0.)))
src2.strength = 1.0

# Combine sources
settings.source = [src1, src2]

Tutorial snippet — no separate file in examples repo

Additional Resources