Skip to content

Comments

Load cell temperatures from HDF5 file indicated by new XML element#3807

Closed
gonuke wants to merge 4 commits intoopenmc-dev:developfrom
gonuke:temp_from_prop
Closed

Load cell temperatures from HDF5 file indicated by new XML element#3807
gonuke wants to merge 4 commits intoopenmc-dev:developfrom
gonuke:temp_from_prop

Conversation

@gonuke
Copy link
Contributor

@gonuke gonuke commented Feb 15, 2026

Description

Currently, to read cell properties from a properties.h5 file, the data is read in python and written to XML and then read from XML by the OpenMC executable. When there are many cells, e.g. O(1e8), then it is possible to exceed the allowable size of an XML element (4GB = 2 giga characters). This is also a relatively inefficient way to transfer data that is already stored in a convenient form.

This PR attempts to introduce a new XML card that is the name of a properties file from which to read the temperature data directly from the properties.h5 at the time of problem initialization in the OpenMC executable.

Notably, since there may be circumstances when the properties.h5 file only has data that matches the geometry and not the materials, this also introduces two flags for the general import_properties method to indicate whether cell data and material data should be imported.

This is currently a draft for comment...

Fixes # (issue)

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)

@pshriwise
Copy link
Contributor

I like it as a potential solution! 🧠 💯 Maybe prompts us (in a separate effort) to revisit the existence of the Model.import_properties method so we only have one implementation of reading these.

Quick hits:

  • This feels like it might fit in better as part of the settings for the model.
  • temperature_from_h5 --> properties_file (or something more generic along those lines)
  • What do you think of generalizing this to an element that sets the properties file path and the bool's for loading temperatures and/or materials from the file?

@GuySten
Copy link
Contributor

GuySten commented Feb 15, 2026

Why not just use the c-api from python to load the properties?
I did not understand why you need to export and import from XML.

@gonuke
Copy link
Contributor Author

gonuke commented Feb 15, 2026

Why not just use the c-api from python to load the properties? I did not understand why you need to export and import from XML.

The round-trip through XML is a quirk of the way that depletion problems are setup. The depletion integrator writes XML and then calls OpenMC init through the c-api that then loads the XML.

There are certainly other solutions to this particular problem, but in general it seemed like a good idea for XML to be able to drive the process of reading data from the properties.h5 file, in general.

The proposed solution may not be the best approach, but it was a way to demonstrate something heading in the right (?) direction.

@gonuke
Copy link
Contributor Author

gonuke commented Feb 15, 2026

I like it as a potential solution! 🧠 💯 Maybe prompts us (in a separate effort) to revisit the existence of the Model.import_properties method so we only have one implementation of reading these.

Quick hits:

  • This feels like it might fit in better as part of the settings for the model.
  • temperature_from_h5 --> properties_file (or something more generic along those lines)
  • What do you think of generalizing this to an element that sets the properties file path and the bool's for loading temperatures and/or materials from the file?

I'm happy to discuss and modify this in many ways. I threw this up as a demonstration that there may be a solution that is not far away and it's probably a valuable feature outside of the immediate need.

@gonuke
Copy link
Contributor Author

gonuke commented Feb 15, 2026

Quick hits:

  • This feels like it might fit in better as part of the settings for the model.

Makes sense, should be a straightforward shift.

  • temperature_from_h5 --> properties_file (or something more generic along those lines)

Yep... my variable name came from the immediate need, but better to generalize.

  • What do you think of generalizing this to an element that sets the properties file path and the bool's for loading temperatures and/or materials from the file?

I think there are interesting questions about how this interacts with other ways to set this info, esp. does this override cell-by-cell temperature entries? Or vice versa?

@gonuke gonuke changed the title Load cell temperatures from properties via XML Load cell temperatures from HDF5 file indicated by new XML element Feb 16, 2026
@gonuke
Copy link
Contributor Author

gonuke commented Feb 16, 2026

  • What do you think of generalizing this to an element that sets the properties file path and the bool's for loading temperatures and/or materials from the file?

If the properties file path is in the settings... should the bool's be in cells and materials since they are relevant to those, respectively?

@pshriwise
Copy link
Contributor

If the properties file path is in the settings... should the bool's be in cells and materials since they are relevant to those, respectively?

I'm not sure I understand. I was thinking of something like this.

<settings>
  <properties>
    <filepath>properties.h5</filepath>
    <temperatures>true</temperatures>
    <materials>false</materials>
  </properties>
</settings>

To support the updates to the functionality in import_properties.

Are you maybe suggesting we'd check for an optional bool value on each cell/material element in the XML?

@gonuke
Copy link
Contributor Author

gonuke commented Feb 16, 2026

I meant to say geometry rather than cell - I was thinking these would be an attribute of the geometry object and an attribute of the materials object.

... but this makes sense, too.

@gonuke
Copy link
Contributor Author

gonuke commented Feb 19, 2026

Closing in favor of cleaner #3808

@gonuke gonuke closed this Feb 19, 2026
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