Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes in MicroXS.from_multigroup_flux #3192

Merged
merged 3 commits into from
Nov 11, 2024

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)

@@ -327,7 +329,7 @@ def from_multigroup_flux(
xs = lib_nuc.collapse_rate(
mt, temperature, energies, multigroup_flux
)
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
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
2 participants