mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-26 13:15:39 -04:00
Add decay_photon_source property on Material
This commit is contained in:
parent
1395b50d49
commit
a917fd94c1
2 changed files with 54 additions and 1 deletions
|
|
@ -1,15 +1,19 @@
|
|||
from collections.abc import Iterable
|
||||
from io import StringIO
|
||||
from math import log
|
||||
from pathlib import Path
|
||||
import re
|
||||
from warnings import warn
|
||||
from xml.etree import ElementTree as ET
|
||||
|
||||
import numpy as np
|
||||
from uncertainties import ufloat, UFloat
|
||||
|
||||
import openmc
|
||||
import openmc.checkvalue as cv
|
||||
from openmc.exceptions import DataError
|
||||
from openmc.mixin import EqualityMixin
|
||||
from openmc.stats import Discrete, Tabular, combine_distributions
|
||||
from openmc.stats import Discrete, Tabular, Univariate, combine_distributions
|
||||
from .data import ATOMIC_SYMBOL, ATOMIC_NUMBER
|
||||
from .function import INTERPOLATION_SCHEME
|
||||
from .endf import Evaluation, get_head_record, get_list_record, get_tab1_record
|
||||
|
|
@ -570,3 +574,40 @@ class Decay(EqualityMixin):
|
|||
|
||||
self._sources = merged_sources
|
||||
return self._sources
|
||||
|
||||
|
||||
_DECAY_PHOTON_SOURCE = {}
|
||||
|
||||
|
||||
def decay_photon_source(nuclide):
|
||||
"""Get photon source 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'].
|
||||
|
||||
Parameters
|
||||
----------
|
||||
nuclide : str
|
||||
Name of nuclide, e.g., 'Co58'
|
||||
|
||||
Returns
|
||||
-------
|
||||
openmc.stats.Univariate
|
||||
Distribution of energies in [eV] of photons emitted from decay
|
||||
"""
|
||||
if not _DECAY_PHOTON_SOURCE:
|
||||
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 'photon' in nuc.sources:
|
||||
_DECAY_PHOTON_SOURCE[nuc.name] = nuc.sources['photon']
|
||||
|
||||
return _DECAY_PHOTON_SOURCE.get(nuclide)
|
||||
|
|
|
|||
|
|
@ -255,6 +255,18 @@ class Material(IDManagerMixin):
|
|||
/ openmc.data.AVOGADRO
|
||||
return density*self.volume
|
||||
|
||||
@property
|
||||
def decay_photon_source(self):
|
||||
atoms = self.get_nuclide_atoms()
|
||||
dists = []
|
||||
probs = []
|
||||
for nuc, num_atoms in atoms.items():
|
||||
source_per_atom = openmc.data.decay_photon_source(nuc)
|
||||
if source_per_atom is not None:
|
||||
dists.append(source_per_atom)
|
||||
probs.append(num_atoms)
|
||||
return openmc.data.combine_distributions(dists, probs)
|
||||
|
||||
@classmethod
|
||||
def from_hdf5(cls, group: h5py.Group):
|
||||
"""Create material from HDF5 group
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue