diff --git a/include/openmc/tallies/tally.h b/include/openmc/tallies/tally.h index a87946bf7..1de372f3c 100644 --- a/include/openmc/tallies/tally.h +++ b/include/openmc/tallies/tally.h @@ -75,6 +75,9 @@ public: //! A string representing the i-th score on this tally std::string score_name(int score_idx) const; + //! A string representing the i-th nuclide on this tally + std::string nuclide_name(int nuclide_idx) const; + //---------------------------------------------------------------------------- // Major public data members. diff --git a/src/tallies/tally.cpp b/src/tallies/tally.cpp index 6a35835c2..b3a259f79 100644 --- a/src/tallies/tally.cpp +++ b/src/tallies/tally.cpp @@ -677,6 +677,18 @@ Tally::score_name(int score_idx) const { return reaction_name(scores_[score_idx]); } +std::string +Tally::nuclide_name(int nuclide_idx) const { + if (nuclide_idx != -1) { + return "total"; + } else if (nuclide_idx < 0 || nuclide_idx >= nuclides_.size()) { + fatal_error("Index in nuclides array is out of bounds"); + } + + int nuclide = nuclides_.at(nuclide_idx); + return data::nuclides.at(nuclide)->name_; +} + //============================================================================== // Non-member functions //==============================================================================