OpenMC executes Monte Carlo simulations by tracking one particle at a time per program instance. The execution lifecycle is divided into three main phases: Initialization, Transport Simulation, and Finalization.
1. Initialization
Before tracking begins, OpenMC performs the following:
- Reads input files to build data structures for geometry, materials, and tallies.
- Initializes the pseudorandom number generator.
- Loads continuous-energy or multi-group cross section data.
- Initializes special energy grid treatments (e.g., union energy grids or lethargy bins) if specified.
- For multi-group problems, combines nuclide cross sections into material-specific data.
- Samples source sites (coordinates, direction, and energy) for fixed source or eigenvalue problems.
2. Transport Simulation (Particle Life Cycle)
For each particle, the following loop occurs:
- Initialization: Particle properties are set from a sampled source site.
- Location: The current cell is determined based on coordinates.
- Cross Sections: Energy-dependent cross sections for the current material are determined.
- Boundary Check: The distance to the nearest cell boundary is calculated.
- Collision Sampling: The distance to the next collision is sampled using the total material cross section $\Sigma_t$.
- Movement:
- If the boundary is closer than the collision, the particle moves to the boundary and the process repeats from step 2.
- If the collision is closer, the particle undergoes a collision.
- Nuclide Selection: In continuous-energy simulations, a specific nuclide is sampled based on total cross sections. (In multi-group, this is pre-combined).
- Reaction Sampling: A specific reaction is sampled based on microscopic (or material-specific multi-group) cross sections.
- Reaction Outcome:
- Scattering (Elastic/Inelastic): Outgoing energy and angle are sampled. In continuous-energy, $(n,xn)$ reactions create secondary particles added to a bank. In multi-group, particle weight is increased instead. The particle continues from step 3.
- Absorption/Fission: The particle dies. If fission occurs, fission sites are stored in a fission bank.
3. Finalization
After all particles are processed:
- Tallies are processed to calculate sample means and variances.
- Results and (optionally) source files are written to disk.
- Memory is freed.