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

Adding openmc.read_source_file #2858

Merged
merged 3 commits into from
Feb 16, 2024

Conversation

pshriwise
Copy link
Contributor

Description

We currently have the ability to write a list of openmc.SourceParticle objects to an HDF5 file, but no ability to read a file into a list of those objects that I'm aware of. I found it useful to be able to do so today and added that function so I thought I'd contribute it
here.

I added testing of this function to test_source_file.py, but left the checks using h5py in place as it hammers on that file spec a bit so I think it's still useful to have them around.

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)

@gonuke
Copy link
Contributor

gonuke commented Jan 24, 2024

I thought this did exist somewhere... I'll have to dig and take a look. That's how we tested it when we introduced the feature???

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.

Thanks @pshriwise!

@paulromano paulromano enabled auto-merge (squash) February 16, 2024 16:23
@gonuke
Copy link
Contributor

gonuke commented Feb 16, 2024

How does this relate to openmc.settings.surf_source_read(). While this may be named poorly, I think it might do a similar thing that you are aiming for here?

@pshriwise
Copy link
Contributor Author

How does this relate to openmc.settings.surf_source_read(). While this may be named poorly, I think it might do a similar thing that you are aiming for here?

openmc.Settings.surf_source_read is a dictionary on the openmc.Settings class that is serialized into the XML. It contains a path to a source file to be read into the OpenMC simulation on initialization of the problem. In contrast, this provides a way to read a general source file (fission source, surface source, what have you) into the Python API. It came in handy for some work I was doing. While this is something that we can interact with via the openmc.lib module using openmc.lib.sample_external_source, it seems a reasonable mirror to the write_source_file function that's currently part of the Python API.

@paulromano paulromano merged commit 3b575a4 into openmc-dev:develop Feb 16, 2024
18 checks passed
church89 pushed a commit to openmsr/openmc that referenced this pull request Jul 18, 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.

3 participants