mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 06:05:58 -04:00
added option for year as time units
This commit is contained in:
parent
8a6dc7e9f8
commit
6865264abd
2 changed files with 13 additions and 9 deletions
|
|
@ -16,6 +16,8 @@ __all__ = ["Results", "ResultsList"]
|
|||
|
||||
|
||||
def _get_time_as(seconds, units):
|
||||
if units == "y":
|
||||
return seconds / (60 * 60 * 24 * 365.25) # 365.25 due to the leap year
|
||||
if units == "d":
|
||||
return seconds / (60 * 60 * 24)
|
||||
elif units == "h":
|
||||
|
|
@ -95,7 +97,7 @@ class Results(list):
|
|||
Units for the returned concentration. Default is ``"atoms"``
|
||||
|
||||
.. versionadded:: 0.12
|
||||
time_units : {"s", "min", "h", "d"}, optional
|
||||
time_units : {"s", "min", "h", "d", "y"}, optional
|
||||
Units for the returned time array. Default is ``"s"`` to
|
||||
return the value in seconds.
|
||||
|
||||
|
|
@ -109,7 +111,7 @@ class Results(list):
|
|||
Concentration of specified nuclide in units of ``nuc_units``
|
||||
|
||||
"""
|
||||
cv.check_value("time_units", time_units, {"s", "d", "min", "h"})
|
||||
cv.check_value("time_units", time_units, {"s", "d", "min", "h", "y"})
|
||||
cv.check_value("nuc_units", nuc_units,
|
||||
{"atoms", "atom/b-cm", "atom/cm3"})
|
||||
|
||||
|
|
@ -190,7 +192,7 @@ class Results(list):
|
|||
|
||||
Parameters
|
||||
----------
|
||||
time_units : {"s", "d", "h", "min"}, optional
|
||||
time_units : {"s", "d", "min", "h", "y"}, optional
|
||||
Desired units for the times array
|
||||
|
||||
Returns
|
||||
|
|
@ -203,7 +205,7 @@ class Results(list):
|
|||
1 contains the associated uncertainty
|
||||
|
||||
"""
|
||||
cv.check_value("time_units", time_units, {"s", "d", "min", "h"})
|
||||
cv.check_value("time_units", time_units, {"s", "d", "min", "h", "y"})
|
||||
|
||||
times = np.empty_like(self, dtype=float)
|
||||
eigenvalues = np.empty((len(self), 2), dtype=float)
|
||||
|
|
@ -257,7 +259,7 @@ class Results(list):
|
|||
|
||||
Parameters
|
||||
----------
|
||||
time_units : {"s", "d", "h", "min"}, optional
|
||||
time_units : {"s", "d", "min", "h", "y"}, optional
|
||||
Return the vector in these units. Default is to
|
||||
convert to days
|
||||
|
||||
|
|
@ -267,7 +269,7 @@ class Results(list):
|
|||
1-D vector of time points
|
||||
|
||||
"""
|
||||
cv.check_value("time_units", time_units, {"s", "d", "min", "h"})
|
||||
cv.check_value("time_units", time_units, {"s", "d", "min", "h", "y"})
|
||||
|
||||
times = np.fromiter(
|
||||
(r.time[0] for r in self),
|
||||
|
|
@ -296,7 +298,7 @@ class Results(list):
|
|||
----------
|
||||
time : float
|
||||
Desired point in time
|
||||
time_units : {"s", "d", "min", "h"}, optional
|
||||
time_units : {"s", "d", "min", "h", "y"}, optional
|
||||
Units on ``time``. Default: days
|
||||
atol : float, optional
|
||||
Absolute tolerance (in ``time_units``) if ``time`` is not
|
||||
|
|
|
|||
|
|
@ -70,14 +70,16 @@ def test_get_keff(res):
|
|||
np.testing.assert_allclose(k[:, 1], u_ref)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("unit", ("s", "d", "min", "h"))
|
||||
@pytest.mark.parametrize("unit", ("s", "d", "min", "h", "y"))
|
||||
def test_get_steps(unit):
|
||||
# Make a Results full of near-empty Result instances
|
||||
# Just fill out a time schedule
|
||||
results = openmc.deplete.Results()
|
||||
# Time in units of unit
|
||||
times = np.linspace(0, 100, num=5)
|
||||
if unit == "d":
|
||||
if unit == "y":
|
||||
conversion_to_seconds = 60 * 60 * 24 * 365.25
|
||||
elif unit == "d":
|
||||
conversion_to_seconds = 60 * 60 * 24
|
||||
elif unit == "h":
|
||||
conversion_to_seconds = 60 * 60
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue