Skip to content

Conversation

@yrrepy
Copy link
Contributor

@yrrepy yrrepy commented Sep 24, 2025

Description

Enable mesh material_volumes to directly save to npz the material volumes it calculates.

When using get_homogenized_materials, the normal mesh volumes (pre-homogenization) are buried and not directly accessible, this enables getting them out.
This is useful to determine what original inventory is being activated in a large mesh R2S.

Small change enabling kwargs to material_volumes and an if statement to save this file. Builds on existing functionatlity.

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)

yrrepy and others added 2 commits September 24, 2025 15:28
enable material_volumes to directly save to npz the material volumes it calculates.

Enable up/down stream, get_homogenized_materials to also tell it to save these results.

This is useful to determine what original inventory is being activated a large mesh R2S
@paulromano paulromano changed the title mesh.py material_volumes directly saves to npz Optional separation of mesh-material-volume calc from get_homogenized_materials Sep 25, 2025
Copy link
Contributor

@paulromano paulromano left a comment

Choose a reason for hiding this comment

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

@yrrepy Good point you've made here. I wasn't crazy about the approach you had though since it makes the material_volumes function impure. I've modified the branch to take the following approach: the get_homogenized_materials function now optionally takes a material_volumes argument, which allows a user to compute it ahead of time or re-use results from a prior calculation. To save now looks like:

vols = mesh.material_volumes(...)
vols.save('myVolumes.npz')
homog_mats = mesh.get_homogenized_materials(model, material_volumes=vols)

Let me know if you're cool with this!

@yrrepy
Copy link
Contributor Author

yrrepy commented Sep 25, 2025

Good to Go for Perry!

@paulromano paulromano enabled auto-merge (squash) September 26, 2025 01:59
@paulromano paulromano merged commit 4011b7a into openmc-dev:develop Sep 26, 2025
24 of 38 checks passed
Grego01-biot pushed a commit to Grego01-biot/openmc that referenced this pull request Oct 27, 2025
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