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

Statepoint file loading refactor and CAPI function #2886

Merged
merged 15 commits into from
Apr 24, 2024

Conversation

pshriwise
Copy link
Contributor

Description

This PR contains a slight refactor of the statepoint loading so it can more cleanly be exposed as part of the CAPI.

It is also a continuation of #2390 in that the scenario where a statepoint is loaded with n_batches equal to settings::n_max_batches is softened to a warning. This allows previously executed statepoint files can be loaded into an initialized openmc.lib instance to recover tally information. An additional check for the current batch vs the max number of batches is added to openmc_next_batch to ensure that no particles will be transported in the case that the warning condition is triggered.

I think this results in reasonable behavior in the case that a user feeds a statepoint file from a complete OpenMC run back into the openmc executable without modification of the batches in the settings file: OpenMC will initialize, load the statepoint file, produce the warning message as part of the statepoint file load, run zero batches, and finalize. Importantly, it will not overwrite the existing statepoint file in this case either. It's somewhat unfortunate that a user will have to wait for problem initialization to get this result, but this was true before these changes as well.

We're using this as part of a project with Cardinal to load reaction rate tallies into a separately initialized OpenMC problem to leverage the depletion module for the Bateman eq. solve before sending updated material compositions back into Cardinal.

I went ahead and added a section on simulation restarts as I didn't see any information on it outside of the restart flag passed to the executable.

The restart regression test needed some updating after this to use a fixture that allowed for a check that the correct warning is present.

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 modified tests that prove my fix is effective or that my feature works (if applicable)

@pshriwise
Copy link
Contributor Author

Update: to comply with expected behavior of openmc.lib's ability to iterate on batches beyond what is specified in the settings.xml, I moved the batches check into the openmc_run function so the early exit only applies when calling the openmc executable or openmc.lib.run.

Copy link
Contributor

@gridley gridley left a comment

Choose a reason for hiding this comment

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

very minor requests!

docs/source/usersguide/settings.rst Outdated Show resolved Hide resolved
openmc/lib/core.py Show resolved Hide resolved
src/simulation.cpp Outdated Show resolved Hide resolved
src/simulation.cpp Outdated Show resolved Hide resolved
src/state_point.cpp Outdated Show resolved Hide resolved
src/state_point.cpp Show resolved Hide resolved
tests/regression_tests/statepoint_restart/test.py Outdated Show resolved Hide resolved
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 for this improvement @pshriwise!

@gridley Can you let us know if you're OK with merging?

@paulromano paulromano merged commit f543c00 into openmc-dev:develop Apr 24, 2024
18 checks passed
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.

None yet

3 participants