SERPENT Guide
Basic Output Analysis in Serpent
Serpent Output File Overview
After running a Serpent simulation, several output files are generated. Each file contains different types of information:
Main Results File (_res.m)
- Criticality (k-effective) results
- Neutron balance data
- Reaction rates
- Group constant data (if requested)
Detector Output (_det0.m)
- User-defined detector results
- Flux, reaction rate tallies
- Energy spectra
- Mesh data
Depletion Output (_dep.m)
- Material compositions over time
- Burnup/depletion results
- Isotopic inventories
- Only present in burnup calculations
Log File (_out)
- Detailed simulation log
- Warnings and error messages
- Memory usage information
- Processing times
Note: The _res.m and _det*.m files are formatted for MATLAB/Octave but can also be processed using Python or other tools.
Reading the Main Results File
The main results file (*_res.m) contains the most important simulation results. Let's examine its key sections:
Criticality Results
For k-eigenvalue (criticality) calculations, the most important results are:
% Output from pin_cell_res.m
% -- Criticality eigenvalue (k-eff) --
IMP_KEFF = [ 1.34721 0.00095 ];
ANA_KEFF = [ 1.34728 0.00091 ];These values represent:
IMP_KEFF: Implicit k-effective (collision estimate)ANA_KEFF: Analog k-effective (absorption estimate)- Format: [ value statistical_uncertainty ]
Neutron Balance
The neutron balance table shows production and loss rates:
% -- Neutron balance --
LOSS_CAPT = 3.25933E-01; % Capture
LOSS_FISS = 6.74215E-01; % Fission
LOSS_LEAK = 0.00000E+00; % Leakage
TOT_LOSS = 1.00015E+00; % Total loss
PROD_FISS = 1.00000E+00; % Fission source
PROD_NXN = 1.47723E-04; % (n,xn) reactions
TOT_PROD = 1.00015E+00; % Total productionImportant: In a properly converged simulation, the total production and loss should be very close to equal. Large discrepancies may indicate problems with your model or insufficient statistics.
Energy-Integrated Reaction Rates
The results file also contains various reaction rates:
% -- Reaction rates by material --
TOT_FISSRATE = [ 6.74215E-01 0.00083 ]; % Total fission rate
NUBAR = [ 2.43943E+00 0.00000 ]; % Average neutrons per fission
% Material-wise data
MAT_fuel_FISSRATE = [ 6.74215E-01 0.00083 ]; % Fission rate in fuel
MAT_fuel_ABSRATE = [ 1.00015E+00 0.00000 ]; % Absorption rate in fuel
MAT_water_ABSRATE = [ 0.00000E+00 0.00000 ]; % Absorption rate in waterUnderstanding Detector Output
Detector outputs (*_det*.m) contain user-defined tallies specified in the input file. These are powerful tools for detailed analysis.
Energy-Dependent Flux Spectrum
A common detector is the energy-dependent flux spectrum:
% -- Flux spectrum detector --
DET_ENERGY = [ 1.00000E-11 1.00000E-10 ... 1.00000E+2 ]; % Energy bin boundaries
DET_FLUX = [
4.53211E-3 0.012; % First energy bin (flux + rel. error)
7.82145E-3 0.009; % Second energy bin
...
];Spatial Distribution Detectors
Mesh detectors provide spatial distributions:
% -- Mesh detector (2D) --
DET_MESH_X = [ -0.63 -0.42 -0.21 0.0 0.21 0.42 0.63 ]; % X-mesh boundaries
DET_MESH_Y = [ -0.63 -0.42 -0.21 0.0 0.21 0.42 0.63 ]; % Y-mesh boundaries
DET_MESH_VAL = [ % Values for each mesh element (flux, reaction rate, etc.)
1.23456E-3 0.012, 2.34567E-3 0.010, ... ; % First row
3.45678E-3 0.009, 4.56789E-3 0.008, ... ; % Second row
...
];Pro Tip: When setting up detectors, be specific about what you want to measure. Well-designed detectors can provide detailed insights but too many detectors can slow down your simulation.
Evaluating Statistical Errors
Monte Carlo results always have statistical uncertainties. Understanding and evaluating these errors is crucial:
Relative Statistical Errors
In Serpent output, most results include a relative statistical error:
- Format: [ value rel_error ]
- For example: [ 1.34721 0.00095 ] means k-eff = 1.34721 ± 0.00095 (relative)
- The absolute error would be 1.34721 × 0.00095 = 0.00128
Interpreting Error Magnitude
General Guidelines for Statistical Errors:
- < 0.001 (0.1%): Excellent - suitable for high-precision work
- 0.001-0.005 (0.1-0.5%): Good - acceptable for most applications
- 0.005-0.01 (0.5-1%): Fair - acceptable for scoping calculations
- > 0.01 (1%): Poor - results should be used with caution
Important: The statistical error in Monte Carlo simulations scales with 1/√N, where N is the number of particle histories. To halve the error, you need to run four times as many particles!
Visualizing Results
Visualizing Serpent results helps with interpretation and analysis. Serpent generates some visualizations automatically, and you can create additional ones using MATLAB, Python, or other tools.
Geometry Plots
If you used set gcu in your input, Serpent creates geometry plots:
*_geom1.png: XY cross-section*_geom2.png: XZ cross-section*_geom3.png: YZ cross-section
MATLAB/Octave Visualization
Since output files are already in MATLAB format, it's straightforward to create plots:
% MATLAB/Octave script to plot flux spectrum
% Run this after loading the _det0.m file
figure;
semilogx(DET_ENERGY(1:end-1), DET_FLUX(:,1), 'b-', 'LineWidth', 2);
xlabel('Energy (MeV)');
ylabel('Flux per unit lethargy');
title('Neutron Flux Spectrum');
grid on;Python Visualization
For Python users, you'll need to parse the output files first:
# Python script to plot flux spectrum
import numpy as np
import matplotlib.pyplot as plt
import re
# Function to extract values from Serpent output
def extract_serpent_array(filename, array_name):
with open(filename, 'r') as f:
text = f.read()
pattern = array_name + r's*=s*[(.*?)];'
match = re.search(pattern, text, re.DOTALL)
if match:
data_str = match.group(1)
# Convert to numpy array
data = np.array([float(x) for x in data_str.split() if x.strip()])
return data
return None
# Extract energy bins and flux
energy = extract_serpent_array('pin_cell_det0.m', 'DET_ENERGY')
flux_data = extract_serpent_array('pin_cell_det0.m', 'DET_FLUX')
flux = flux_data[::2] # Values are at even indices
error = flux_data[1::2] # Errors are at odd indices
# Plot
plt.figure(figsize=(10, 6))
plt.semilogx(energy[:-1], flux, 'b-', linewidth=2)
plt.xlabel('Energy (MeV)')
plt.ylabel('Flux per unit lethargy')
plt.title('Neutron Flux Spectrum')
plt.grid(True)
plt.show()Pro Tip: For regular Serpent users, it's worth creating a library of reusable scripts for processing and plotting common output data. This saves time and ensures consistent analysis.
Convergence Assessment
Evaluating whether your simulation has properly converged is critical for reliable results.
Shannon Entropy
Serpent tracks the Shannon entropy of the fission source distribution, which is a measure of source convergence:
% Shannon entropy data from _res.m file
SRC_ENT = [
4.59813E+00; % First inactive cycle
4.61247E+00; % Second inactive cycle
...
4.63576E+00; % Final active cycle
];A properly converged simulation should show a stable plateau in the Shannon entropy.
k-effective Convergence
You can examine k-effective values over cycles:
% k-effective by cycle
ANA_KEFF_CYCLE = [
1.32145 0; % First inactive cycle (zero error)
1.34023 0; % Second inactive cycle
...
1.34683 0.00435; % First active cycle (with error)
1.34795 0.00312; % Second active cycle
...
];Warning Signs of Poor Convergence:
- Steadily increasing or decreasing k-effective trend
- Shannon entropy that hasn't stabilized
- Large cycle-to-cycle fluctuations in k-effective
- Significant bias between analog and implicit k-effective
Practical Analysis Examples
Example 1: Criticality Assessment
For a reactor physics calculation, you might analyze:
- k-effective: Is the system critical (k ≈ 1.0)?
- Neutron spectrum: What's the thermal/fast neutron ratio?
- Fission distribution: Is power evenly distributed?
- Material temperatures: Are there any significant feedback effects?
Example 2: Parameter Study
For studying the effect of a parameter (e.g., fuel enrichment):
- Run multiple simulations with different enrichment values
- Extract k-effective from each run
- Plot k-effective vs. enrichment
- Determine the enrichment needed for criticality
% MATLAB example for parameter study
enrichment = [2.0, 3.0, 4.0, 5.0]; % Enrichment values
keff = [0.942, 1.023, 1.099, 1.168]; % k-effective results
errors = [0.0009, 0.0008, 0.0008, 0.0007]; % Statistical errors
figure;
errorbar(enrichment, keff, errors, 'o-', 'LineWidth', 2);
xlabel('Enrichment (%)');
ylabel('k-effective');
title('Effect of Fuel Enrichment on Criticality');
grid on;
% Find enrichment for k=1.0 using linear interpolation
crit_enrich = interp1(keff, enrichment, 1.0);
fprintf('Estimated critical enrichment: %.2f%%
', crit_enrich);Pro Tip: When conducting parameter studies, use a consistent random number seed (set seed) across simulations. This reduces statistical fluctuations and makes trends clearer.
Common Analysis Challenges
Handling Large Output Files
For complex models with many detectors or mesh tallies, output files can become very large. Tips for handling these:
- Use specific detectors rather than excessively fine meshes
- Consider processing output files in chunks
- For large mesh data, save visualizations rather than raw data
Dealing with Poor Statistics
If your results have high statistical errors:
- Run more particles (increase
set popfirst parameter) - Run more active cycles (increase
set popsecond parameter) - Consider variance reduction techniques for difficult problems
- Use spatial averaging if appropriate
Comparing with Experiments or Other Codes
When validating against experiments or benchmarking against other codes:
- Always include statistical uncertainties in comparisons
- Consider systematic uncertainties (nuclear data, modeling approximations)
- Look for consistent biases that might indicate modeling issues
- Document all assumptions and differences in models