Skip to content

Warn when a material spans multiple cells in material_wise MGXS#3983

Closed
jon-proximafusion wants to merge 1 commit into
openmc-dev:developfrom
shimwell:warn-convert-mgxs-material-wise-averaging
Closed

Warn when a material spans multiple cells in material_wise MGXS#3983
jon-proximafusion wants to merge 1 commit into
openmc-dev:developfrom
shimwell:warn-convert-mgxs-material-wise-averaging

Conversation

@jon-proximafusion

Copy link
Copy Markdown
Contributor

Summary

The material_wise convert_to_multigroup method produces one flux-weighted cross section per material. A material that fills cells with different neutron spectra (e.g. structural steel near the source and deep inside a shield) is collapsed to a single spectrum-averaged cross section, which can be inaccurate.

This adds a warning when a material fills more than one cell, recommending Model.differentiate_mats() to give each location its own material (and hence its own locally-weighted cross section). It is a heads-up only — one cross section per material is the intended multigroup behaviour, so nothing in the output changes.

Companion to the duplicate-name fix in #108 (which is a genuine bug); this PR flags expected-but-easily-overlooked behaviour. Note the warning fires whenever a material fills multiple cells, which is common.

Tests

Added a unit test asserting the warning fires when one material fills multiple cells.

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)

The "material_wise" convert_to_multigroup method produces one flux-weighted
cross section per material. A material that fills cells with different
neutron spectra (for example structural steel near the source and deep
inside a shield) is therefore collapsed to a single spectrum-averaged cross
section, which can be inaccurate. Warn in that case, recommending
Model.differentiate_mats() to give each location its own material and hence
its own cross section.
@shimwell shimwell requested a review from jtramm June 25, 2026 15:44
@jtramm

jtramm commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Thanks for putting this in for consideration @jon-proximafusion!

I'd say that as the MGXS data will always be shared across multiple locations, the multigroup inaccuracy is pretty inherent in the method. Even if we did make unique MGXS per each cell-material combination there are still lattices or large spatial regions that will be subdivided by the source region mesh - in which case the same problem is present. As such, I don't think it's worth calling out this case of applying the same material to two cells, given that that accuracy differences (especially for weight window generation usage) are likely quite small compared to the difference between multigroup vs. continuous energy.

Down the line though - it would definitely be nice to add a "cell-material-wise" option for MGXS generation that does produce MGXS with a little bit more spatial granularity (so as to be uniuque for each cell-material combination rather than for each material). This would still be an approximation compared to continuous energy, but could be useful if you want to squeeze maximum accuracy out of the random ray solver.

@shimwell

Copy link
Copy Markdown
Member

Thanks for the feedback, ok I shall close this unnecessary PR and look to add a "cell-material-wise" method in the future to help users who want the even better multigroup cross sections than "material-wise" provides

@shimwell shimwell closed this Jun 25, 2026
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.

3 participants