StatePoint Files in OpenMC

Understanding StatePoint Files

OpenMC stores all simulation results in StatePoint files (*.h5 format).

What's Inside

  • Tally results
  • Statistical uncertainties
  • K-effective (for criticality)
  • Simulation settings

Common Uses

  • Get tally data
  • Check convergence
  • Plot results
  • Export to other formats

Basic Usage

Basic result extraction:

Opening Results

python
# Load the results
sp = openmc.StatePoint('statepoint.100.h5')

# Basic information
print(f"k-effective = {sp.keff.nominal_value:.5f} ± {sp.keff.std_dev:.5f}")

# Get a specific tally
tally = sp.get_tally(name='flux')
mean = tally.mean
rel_err = tally.std_dev / tally.mean

Tutorial snippet — no separate file in examples repo

Tip: Always check the relative error of your results. Values above 0.1 (10%) indicate poor statistics and may need more particles.

Working with Data

Tally data can be converted to pandas DataFrames for analysis:

Data Analysis

python
# Convert tally to DataFrame
df = tally.get_pandas_dataframe()

# Filter results
flux = df[df['score'] == 'flux']
u235 = df[df['nuclide'] == 'U235']

# Basic statistics
print(f"Average flux: {flux['mean'].mean()}")
print(f"Max flux: {flux['mean'].max()}")

Tutorial snippet — no separate file in examples repo

Simple Plot

python
import matplotlib.pyplot as plt

# Plot flux by tally bin
flux = df[df['score'] == 'flux']
plt.figure()
plt.plot(flux['mean'].values, 'o-')
plt.xlabel('Tally Bin')
plt.ylabel('Flux')
plt.grid(True)
plt.savefig('flux.png')

Tutorial snippet — no separate file in examples repo

K-eff Plot

python
# Plot k-effective convergence
keff_by_gen = sp.k_generation
batches = range(1, len(keff_by_gen) + 1)

plt.figure()
plt.plot(batches, keff_by_gen, 'o-')
plt.xlabel('Batch')
plt.ylabel('k-effective')
plt.grid(True)
plt.savefig('keff.png')

Tutorial snippet — no separate file in examples repo

Best Practices

Analysis Tips

  • Always check uncertainties
  • Plot results to spot issues
  • Save raw data for later
  • Document your analysis
  • Use pandas for complex analysis

Additional Resources