Skip to content

Report unresolvable nuclide names instead of terminating - #4130

Open
GuySten wants to merge 1 commit into
openmc-dev:developfrom
GuySten:claude/report-data-errors
Open

GuySten wants to merge 1 commit into
openmc-dev:developfrom
GuySten:claude/report-data-errors

Conversation

@GuySten

@GuySten GuySten commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Two places call openmc_load_nuclide and turn a failure into a thrown std::runtime_error. Nothing catches either of them -- there is no try/catch on the initialization path at all -- so both end the process with "terminate called after throwing an instance of" and no OpenMC error message.

Tally::set_nuclides is the reachable one. A tally bin names a nuclide, so an element symbol does not resolve even when the element is in the material: nuclides=['C'] aborts on a material made of C12, as does a plain typo. Report it with the offending name. read_ce_cross_sections is the same pattern; Material::init_nuclide_index checks the library first so nothing reaches it today, but the two should fail the same way.

Checking the names in Python is tempting, but cannot raise: a multi-group bin may name a macroscopic dataset, whose name is arbitrary and indistinguishable from a typo without knowing the model's energy mode, and Tally.nuclides also accepts the CrossNuclide and AggregateNuclide objects that tally arithmetic produces. A warning that fires on valid input is worth less than an error that names the problem, which is what the above now gives.

Also drop the user guide's claim that 'all' can be listed as a nuclide. Only "total" is special-cased; "all" is recognized for trigger scores and nowhere else, so following that advice lands in the error above. Point at Material.get_nuclides() instead, and say that an element symbol is not a valid bin even for photon tallies, whose data is tabulated per element.

Checklist

  • I have performed a self-review of my own code
  • I have run clang-format (version 18) on any C++ source files (if applicable)
  • I have followed the style guidelines for Python source files (if applicable)
  • I have made corresponding changes to the documentation (if applicable)
  • I have added tests that prove my fix is effective or that my feature works (if applicable)

… tally docs

Two places call openmc_load_nuclide and turn a failure into a thrown
std::runtime_error. Nothing catches either of them -- there is no try/catch on
the initialization path at all -- so both end the process with "terminate called
after throwing an instance of" and no OpenMC error message.

Tally::set_nuclides is the reachable one. A tally bin names a nuclide, so an
element symbol does not resolve even when the element is in the material:
nuclides=['C'] aborts on a material made of C12, as does a plain typo. Report it
with the offending name. read_ce_cross_sections is the same pattern;
Material::init_nuclide_index checks the library first so nothing reaches it
today, but the two should fail the same way.

Checking the names in Python is tempting, but cannot raise: a multi-group bin
may name a macroscopic dataset, whose name is arbitrary and indistinguishable
from a typo without knowing the model's energy mode, and Tally.nuclides also
accepts the CrossNuclide and AggregateNuclide objects that tally arithmetic
produces. A warning that fires on valid input is worth less than an error that
names the problem, which is what the above now gives.

Also drop the user guide's claim that 'all' can be listed as a nuclide. Only
"total" is special-cased; "all" is recognized for trigger scores and nowhere
else, so following that advice lands in the error above. Point at
Material.get_nuclides() instead, and say that an element symbol is not a valid
bin even for photon tallies, whose data is tabulated per element.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JxR1sQWWnALXj39rX12v7c
@GuySten
GuySten marked this pull request as ready for review September 14, 2026 16:02
@GuySten
GuySten requested a review from paulromano September 14, 2026 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants