Skip to content

Refactoring moltres_xs to be able to use mgxs.Library() functionality. #340

Draft
Jeremyb8707bigbrain wants to merge 11 commits intoarfc:develfrom
Jeremyb8707bigbrain:devel
Draft

Refactoring moltres_xs to be able to use mgxs.Library() functionality. #340
Jeremyb8707bigbrain wants to merge 11 commits intoarfc:develfrom
Jeremyb8707bigbrain:devel

Conversation

@Jeremyb8707bigbrain
Copy link

@Jeremyb8707bigbrain Jeremyb8707bigbrain commented Feb 2, 2026

Summary of changes

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Required for Merging

  • I have read the CONTRIBUTING document.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
    • CI tests pass
    • Local tests pass (including Serpent2 integration tests)

Associated Issues and PRs

Associated Developers

Checklist for Reviewers

Reviewers should use this link to get to the
Review Checklist before they begin their review.

@Jeremyb8707bigbrain
Copy link
Author

Jeremyb8707bigbrain commented Feb 2, 2026

Hey everyone,

I ran local tests myself for the godiva.json files, mostly everything lines up like it should.
The main issue is my cross sections that I had myself only are 6 delayed groups, and I really dont know how to get the 8 that godiva.json used.

Another discrepancy that may be noted is the version, I am on OpenMC version 0.15.2 so the numbers are within std. dev, but for the smaller values it had a bit more range.

99% of everything works as it should, and I plan to add support for multiple statepoints and summaries soon. I added the openmc_mgxslib class so even if it is not 100% it can be added (maybe).

Also I forgot to say, this one does not require an input file that specifies energy groups delayed etc, that all comes with a properly configured mgxs.Library(). Also I am working on ordering the files consistently in the.json.

…ned up spacing, extra lines, and more type checking and error catching.
…. Tweaked division by zero handling to be more readable and less complex.
… added back the consistent nu-scatter matrix requirement because I was testing stuff and forgot to add that back.
…sted the consistent nu-scatter matrix processing to allow all legendre_order types.
@smpark7
Copy link
Collaborator

smpark7 commented Feb 6, 2026

Hey @Jeremyb8707bigbrain thanks again for working on this PR. I have been very busy, but I have some general feedback:

  • Your code should replace the existing class openmc_xs, not create a new class.
  • The new version should maintain compatibility with the existing workflow for group constant generation for backward compatibility and user-friendliness. Current workflow:
    • Use openmc_xs.generate_openmc_tallies_xml to configure tallies (currently through individual mgxs tallies, to be migrated to mgxs.Library())
    • Run OpenMC, potentially at multiple reactor temperatures
    • Run $MOLTRES/python/moltres_xs.py input.inp to parse and generate json group constant file.
  • It should continue to have the openmc_xs.generate_openmc_tallies_xml function that helps beginner users automatically configure mgxs.Library() such that the generated group constants are compatible with the neutronics solvers in Moltres. Advanced users can choose to ignore this function and configure mgxs.Library() in their own way if they wish.
  • It should be compatible with the existing approach of using .inp files for users to specify which material group constants and temperature values they want.
  • You'll find how totalxs and nuscattermatrix group constants are extracted in moltres_xs.py for the new SN solver in Moltres.
  • You're missing remxs values that are needed by the neutron diffusion solver.
  • If possible, the mgxs.Library() configuration settings should be compatible with OpenMC mgxs generation for its own multigroup solver (https://nbviewer.org/github/openmc-dev/openmc-notebooks/blob/main/mg-mode-part-ii.ipynb). This would avoid having duplicate mgxs tallies that would otherwise significantly increase OpenMC simulation time.

@Jeremyb8707bigbrain
Copy link
Author

Perfect I can do all of that!
I will put another comment when I would like it to be reviewed, for now I will start working on that feedback!

Jeremyb8707bigbrain and others added 2 commits February 7, 2026 10:27
Changed main openmc (0.15.3) calls to run new function rather than the old one, added a way to manually build old case logic via inputs and inspecting python file for the mgxs.Library
Added better logging for errors at mgxslib.load_from_statepoints....
Adapted it so that it will correctly use burn_idexes to comply with read_input() formatting.
Set generate_openmc_talies_xml as a staticmethod explicitly
@Jeremyb8707bigbrain Jeremyb8707bigbrain marked this pull request as draft February 8, 2026 23:00
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