Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
remove json for decay energy
  • Loading branch information
jiankai-yu committed Nov 5, 2022
commit 542553b50098360e2e6fe117454c5211bf294f4d
29 changes: 0 additions & 29 deletions openmc/data/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@
# Used in half_life function as a cache
_HALF_LIFE = {}
_LOG_TWO = log(2.0)
_DECAY_ENERGY = {}

def atomic_mass(isotope):
"""Return atomic mass of isotope in atomic mass units.
Expand Down Expand Up @@ -333,34 +332,6 @@ def decay_constant(isotope):
return _LOG_TWO / t if t else 0.0


def decay_energy(isotope):
"""Return decay energy of isotope in eV or 0.0 if isotope is stable

Decay energy values are from the `ENDF/B-VIII.0 decay sublibrary
<https://www.nndc.bnl.gov/endf-b8.0/download.html>`_.

.. versionadded:: 0.14.1

Parameters
----------
isotope : str
Name of isotope, e.g., 'U235'

Returns
-------
float
Decay energy of isotope in [eV]

"""
global _DECAY_ENERGY
if not _DECAY_ENERGY:
# Load ENDF/B-VIII.0 data from JSON file
decay_energy_path = Path(__file__).with_name('decay_energy.json')
_DECAY_ENERGY = json.loads(decay_energy_path.read_text())
t = half_life(isotope)
return _DECAY_ENERGY.get(isotope.lower()) if t else 0.0


def water_density(temperature, pressure=0.1013):
"""Return the density of liquid water at a given temperature and pressure.

Expand Down
45 changes: 45 additions & 0 deletions openmc/data/decay.py
Original file line number Diff line number Diff line change
Expand Up @@ -619,3 +619,48 @@ def decay_photon_energy(nuclide: str) -> Optional[Univariate]:
"sources listed.")

return _DECAY_PHOTON_ENERGY.get(nuclide)


_DECAY_ENERGY = {}


def decay_energy(nuclide: str):
"""Get decay energy value resulting from the decay of a nuclide

This function relies on data stored in a depletion chain. Before calling it
for the first time, you need to ensure that a depletion chain has been
specified in openmc.config['chain_file'].

.. versionadded:: 0.14.0
Comment thread
paulromano marked this conversation as resolved.
Resolved

Parameters
----------
nuclide : str
Name of nuclide, e.g., 'H3'

Returns
-------
float
Decay energy of isotope in [eV].
Comment thread
paulromano marked this conversation as resolved.
Resolved
"""
if not _DECAY_ENERGY:
chain_file = openmc.config.get('chain_file')
if chain_file is None:
raise DataError(
"A depletion chain file must be specified with "
"openmc.config['chain_file'] in order to load decay data."
)

from openmc.deplete import Chain
chain = Chain.from_xml(chain_file)
for nuc in chain.nuclides:
if nuc.decay_energy:
_DECAY_ENERGY[nuc.name] = nuc.decay_energy

# If the chain file contained no decay energy, warn the user
if not _DECAY_ENERGY:
warn(f"Chain file '{chain_file}' does not have any decay energy.")

return _DECAY_ENERGY.get(nuclide)
Comment thread
paulromano marked this conversation as resolved.
Resolved


Loading