Skip to content

Conversation

@nuclearkevin
Copy link
Contributor

Description

This PR implements temperature feedback in the random ray solver using nearest interpolation (in a manner consistent to the MGMC solver). A new array slice is added to the flattened MGXS data structures which corresponds to a temperature index. Each source region computes and stores this temperature index based off of the cell (instance) temperature, allowing for per-cell temperature feedback. The implementation was tested by manually adding a new MGXS set for the south-west pin in the 2x2 random ray example which is 1/2 that of the other pins, which is used as the gold file for tests/regression_tests/random_ray_cell_temperature. The generation of temperature-dependent cross sections is also supported in the automagic setup, where the entire model is isothermal at each temperature value in the list provided by the user. The automagic addition + tests accounts for the vast majority of the diff in this PR.

This PR also fixes a bug in the MGMC solver where cell temperatures were not being queried correctly. This stopped all temperature datapoints from being correctly loaded when initializing the MGXS library at runtime.

Future work should include other temperature interpolation types for both the MGMC solver and the random ray solver. This is complicated in the random ray case due to the flattening of the cross sections to improve cache locality during source region updates.

I am not the most savvy Python programmer, so feedback regarding the additions to the Python API would be greatly appreciated!

Checklist

  • I have performed a self-review of my own code
  • I have run clang-format (version 15) 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)

@yardasol
Copy link
Contributor

This is an awesome feature. It'd be nice if you could add some content to the theory and user manual on it's implementation and use :) (as well as for the cell density feature that was already merged)

@nuclearkevin
Copy link
Contributor Author

nuclearkevin commented Jan 16, 2026

Good catch @yardasol! I don't know if a discussion about the cell densities / temperatures really needs to be included in the random-ray user guide, as this was a feature in CE/MG Monte Carlo which these PRs extended to the random ray solver. I think it's definitely worth adding a discussion of the temperature automagic setup though.

Edit: I just realized that distributed cell temperatures and densities don't have an entry in the geometry user manual. I'll add those in a bit.

@nuclearkevin nuclearkevin force-pushed the rr_temperature_feedback branch from 6bb3fef to 0bb4bb4 Compare January 22, 2026 22:19
@nuclearkevin nuclearkevin force-pushed the rr_temperature_feedback branch from 0bb4bb4 to e850220 Compare January 23, 2026 16:50
Copy link
Contributor

@jtramm jtramm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding in this new capability @nuclearkevin - very cool!!

I gather there are three basic things this PR does:

  1. Adds temperature dependence to the MGXS library object on the python side

  2. Updates the "automagic" MGXS generation routines to support automated generation of MGXS data.

  3. Updates the random ray solver to actually use the temperature dependent MGXS, with the nearest method.

This all sounds good and makes sense! I've annotated the code with a few minor comments.

The main thing I'm wondering about is that I had recalled that MGMC had already been able to support temperature dependence, so I was going into this assuming that the machinery for building temperature dependent libraries was already in place (i.e., (1) above). It sounds like this is not the case? What was the existing workflow for temperature dependence in MGMC before this PR?

Comment on lines 742 to 744
temperature settings used during cross section generation can be specified with the
``temperature_settings`` parameter. If no ``temperature_settings`` are provided,
the settings contained in the model will be used. This approach yields isothermal
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not clear to me what the temperature_settings parameter does - can you elaborate more on this parameters function or what the options for it are?

Comment on lines 957 to 960
def get_xsdata(self, domain, xsdata_name, nuclide='total', xs_type='macro',
subdomain=None, apply_domain_chi=False):
subdomain=None, apply_domain_chi=False, temperature=ROOM_TEMPERATURE_KELVIN):
"""Generates an openmc.XSdata object describing a multi-group cross section
dataset for writing to an openmc.MGXSLibrary object.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding was that the MGMC solver was already capable of handling temperature dependence. How was it able to load in temperature dependent MGXS libraries previously? Can we use that same strategy for what we're doing with random ray/automagic without all the edits in library.py? I'm sure there is likely a good reason for this, but want to make sure I understand.

Copy link
Contributor Author

@nuclearkevin nuclearkevin Jan 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous workflow in MGMC for generating multi-temperature MGXS libraries was to manually set each MGXS at each temperature data point (which results in a lot of duplicated code). The modifications in openmc.mgxs.Library and openmc.MGXSLibrary exist to decrease code duplication, since we generate isothermal temperature data points in individual libraries with the MGXS API and need to merge the individual libraries together.

In the case of the openmc.mgxs.Library, there was no way to set a temperature dependence previously. You had to go in, extract the cross section data one array at a time, and manually re-assign it to a XSdata object.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is possible to do this the old way (see this commit for what that looks like). If that's preferred, I can revert to this point (though I think the ability to merge libraries with different temperature points would be useful in the future).

Comment on lines +1985 to +1987
temperature_settings : dict, optional
A dictionary of temperature settings to use when generating MGXS. If not
provided, the settings stored in the model will be used.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to elaborate more on what this parameter does (what items are in the dictionary, or where else is it defined?).

Comment on lines +2157 to +2158
temperature_settings : dict
A dictionary of temperature settings to use when generating MGXS.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar comment as above regarding more explanation of this parameter

Comment on lines +2265 to +2267
temperature_settings : dict, optional
A dictionary of temperature settings to use when generating MGXS. If not
provided, the settings stored in the model will be used.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar comment as above regarding more explanation of this parameter

Comment on lines +2363 to +2364
temperature_settings : dict
A dictionary of temperature settings to use when generating MGXS.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar comment as above regarding more explanation of this parameter

Comment on lines +2551 to +2553
temperature_settings : dict, optional
A dictionary of temperature settings to use when generating MGXS. If not
provided, the settings stored in the model will be used.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar comment as above regarding more explanation of this parameter

- Also add more checks when merging MGXS temperature grids.
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