Skip to content

Conversation

@paulromano
Copy link
Contributor

Description

This PR fixes two issues in MicroXS.from_multigroup_flux. First, as described in #3121, when a MicroXS object is created using this classmethod, it cannot be written to csv, This was found to be due to the fact that it was creating a 2D array with shape (nuclides, reactions) instead of a 3D array with shape (nuclides, reactions, group) as it should have been. The other issue I observed is that this method modifies the value of multigroup_flux that is passed in, which can be undesirable for the user.

One other small fix in here is for the IndependentOperator class, which now accepts a normal list of materials (before you had to pass an instance of openmc.Materials).

Fixes #3121

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)

microxs_arr[nuc_index, mt_index] = xs
microxs_arr[nuc_index, mt_index, 0] = xs

return cls(microxs_arr, nuclides, reactions)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the changes above look good, but would this also do the trick?

Suggested change
return cls(microxs_arr, nuclides, reactions)
# ensure microxs_arr has the correct number of dimensions for a one-group cross section
microxs_arr = np.expand_dims(microxs_arr, -1)
return cls(microxs_arr, nuclides, reactions)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That would work if we keep microxs_arr as 2D, but it is a lot less obvious to someone reading the code in my opinion, so I'd prefer the current version (explicit is better than implicit).

Copy link
Contributor

@pshriwise pshriwise left a comment

Choose a reason for hiding this comment

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

Thanks @paulromano!

@pshriwise pshriwise merged commit c920779 into openmc-dev:develop Nov 11, 2024
16 checks passed
@paulromano paulromano deleted the microxs-from-multigroup-fix branch November 12, 2024 00:07
magnoxemo pushed a commit to magnoxemo/openmc that referenced this pull request Nov 22, 2024
@yardasol
Copy link
Contributor

yardasol commented Feb 24, 2025

@paulromano Just doing some poking around on this: is MicroXS.from_multigroup_flux() supposed to return a MicroXS object with one group? This is not stated explicitly in the documentation.

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.

MicroXS classmethods from_csv() and to_csv() do not work properly

3 participants