Settings Parameters in OpenMC

What you'll learn

First pin cell · 7 / 1110 min read
  • Choose particles, batches, and inactive batches, and explain what each one buys you.
  • Switch between eigenvalue and fixed source run modes.
  • Stop a run automatically once k-effective reaches a target uncertainty.

Before you start

Batches, particles, and two run modes

Settings controls how the transport solve runs rather than what it solves — particle counts, run mode, source, and stopping criteria. A run is batches batches of particles particles each, and in an eigenvalue calculation the first inactive of those batches are thrown away, because the fission source starts wherever you put it and needs a few generations to relax onto the fundamental mode shape before the tallies mean anything. Note that inactive counts against batches, not on top of it — a run with batches=100, inactive=20 gives you 80 active batches of statistics, not 100.

python
settings = openmc.Settings()
settings.batches = 50
settings.inactive = 10
settings.particles = 5000
settings.run_mode = 'eigenvalue'   # or 'fixed source'

Tutorial snippet — no separate file in examples repo

'eigenvalue' mode is for a self-sustaining system where the source is the fission it produces — reactors, critical assemblies. 'fixed source' mode is for everything driven by an external, non-multiplying source instead — shielding, detector response, dose. There is no concept of inactive batches in fixed source mode, because there is no fission source to converge; every batch counts toward the result.

To stop an eigenvalue run automatically once its uncertainty is good enough rather than guessing a batch count up front, set a trigger:

python
# Stop once the k-eff standard deviation drops below 0.001 (100 pcm).
# 'std_dev' is an absolute threshold; use 'rel_err' for a relative one.
settings.keff_trigger = {'type': 'std_dev', 'threshold': 0.001}
settings.trigger_active = True
settings.trigger_max_batches = 500   # hard ceiling, in case it never converges

Tutorial snippet — no separate file in examples repo

The pin cell's settings

The pin cell runs in eigenvalue mode with a starting source placed inside the fuel. This is the same fragment that appears on Example: Pin Cell.

python
settings = openmc.Settings()
settings.batches = 100
settings.inactive = 20
settings.particles = 10000

# Starting guess for the fission source — anywhere inside the fuel pellet works
source_region = openmc.stats.Box(
    [-fuel_radius, -fuel_radius, -1],
    [fuel_radius, fuel_radius, 1],
)
settings.source = openmc.IndependentSource(space=source_region)

Tutorial snippet — no separate file in examples repo

In eigenvalue mode this starting box barely matters: it only seeds the first batch, and the 20 inactive batches above exist precisely to let the fission source forget that starting guess and converge onto the pin's actual fundamental mode before any tally starts counting. In fixed source mode there are no inactive batches to absorb a bad guess — the source you specify is the problem, and getting its space, energy, and angle right matters for every single batch.

openmc.Source still works as a deprecated alias for openmc.IndependentSource, which is what current code and this page use. Building a source with energy spectra, angular distributions, or multiple components is covered on Source Definition.

Check yourself

  • Choose particles, batches, and inactive batches, and explain what each one buys you?
  • Switch between eigenvalue and fixed source run modes?
  • Stop a run automatically once k-effective reaches a target uncertainty?