Skip to content

Conversation

@shimwell
Copy link
Member

Description

When running a depletion simulation and then loading up the materials from a depletion_results.h5 file the material names are lost.

This makes depletion with DAGMC workflows a bit tricky as one typically knows the material name and not the ID in DAGMC workflows (this stems from material tags in the DAGMC file).

Anyway it would be super useful for me if we can preserve the material name when writing the depletion_results.h5 file so that I can easily find materials once again.

I have added tests but also manually tested with this script

I have also tried to keep this PR to the bare minimum and not cram in extra fixes or deviations from the objective.

"""Minimal OpenMC depletion example to test material name preservation."""

import openmc
import openmc.deplete
from pathlib import Path
openmc.config['cross_sections'] = Path.home() / 'nuclear_data'/ 'endf-b8.0-hdf5/' / 'cross_sections.xml'
openmc.config['chain_file'] = Path.home() / 'nuclear_data' / 'chain-endf-b8.0.xml'
fuel = openmc.Material(name="My Fuel Material", material_id=1)
fuel.add_nuclide("Fe56", 1)
fuel.set_density("g/cm3", 10.0)
fuel.depletable = True
fuel.volume = 4/3 * 3.14159 * 10**3  # sphere volume
materials = openmc.Materials()
sphere = openmc.Sphere(r=10, boundary_type="vacuum")
cell = openmc.Cell(fill=fuel, region=-sphere)
geometry = openmc.Geometry([cell])
settings = openmc.Settings()
settings.batches = 10
settings.run_mode  = 'fixed source'
settings.particles = 1000
settings.source = openmc.Source(
    space=openmc.stats.Point((0, 0, 0)),
    energy=openmc.stats.Discrete([14.0e6], [1.0])
)
model = openmc.Model(geometry, materials, settings)
model.deplete(
    method="predictor", 
    operator_kwargs={
        "normalization_mode": "source-rate",
        "chain_file": openmc.config['chain_file'],
        "reduce_chain_level": 5,
    },
    timesteps=[1,1,1,1],
    source_rates=[1e20,0,0,0],
)
results = openmc.deplete.Results("depletion_results.h5")
step = results[-1]
material = step.get_material('1')
assert material.name =="My Fuel Material"
print(material.name)

Fixes # (issue)

Checklist

  • I have followed the style guidelines for Python source files (if applicable)
  • I have added tests that prove my fix is effective or that my feature works (if applicable)

@shimwell shimwell requested a review from paulromano as a code owner January 16, 2026 10:43
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.

2 participants