openmc-dev / openmc

OpenMC Monte Carlo Code
https://docs.openmc.org
Other
699 stars 444 forks source link

Support track file writing for particle restart runs. #2957

Closed pshriwise closed 1 week ago

pshriwise commented 2 weeks ago

Description

This PR should help streamline lost particle debugging by enabling a track file write with the following workflow:

# run produces lost particle files
openmc
# restart with a particle file and produce a `tracks.h5` file with the resulting track for debugging
openmc -r <particle_file> -t

or in Python

# produces a `RuntimeError`
model.run()
# apply a particle file and produce the track
model.run(restart_file=particle_filepath, tracks=True)

This just involved opening and closing a track file for the run_particle_restart function. Those calls are typically made in openmc_simulation_init but that function isn't called for a particle restart run. I've added a test to ensure the above workflow is possible going forward.

Fixes #2956

Checklist