Description
I hit an IndexError when running OpenMC R2SManager in mesh-based activation mode with a filtered photon model (many materials effectively removed from photon-side source construction). The same workflow in a similar case may pass, so this appears data-dependent. Specifically when I ran with a set of components made of steel it errored out, and when those same materials were just swapped to aluminum it completed without error.
Original error traceback
Traceback (most recent call last):
File “…/run_mcp.py”, line 33, in
mcp.run(geom_debug=args.geom_debug, mpi_args=args.mpi_args)
File “…/mcproblem.py”, line 850, in run
source_rates,
File “…/site-packages/openmc/deplete/r2s.py”, line 231, in run
self.step3_photon_transport(
File “…/site-packages/openmc/deplete/r2s.py”, line 492, in step3_photon_transport
self.get_decay_photon_source_mesh(time_index)
File “…/site-packages/openmc/deplete/r2s.py”, line 619, in get_decay_photon_source_mesh
source_lists[j][index_elem] = openmc.IndependentSource(
IndexError: list index out of range
Where this occurs (OpenMC source)
openmc/deplete/r2s.py inside R2SManager.get_decay_photon_source_mesh().
AI diagnosis:
Current logic:
if j >= len(source_lists):
source_lists.append([null_source] * n_elements)
Because j comes from enumerate(mat_vols.by_element(index_elem)) and some entries are skipped (e.g., not present in photon model), j can be sparse. In that case, appending only once may still leave j out of range.
I appear to have fixed the error by simply changing the current line above to:
while j >= len(source_lists):
source_lists.append([null_source] * n_elements)
I am wondering if this has been seen before or if this explanation makes sense; and if it is an actual bug. As stated above this arises when I modify the material of cells I intend to remove from the photon transport stage (to simulate their removal from the problem).
Thanks in advance for any insights.
Marc