diff --git a/openmc/deplete/results_list.py b/openmc/deplete/results_list.py index 1b5b81ac4c..9e7cd9ffb9 100644 --- a/openmc/deplete/results_list.py +++ b/openmc/deplete/results_list.py @@ -2,7 +2,7 @@ import h5py import numpy as np from .results import Results, _VERSION_RESULTS -from openmc.checkvalue import check_filetype_version +from openmc.checkvalue import check_filetype_version, check_value __all__ = ["ResultsList"] @@ -40,7 +40,7 @@ class ResultsList(list): new.append(Results.from_hdf5(fh, i)) return new - def get_atoms(self, mat, nuc): + def get_atoms(self, mat, nuc, nuc_units="atoms", time_units="s"): """Get number of nuclides over time from a single material .. note:: @@ -57,15 +57,24 @@ class ResultsList(list): Material name to evaluate nuc : str Nuclide name to evaluate + nuc_units : {"atoms", "atoms/b/cm", "atoms/cm^3"}, optional + Units for the returned concentration. Default is ``"atoms"`` + time_units : {"s", "d"}, optional + Units for the returned time array. Default is ``"s"`` to + return the value in seconds Returns ------- time : numpy.ndarray - Array of times in [s] + Array of times in units of ``time_units`` concentration : numpy.ndarray - Total number of atoms for specified nuclide + Concentration of specified nuclide in units of ``nuc_units`` """ + check_value("time_units", time_units, {"s", "d"}) + check_value("nuc_units", nuc_units, + {"atoms", "atoms/b/cm", "atoms/cm^3"}) + time = np.empty_like(self, dtype=float) concentration = np.empty_like(self, dtype=float) @@ -74,6 +83,17 @@ class ResultsList(list): time[i] = result.time[0] concentration[i] = result[0, mat, nuc] + # Unit conversions + if time_units == "d": + time /= (60 * 60 * 24) + + if nuc_units != "atoms": + # Divide by volume to get density + concentration /= self[0].volume[mat] + if nuc_units == "atoms/b/cm": + # 1 barn = 1e-24 cm^2 + concentration *= 1e-24 + return time, concentration def get_reaction_rate(self, mat, nuc, rx):