Skip to content

added openmc.Material.mean_free_path function - #3469

Merged
jtramm merged 2 commits into
openmc-dev:developfrom
shimwell:adding-mean-free-path
Jun 26, 2025
Merged

jtramm merged 2 commits into
openmc-dev:developfrom
shimwell:adding-mean-free-path

Conversation

@shimwell

Copy link
Copy Markdown
Member

This PR proposes that we add a mean_free_path method to the openmc.Material() class.

@jtramm this might be useful when setting the mesh sizes to a couple of mean free paths in your nice FW-CADIS workflow. Where we don't want the weight window mesh voxel sizes to be more than a few mean free paths of the material.

I would be keen to one day extend this to allow photons but I don't think the underlying _calculate_cexs_elem_mat functions support particles other than neutrons.

Example use

import openmc

mat_concrete = openmc.Material(name="concrete")
mat_concrete.add_element("H", 0.168759)
mat_concrete.add_element("C", 0.001416)
mat_concrete.add_element("O", 0.562524)
mat_concrete.add_element("Na", 0.011838)
mat_concrete.add_element("Mg", 0.0014)
mat_concrete.add_element("Al", 0.021354)
mat_concrete.add_element("Si", 0.204115)
mat_concrete.add_element("K", 0.005656)
mat_concrete.add_element("Ca", 0.018674)
mat_concrete.add_element("Fe", 0.00426)
mat_concrete.set_density("g/cm3", 2.3)

print(mat_concrete.mean_free_path(energy=14e6))
>>>8.220341386874415

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)

@jtramm jtramm left a comment

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.

LGTM! Thanks @shimwell!

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