-
Notifications
You must be signed in to change notification settings - Fork 498
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
Write surface source files per batch #3124
Conversation
0f6b18b
to
201ca7f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor comments on verbosity and file naming formats, and I finally figured out what I think we should do:
The current implementation is very nice and accomplishes the goal of this feature (to allow more surface crossings to be generated by the simulation than allowed by the max_particles
setting on the surface source). In the end though, I think this feature should behave in a similar manner to the openmc.Settings.statepoint['batches']
capability.
So for this features we would incorporate a openmc.Settings.surf_source_batches
option that would allow users to specify a list of batches after which the surface source bank will be written to file and the surface source bank in memory will be cleared. With this method the user can specify that they'd like to write the current set of source particles after as many batches as they like. If they'd like all of the batches it's as simple as specifying:
settings.surface_source_batches = [i for i in range(settings.batches)]
Sorry it took me so long to come to this conclusion. What do you think @zoeprieto?
Thanks for all the suggestions @pshriwise . I think using the same format of creating files as in statepoint is really very good, and simplifies the need to create more variables. Also, it adds the ability to not be so strict on whether it's in all batches or just the last batch. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks really nice @zoeprieto. 🥇 Mainly a couple of high-level questions here to address.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple more thoughts, but I think this is really close.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost there! If you don't mind, let's add one test with the batches
property set to ensure the correct number of files and filenames are generated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Teeny-tiny documentation tweak and then I'm happy! 😄
Co-authored-by: Patrick Shriwise <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @zoeprieto!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry to stall the merging -- wanted to take a look at this but haven't had a chance to yet. I'll try to review in the next few days!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To summarize some discussion that @pshriwise @zoeprieto and I had offline -- rather than writing a surface source file at specific batches, I am recommending that we write the surface source file at the point where it fills up and then give the user an option as to how many times they are allowing a full source file to be written. If the surface source bank is not full by the end of the simulation, it will write out the surface source as is. This removes some of the guess work for the user in figuring out how often they should be writing the surface source (i.e., which batches).
Head branch was pushed to by a user without write access
Thank you @paulromano for your comment. You are right, it is more reasonable to create another file only if the first one is full. I solved it by adding a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks again for this enhancement @zoeprieto. I made the following changes on this branch:
- Renamed global variables to all start with
ssw_
to indicate they are related to surface source writing. - Introduced a new
write_source_point
function to consistently handle the logic for writing either a .h5 and .mcpl file - Changed the name of the user input "max_surf_files" to "max_source_files"
- Updated the test case
Thank you @paulromano for your feedback and changes! |
Description
This is a preliminary solution to the first part of the issue #3123 for writing surface source files in the last N active batches chosen by the user.
By default it still saves a surface source file only in the last batch. The difference is that the files will be named: surface_source_batch_N.h5 with N being the number of the last batch.
It has also added the ability to print the number of particles that were saved per batch as the simulation runs.
Fixes #3123
Checklist