StatePoint Files in OpenMC

Understanding StatePoint Files

After running a simulation, you need to analyze your results. OpenMC stores all simulation results in StatePoint files (*.h5 files). Let's learn how to work with them.

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

Let's start with the basics of reading results:

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

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

OpenMC makes it easy to analyze your results using pandas:

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()}")

Simple Plot

python
import matplotlib.pyplot as plt

# Plot flux vs. position
plt.figure()
plt.plot(df['x'], df['mean'], 'o-')
plt.xlabel('Position (cm)')
plt.ylabel('Flux')
plt.grid(True)
plt.savefig('flux.png')

K-eff Plot

python
# Plot k-effective convergence
keff_by_gen = sp.keff_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')

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