MCNP Output Analysis

Understanding and validating your simulation results

Statistical Quality Checks

MCNP provides ten statistical tests to verify result reliability. All tests should pass for trusted results.

Key Statistical Tests

  • Mean behavior: Should stabilize in last half
  • Relative error: Should be < 0.10 and decrease
  • Variance of variance: Should decrease steadily
  • Figure of merit: Should remain constant
  • PDF slope: Should be > 3

What Good Results Look Like

  • All 10 statistical checks pass
  • Relative error decreases as 1/√N
  • Mean stays within 1-2 standard deviations
  • Figure of merit stays roughly constant
  • No obvious trends in tally fluctuation

Example Statistical Output

text
tally   4    nps = 1000000
          mean     = 2.43156E-01
          rel err  = 1.23E-02
          vov      = 1.52E-04
          fom      = 2.78E+02
          slope    = 3.2
          
statistical checks: all 10 passed
status: results pass all statistical checks

This shows a well-converged result with good statistics.

Common Analysis Tasks

Extracting Tally Data

bash
# Extract tally results from output
grep -A 20 "tally   4" output_file

# Get final tally values
grep "nps =" output_file | tail -1

# Check statistical tests
grep "statistical checks" output_file

Python Analysis Script

python
import numpy as np
import matplotlib.pyplot as plt

# Read MCNP output data
def read_mcnp_tally(filename):
    with open(filename, 'r') as f:
        lines = f.readlines()
    
    # Find tally data and extract values
    tally_data = []
    for line in lines:
        if 'nps =' in line:
            parts = line.split()
            mean = float(parts[2])
            rel_err = float(parts[5])
            tally_data.append([mean, rel_err])
    
    return np.array(tally_data)

# Plot convergence
data = read_mcnp_tally('output')
plt.plot(data[:, 0], label='Mean')
plt.plot(data[:, 1], label='Relative Error')
plt.legend()
plt.savefig('convergence.png')

Visualization Tools

Mesh Tally Visualization

python
# Convert mesh tally to VTK
mcnp2vtk input=meshtal output=results.vtk

# Python visualization
import matplotlib.pyplot as plt
import numpy as np

data = np.loadtxt('meshtal')
plt.imshow(data, cmap='hot')
plt.colorbar()
plt.title('Flux Distribution')
plt.savefig('flux_map.png')

Useful Tools

  • matplotlib: 2D plots and data analysis
  • ParaView: 3D mesh tally visualization
  • MCNP Visual Editor: Geometry plotting
  • Excel/LibreOffice: Basic data analysis
  • VisIt: Large dataset visualization

Troubleshooting Poor Results

Common Problems and Solutions

  • High relative error: Run more particles or use variance reduction
  • Failed statistical tests: Check for proper convergence and adequate sampling
  • Unstable mean: May need longer run or better importance sampling
  • Low figure of merit: Consider variance reduction techniques
  • Unrealistic results: Check geometry, materials, and source definition

Quick Diagnostic Checks

  • Are all statistical tests passing?
  • Is the relative error reasonable for your application?
  • Does the result make physical sense?
  • Are there any warning messages in the output?
  • Is the geometry correct (check with plots)?

Improving Results

  • Increase particle count (NPS)
  • Use appropriate variance reduction
  • Check tally placement and size
  • Verify source definition
  • Consider geometry simplifications

Best Practices

Analysis Workflow

  1. Check that MCNP completed without fatal errors
  2. Verify all statistical tests pass
  3. Review relative errors are acceptable
  4. Compare results to physical expectations
  5. Document analysis methods and assumptions
  6. Archive both input files and results

Documentation Tips

  • Record MCNP version and date
  • Save input files with descriptive names
  • Document any assumptions or approximations
  • Include statistical quality information
  • Note any unusual results or problems
  • Keep analysis scripts for reproducibility