Skip to content

Support multiple meshes in R2S calculations#3860

Open
paulromano wants to merge 4 commits intoopenmc-dev:developfrom
paulromano:r2s-multi-mesh
Open

Support multiple meshes in R2S calculations#3860
paulromano wants to merge 4 commits intoopenmc-dev:developfrom
paulromano:r2s-multi-mesh

Conversation

@paulromano
Copy link
Copy Markdown
Contributor

Description

This PR extends R2SManager to accept a list of meshes (as the domains argument), enabling mesh-based R2S calculations to use multiple non-overlapping meshes in a single workflow. Each element-material combination across all meshes is treated as an independent activation region. This can come in handy in a variety of situations:

  • Problems requiring varying spatial resolution in different regions
  • Activating two or more disconnected regions where a cell-based workflow is not sufficient
  • Activating a component that covers a large physical extent but is mostly empty (e.g., the vacuum vessel of a tokamak)

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)

Copy link
Copy Markdown
Contributor

@eepeterson eepeterson 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 the helpful improvement @paulromano. A number of small comments for your consideration, but nothing blocking.

Comment thread openmc/deplete/microxs.py
model : openmc.Model
OpenMC model object. Must contain geometry, materials, and settings.
domains : list of openmc.Material or openmc.Cell or openmc.Universe, or openmc.MeshBase, or openmc.Filter
domains : list of openmc.Material or openmc.Cell or openmc.Universe, or openmc.MeshBase, or openmc.Filter, or list of openmc.Filter
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This list feels like it's growing a bit long and having the general openmc.Filter and list of openmc.Filter in the documentation may be slightly misleading since not all Filter objects should be viable here.

Makes me wonder if it's worth creating an openmc.Domain enum-like type that does the type checking and validation for us and leveraging that here (and elsewhere potentially). The arguments to domains are defining spatial regions regardless of whether it is implicitly defined through something else like Material assignments. It might be nice to have a type or class that checks that what's passed is a valid way of defining some spatial domain.

It may be obvious what should and should not be allowed if someone is using this function, but it might help to be more explicit.

Comment thread openmc/deplete/microxs.py
domain_filters = [openmc.CellFilter(domains)]
elif isinstance(domains[0], openmc.Universe):
domain_filter = openmc.UniverseFilter(domains)
domain_filters = [openmc.UniverseFilter(domains)]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If we do move forward with the above suggested abstraction this code could migrate.

Comment thread openmc/deplete/microxs.py
for flux_arr, rr_tally in zip(all_flux_arrays, rr_tallies):
flux = flux_arr
reaction_rates = rr_tally.get_reshaped_data()
reaction_rates = np.moveaxis(reaction_rates, 1, -1)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

could be worth adding same comment here as above in the flux loop to make clear what is being aligned.

Comment thread openmc/deplete/r2s.py
----------
domains : openmc.MeshBase or Sequence[openmc.Cell]
The mesh or a sequence of cells that represent the spatial units over
domains : list of openmc.MeshBase or Sequence[openmc.Cell]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actually seeing here that we use domains for a few different things, that may negate my previous comment, but I'll leave it for posterity.

Comment thread openmc/deplete/r2s.py
if mmv_file.exists():
self.results['mesh_material_volumes'] = \
openmc.MeshMaterialVolumes.from_npz(mmv_file)
mmv_files = sorted(neutron_dir.glob('mesh_material_volumes*.npz'),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

might be worth including digit specifiers in the glob string to ensure what you're getting is indeed what you intend to sort. Same goes for below in the photon glob search.

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