Hey @gridley. Yeah, that’s a really good suggestion and I’ve come upon the same thought before. I could imagine both a fine-grained approach where you want to extract one specific material from a depletion results file as well as a more coarse-grained approach where you want to take an entire model and update all materials based on the state in the depletion results at a particular time. In any event, here’s how you could create a material based on what’s in the results file:
# Get final result
results = openmc.deplete.ResultsList.from_hdf5('depletion_results.h5')
last_result = results[-1]
# Create new Material object
new_mat = openmc.Material()
mat_id = 1 # ..or whatever your desired material is
new_mat.volume = last_result.volume[str(mat_id)]
# Add nuclides, skipping those with zero density
for nuc in last_result.nuc_to_ind.keys():
atoms = last_result[0, str(mat_id), nuc]
if atoms > 0.0:
atoms_per_barn_cm = 1e-24 * atoms / new_mat.volume
new_mat.add_nuclide(nuc, atoms_per_barn_cm)