-
Notifications
You must be signed in to change notification settings - Fork 510
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
Exporting and importing physical properties #1852
Conversation
Looks very useful - I will undoubtedly be using this soon! Thanks for explaining why this shouldn't be done in a statepoint file, which was my only question. In the transient code I'm proposing (the adiabatic PR), you'll notice we use a log_file.h5. These property.h5 files remind me of that, but better catered toward the CAPI. In the transient code, full OpenMC runs are completed before updating properties, so the state point files and the log_file are sufficient. However, as I move forward with my PhD and include multiphysics coupling into that scheme, the CAPI will quickly get involved which might move my strategy more toward these property files. |
Thanks for the tag! I think this will provide a useful verification check (I assume the write of the properties can be turned on and off?), maybe even allow for an integration test in AURORA that the representations of temperature and density are consistent between MOOSE/OpenMC. There's less of a use case for me at run-time though, as I pass this information in memory; I would probably stick with this to avoid too many IO operations. |
This comes at the perfect time, @pshriwise and I were just discussing ways to verify the temperature setting in OpenMC. Thanks @paulromano! |
Glad to hear that this feature will likely get some use! @helen-brooks Right now, writing of properties doesn't really have an on/off switch in the same way that, say, statepoint files do. Instead, it is up to an external application to make a call to |
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 is really nice @paulromano. It's going to be very handy to dump and load this information so seamlessly.
@pshriwise I believe all your comments have been addressed. Let me know if you have further requests |
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.
Looking good! Thanks for adding this handy feature @paulromano
This PR adds two new functions to our C API,
openmc_properties_export
andopenmc_properties_import
that allow physical properties (cell temperatures, material densities) to be exported to a HDF5 file, by default called "properties.h5". This is primarily intended for multiphysics coupling where we want to be able to save, load, and visualize temperature and density distributions. Right now, we don't have a good way to do this. Along with the two C functions, this PR also introduces:openmc.lib.export_properties
andopenmc.lib.import_properties
Python bindings to the underlying C functionsModel.import_properties
method that takes an existingModel
object and modifies cell temperatures and material densities from a properties.h5 file. This modifiedModel
can then be re-exported using the normalModel.export_to_xml
method.Model.from_xml
classmethod that does what you would expect: create aModel
object based on existing XML files. Not sure why we didn't add this before...Other small changes:
openmc.lib.Cell
now has anum_instances
property, relying on a correspondingopenmc_cell_get_num_instances
C API functionopenmc_id_map
to return both cell IDs and instancesDocumentation and unit tests have been updated accordingly.
Companion PRs
After this, I will submit two companion PRs taking advantage of the new functionality
As a sneak peak of what's possible with these capabilities, here is a converged axial temperature distribution in an assembly simulated with ENRICO (using this PR) visualized using openmc-plotter:
Design alternatives
In discussion with @pshriwise, I did consider a few design alternatives. The first alternative was to include this information in our normal statepoint files. This would have the benefit of not introducing a new file, but statepoints are really about tally results, not so much physical properties that may have changed. Plus, in some cases, we may just want to load a model via
openmc.lib
change temperatures/densities, and export the properties without ever having run a transport simulation.The other alternative was to include this information in our summary file. However, in the common case where we are writing this information at each iteration of a multiphysics calculation, this may result in unnecessarily large files. By separating out the temperature/density data in a single file, we ensure that only the minimum amount of data is written each time.
I'd appreciate any thoughts/feedback from those of you working on multiphysics stuff (@smharper @aprilnovak @mkreher13 @helen-brooks)