Skip to content

Adding multigroup photon transport capability in MC mode - #4141

Draft
Grego01-biot wants to merge 10 commits into
openmc-dev:developfrom
Grego01-biot:photon-mg-mc
Draft

Grego01-biot wants to merge 10 commits into
openmc-dev:developfrom
Grego01-biot:photon-mg-mc

Conversation

@Grego01-biot

@Grego01-biot Grego01-biot commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Description

This PR enables multigroup photon transport in the Monte Carlo solver. It builds on #4073, which generates photon MGXS libraries on the Python side (PhotonTransferMatrixXS, Library(particle_type='photon')) and writes a particle_type attribute to the library file. Until now the C++ side never read that attribute, and multigroup mode rejected photon transport outright.

This is the first of two PRs toward a multigroup photon random ray workflow; a follow-up will add random ray support on top of this one.

Changes

  • settings.cpp: lift the check that rejected photon transport in multigroup mode.
  • material.cpp: guard the continuous-energy photon data setup with settings::run_CE, so multigroup runs no longer look up photon element data in cross_sections.xml.
  • mgxs_interface.{h,cpp}: read the library's particle_type in read_header(), store it, and use it when setting up the multigroup globals in put_mgxs_header_data_to_globals(). For photon libraries the default inverse velocity is now 1/c in every group. It used to be computed from the neutron mass, so photons moved at neutron speeds, corrupting particle time, time filters and cutoffs, and the inverse-velocity score.
  • source.cpp: in multigroup mode, before converting source energies to groups, check that the source particle type matches the library and that the energy lies within the library's group bounds, and error out otherwise. Without the type check, a neutron source with a photon library runs silently on photon cross sections.
  • tally.cpp: reject pulse-height tallies in multigroup mode, since they rely on continuous-energy photon physics.

Testing

The new tests/regression_tests/mg_photon test runs a 3-group photon library (P1 scattering, row-constant multiplicity matrix) in a reflective 10 cm cube, i.e. an infinite medium with an exact solution. This test asserts that the group fluxes match the exact solution within 5σ and that photons travel at c (via the inverse-velocity score). Four parametrized cases cover the new input checks: source energy above and below the library bounds, particle-type mismatch, and a pulse-height tally. It passes locally with history-based and event-based transport.

Out of scope

Coupled neutron-photon multigroup transport: a library describes a single particle type, and the source has to match it. Documentation will come with the random ray PR.

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)

This branch has not been deployed

No deployments
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