Skip to content

Add decay heat function in material - #2287

Merged
paulromano merged 10 commits into
openmc-dev:developfrom
jiankai-yu:decay_heat
Nov 18, 2022
Merged

paulromano merged 10 commits into
openmc-dev:developfrom
jiankai-yu:decay_heat

Conversation

@jiankai-yu

@jiankai-yu jiankai-yu commented Oct 31, 2022 •

Copy link
Copy Markdown
Contributor

Recently I have been asked to extract decay heat from depleted materials. This PR is to add get_decayheat() function apart from get_activity() function in material. Its implementation is based on decay_energy.json, just like half_life.json for activity extraction. The extraction of decay heat from depleted materials can be done like this:


import openmc
import openmc.deplete
from openmc.deplete import chain 

chain = chain.Chain.from_xml('./chain_endfb80.xml')
nucs_all = [i.name for i in chain.nuclides]

depletion_results = openmc.deplete.Results('depletion_results.h5')
all_decayheats = []
time_steps = depletion_results.get_times('s')

for counter in range(0, len(time_steps)):
    materials_at_timestep = depletion_results.export_to_materials(burnup_index=counter, nuc_with_data=nucs_all)
    decayheat = 0.0
    for material in materials_at_timestep:
        decayheat += material.get_decayheat(units='W')
    all_decayheats.append(decayheat)

The unit test is also borrowed from activity's test and adjusted to decay heat.
Any comment is welcome.

@shimwell

shimwell commented Nov 1, 2022 •

Copy link
Copy Markdown
Member

Thanks for making this PR, I am keen to see such a feature adding. Nice work

I've made a few tiny comments for your consideration.

The main thing I am wondering about is. Should we get the decay energy from a chain_file.xml instead of an additional json file. This would allow us to separate the decay heat for different particles and be consistent with the decay data. With decay data from separate particles we could compare with plots like these

Comment thread tests/unit_tests/test_material.py Outdated
Comment thread tests/unit_tests/test_material.py Outdated
Comment thread tests/unit_tests/test_material.py Outdated
Comment thread tests/unit_tests/test_material.py Outdated
Comment thread tests/unit_tests/test_material.py Outdated
Comment thread openmc/material.py Outdated
@jiankai-yu

jiankai-yu commented Nov 1, 2022 •

Copy link
Copy Markdown
Contributor Author

Thanks for making this PR, I am keen to see such a feature adding. Nice work

I've made a few tiny comments for your consideration.

The main thing I am wondering about is. Should we get the decay energy from a chain_file.xml instead of an additional json file. This would allow us to separate the decay heat for different particles and be consistent with the decay data. With decay data from separate particles we could compare with plots like these

Thanks for your comments.
Can I do this way? For instance, add an optional argument for get_decayheat(decay_energy=decay_energy), and decay_energy can be prepared by users like this:

import xml.etree.ElementTree as ET
decay_energy = {}
tree = ET.parse('./chain_endfb80.xml')
for elem in tree.iter():
    if elem.tag == 'nuclide':
        if 'decay_energy' in elem.keys():
            decay_energy[elem.get('name').lower()] = float(elem.get('decay_energy'))

Comment thread openmc/data/data.py Outdated
@jiankai-yu
jiankai-yu requested review from paulromano and shimwell and removed request for paulromano and shimwell November 10, 2022 19:29

@paulromano paulromano left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the updates @jiankai-yu! A few more small changes and this should be good to go.

Comment thread openmc/data/decay.py Outdated
Comment thread openmc/data/decay.py Outdated
Comment thread openmc/data/decay.py Outdated
Comment thread openmc/material.py Outdated
Comment thread openmc/material.py Outdated
Comment thread tests/unit_tests/test_material.py Outdated
Comment thread tests/unit_tests/test_material.py Outdated
Comment thread tests/unit_tests/test_material.py Outdated
Comment thread tests/unit_tests/test_material.py Outdated
Comment thread tests/unit_tests/test_material.py Outdated
@jiankai-yu
jiankai-yu requested review from paulromano and removed request for shimwell November 15, 2022 16:32

@paulromano paulromano left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the updates @jiankai-yu! One final thing I forgot to mention before -- can you add the openmc.data.decay_energy function to docs/source/pythonapi/data.rst so that it is included in the documentation? Namely, in this section:
https://github.com/openmc-dev/openmc/blob/develop/docs/source/pythonapi/data.rst#core-functions

@jiankai-yu

Copy link
Copy Markdown
Contributor Author

Thanks for the updates @jiankai-yu! One final thing I forgot to mention before -- can you add the openmc.data.decay_energy function to docs/source/pythonapi/data.rst so that it is included in the documentation? Namely, in this section: https://github.com/openmc-dev/openmc/blob/develop/docs/source/pythonapi/data.rst#core-functions

Added. Thanks for your reminder.

@paulromano
paulromano merged commit a17fe6c into openmc-dev:develop Nov 18, 2022
apingegno pushed a commit to apingegno/openmc that referenced this pull request May 7, 2026
* add decay heat in material.py

* add decay_energy.json into eggs

* fix a bug when returned decay_ery is None

* add unit test for decayheat

* fix typo in doc string

* address reviewer's comments

* add user defined decay energy

* remove json for decay energy

* address a few comments

* add to docs
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