OpenMC Guide
Tallies in OpenMC
What you'll learn
- Define a tally from three parts: filters, scores, and nuclides.
- Restrict results by cell, material, energy, or mesh.
- Name a tally so you can retrieve it again from the statepoint.
Before you start
What a tally needs
A tally scores something without touching the physics being simulated — filters and scores tell it what to watch, they never bias how particles move. Every tally needs filters, which restrict where and when it applies (a cell, a material, an energy range, a mesh), and scores, which say what to record (flux, fission,absorption, heating, and specific reactions by MT number). Add nuclides if you want a score broken out per isotope instead of summed over the whole material.
tally = openmc.Tally(name='fuel_flux')
tally.filters = [openmc.CellFilter([fuel_cell])]
tally.scores = ['flux', 'fission']
tally.nuclides = ['U235', 'U238'] # optional — omit to sum over the material
tallies = openmc.Tallies([tally])Tutorial snippet — no separate file in examples repo
Name every tally you create. The default name is just the tally's numeric ID, which shifts if you add or remove a tally earlier in the script — a fragile way to find results again. A stable string name is what the Running and StatePoint pages, and any later analysis script, use to look the tally up by sp.get_tally(name=...).
Beyond cell and material filters, an EnergyFilter splits a score into energy bins and a MeshFilter spreads it over a spatial grid. Angular filters (PolarFilter, AzimuthalFilter) and a TimeFilter exist for directional and time-dependent problems, but neither is needed for a static k-eigenvalue pin cell. Each filter you add multiplies the number of bins in the result, so use only the ones the question you're asking actually requires.
The pin cell's three tallies
The pin cell tallies flux in all three regions, plus the two reaction rates needed to sanity-check k-effective in the fuel. This is the same fragment that appears on Example: Pin Cell.
tallies = openmc.Tallies()
fuel_tally = openmc.Tally(name='fuel_flux')
fuel_tally.filters = [openmc.CellFilter(fuel_cell)]
fuel_tally.scores = ['flux', 'nu-fission', 'absorption']
tallies.append(fuel_tally)
clad_tally = openmc.Tally(name='clad_flux')
clad_tally.filters = [openmc.CellFilter(clad_cell)]
clad_tally.scores = ['flux', 'absorption']
tallies.append(clad_tally)
water_tally = openmc.Tally(name='water_flux')
water_tally.filters = [openmc.CellFilter(water_cell)]
water_tally.scores = ['flux', 'absorption']
tallies.append(water_tally)Tutorial snippet — no separate file in examples repo
None of these three carries an EnergyFilter, so each score is integrated over the whole spectrum. Reading the results back — as arrays, or as a pandas dataframe for the full breakdown — is covered on StatePoint Files, once there is a finished run to read from.
One thing to try
Add 'fission' to the fuel tally's scores, alongside the existing 'nu-fission'. Predict which one comes out larger before you check — one of them counts fission events, the other multiplies each event by ν, the number of neutrons released per fission.
fuel_tally.scores = ['flux', 'nu-fission', 'fission', 'absorption']Tutorial snippet — no separate file in examples repo
Check yourself
- Define a tally from filters, scores, and nuclides?
- Restrict results by cell, material, energy, or mesh?
- Name a tally so you can retrieve it again from the statepoint?