mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 22:26:08 -04:00
ResultList.get_atoms supports atom densities, days
Two new optional arguments to ResultsList.get_atoms are introduced that control the units on the return values. Time can be returned in second or in days if time_units is "s" or "d", respectively. Concentrations can be returned in atoms/cm^3 or atoms/b/cm if nuc_units is one of those values. The default is to return time in seconds and number of atoms, retaining back compatibility.
This commit is contained in:
parent
ceaecef45a
commit
a86c3481d6
1 changed files with 24 additions and 4 deletions
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue