openmc icon indicating copy to clipboard operation
openmc copied to clipboard

Feature request: adding original materials to depletion_results.h5

Open shimwell opened this issue 2 years ago • 4 comments

Description

When running depletion simulations I occasionally need access to the original material definitions prior to their depletion.

For example when calling the Results.export_to_materials() the path to the original materials.xml file is needed.

This is perhaps out of sync with the result of openmc where we use of model.xml now instead separate xml files. However I wonder if we could include the original materials definition in the depletion_results.h5 file then avoid needing to retain access to this materials.xml file as the data could be found withing the h5 file and results object automatically.

Alternatives

we continue to export the materials file prior to running a depletion and then we continue to pass in the materials.xml file when needed

Compatibility

I think this will not break the existing API and we could still allow users to pass in the materials.xml if they want. It would just find the materials when needed.

shimwell avatar Oct 24 '23 12:10 shimwell

Wouldn't the following :

import openmc
import openmc.deplete
res = openmc.deplete.Results.from_hdf5("depletion_results.h5")
initial = res[0]
materials = {}
for mat in initial.index_mat.keys():
    materials[mat] = initial.get_material(mat)

do basically what you need? Although this makes all isotopes in the depletion_results.h5 appear in the material, even the ones with a concentration of zero which will be numerous if you need initial composition.

I guess the only things missing from the resulting materials would be the original temperature and s(α, β) info. These could be added pretty easily to the attributes of the material leaves in the depletion_results.h5 file. It also only fetches depletable materials, whereas the materials.xml also gives you static ones.

nplinden avatar Oct 26 '23 11:10 nplinden

That does look very close yes, thanks for the answer.

I think this material is still a bit different in these ways

  • the original material.name
  • material.density is in units of sum even if it was originally made in g/cm3
  • has zero values for lots of isotopes that were not in original material
  • misses temperature

Let me see if I can refactor Results.export_to_materials() so that it makes use of these material instead of the material.xml file. I shall be back

shimwell avatar Oct 26 '23 15:10 shimwell