Skip to content

Statepoint file loading refactor and CAPI function - #2886

Merged
paulromano merged 15 commits into
openmc-dev:developfrom
pshriwise:sp-load-refactor
Apr 24, 2024
Merged

paulromano merged 15 commits into
openmc-dev:developfrom
pshriwise:sp-load-refactor

Conversation

@pshriwise

Copy link
Copy Markdown
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
Copy Markdown
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.

@gridley gridley 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.

very minor requests!

Comment thread docs/source/usersguide/settings.rst Outdated
Comment thread openmc/lib/core.py
Comment thread src/simulation.cpp Outdated
Comment thread src/simulation.cpp Outdated
Comment thread src/state_point.cpp Outdated
Comment thread src/state_point.cpp
Comment thread tests/regression_tests/statepoint_restart/test.py Outdated

@paulromano paulromano 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.

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
church89 pushed a commit to openmsr/openmc that referenced this pull request Jul 18, 2024
Co-authored-by: Paul Romano <paul.k.romano@gmail.com>
apingegno pushed a commit to apingegno/openmc that referenced this pull request May 7, 2026
Co-authored-by: Paul Romano <paul.k.romano@gmail.com>
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