Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions openmc/deplete/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def get_activity(
----------
mat : openmc.Material, str
Material object or material id to evaluate
units : {'Bq', 'Bq/g', 'Bq/kg', 'Bq/cm3'}
units : {'Bq', 'Bq/g', 'Bq/kg', 'Bq/cm3', 'Bq/m3'}
Specifies the type of activity to return, options include total
activity [Bq], specific [Bq/g, Bq/kg] or volumetric activity [Bq/cm3].
by_nuclide : bool
Expand Down Expand Up @@ -231,7 +231,7 @@ def get_decay_heat(
----------
mat : openmc.Material, str
Material object or material id to evaluate.
units : {'W', 'W/g', 'W/kg', 'W/cm3'}
units : {'W', 'W/g', 'W/kg', 'W/cm3', 'W/m3'}
Specifies the units of decay heat to return. Options include total
heat [W], specific [W/g, W/kg] or volumetric heat [W/cm3].
by_nuclide : bool
Expand Down
27 changes: 16 additions & 11 deletions openmc/material.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ def get_decay_photon_energy(
clip_tolerance : float
Maximum fraction of :math:`\sum_i x_i p_i` for discrete distributions
that will be discarded.
units : {'Bq', 'Bq/g', 'Bq/kg', 'Bq/cm3'}
units : {'Bq', 'Bq/g', 'Bq/kg', 'Bq/cm3', 'Bq/m3'}
Specifies the units on the integral of the distribution.
volume : float, optional
Volume of the material. If not passed, defaults to using the
Expand All @@ -367,7 +367,7 @@ def get_decay_photon_energy(
the total intensity of the photon source in the requested units.

"""
cv.check_value('units', units, {'Bq', 'Bq/g', 'Bq/kg', 'Bq/cm3'})
cv.check_value('units', units, {'Bq', 'Bq/g', 'Bq/kg', 'Bq/cm3', 'Bq/m3'})

if exclude_nuclides is not None and include_nuclides is not None:
raise ValueError("Cannot specify both exclude_nuclides and include_nuclides")
Expand All @@ -378,6 +378,8 @@ def get_decay_photon_energy(
raise ValueError("volume must be specified if units='Bq'")
elif units == 'Bq/cm3':
multiplier = 1
elif units == 'Bq/m3':
multiplier = 1e6
elif units == 'Bq/g':
multiplier = 1.0 / self.get_mass_density()
elif units == 'Bq/kg':
Expand Down Expand Up @@ -1383,16 +1385,16 @@ def get_element_atom_densities(self, element: str | None = None) -> dict[str, fl

def get_activity(self, units: str = 'Bq/cm3', by_nuclide: bool = False,
volume: float | None = None) -> dict[str, float] | float:
"""Returns the activity of the material or of each nuclide within.
"""Return the activity of the material or each nuclide within.

.. versionadded:: 0.13.1

Parameters
----------
units : {'Bq', 'Bq/g', 'Bq/kg', 'Bq/cm3', 'Ci', 'Ci/m3'}
units : {'Bq', 'Bq/g', 'Bq/kg', 'Bq/cm3', 'Bq/m3', 'Ci', 'Ci/m3'}
Specifies the type of activity to return, options include total
activity [Bq,Ci], specific [Bq/g, Bq/kg] or volumetric activity
[Bq/cm3,Ci/m3]. Default is volumetric activity [Bq/cm3].
[Bq/cm3, Bq/m3, Ci/m3]. Default is volumetric activity [Bq/cm3].
by_nuclide : bool
Specifies if the activity should be returned for the material as a
whole or per nuclide. Default is False.
Expand All @@ -1410,7 +1412,7 @@ def get_activity(self, units: str = 'Bq/cm3', by_nuclide: bool = False,
of the material is returned as a float.
"""

cv.check_value('units', units, {'Bq', 'Bq/g', 'Bq/kg', 'Bq/cm3', 'Ci', 'Ci/m3'})
cv.check_value('units', units, {'Bq', 'Bq/g', 'Bq/kg', 'Bq/cm3', 'Bq/m3', 'Ci', 'Ci/m3'})
cv.check_type('by_nuclide', by_nuclide, bool)

if volume is None:
Expand All @@ -1420,6 +1422,8 @@ def get_activity(self, units: str = 'Bq/cm3', by_nuclide: bool = False,
multiplier = volume
elif units == 'Bq/cm3':
multiplier = 1
elif units == 'Bq/m3':
multiplier = 1e6
elif units == 'Bq/g':
multiplier = 1.0 / self.get_mass_density()
elif units == 'Bq/kg':
Expand All @@ -1438,16 +1442,15 @@ def get_activity(self, units: str = 'Bq/cm3', by_nuclide: bool = False,

def get_decay_heat(self, units: str = 'W', by_nuclide: bool = False,
volume: float | None = None) -> dict[str, float] | float:
"""Returns the decay heat of the material or for each nuclide in the
material in units of [W], [W/g], [W/kg] or [W/cm3].
"""Return the decay heat of the material or each nuclide within.

.. versionadded:: 0.13.3

Parameters
----------
units : {'W', 'W/g', 'W/kg', 'W/cm3'}
units : {'W', 'W/g', 'W/kg', 'W/cm3', 'W/m3'}
Specifies the units of decay heat to return. Options include total
heat [W], specific [W/g, W/kg] or volumetric heat [W/cm3].
heat [W], specific [W/g, W/kg] or volumetric heat [W/cm3, W/m3].
Default is total heat [W].
by_nuclide : bool
Specifies if the decay heat should be returned for the material as a
Expand All @@ -1466,13 +1469,15 @@ def get_decay_heat(self, units: str = 'W', by_nuclide: bool = False,
of the material is returned as a float.
"""

cv.check_value('units', units, {'W', 'W/g', 'W/kg', 'W/cm3'})
cv.check_value('units', units, {'W', 'W/g', 'W/kg', 'W/cm3', 'W/m3'})
cv.check_type('by_nuclide', by_nuclide, bool)

if units == 'W':
multiplier = volume if volume is not None else self.volume
elif units == 'W/cm3':
multiplier = 1
elif units == 'W/m3':
multiplier = 1e6
elif units == 'W/g':
multiplier = 1.0 / self.get_mass_density()
elif units == 'W/kg':
Expand Down
6 changes: 6 additions & 0 deletions tests/unit_tests/test_material.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,8 @@ def test_get_activity():
assert pytest.approx(m4.get_activity(units='Bq/g', by_nuclide=True)["H3"]) == 355978108155965.94 # [Bq/g]
assert pytest.approx(m4.get_activity(units='Bq/cm3')) == 355978108155965.94*3/2 # [Bq/cc]
assert pytest.approx(m4.get_activity(units='Bq/cm3', by_nuclide=True)["H3"]) == 355978108155965.94*3/2 # [Bq/cc]
assert pytest.approx(m4.get_activity(units='Bq/m3')) == 355978108155965.94*3/2*1e6 # [Bq/m3]
assert pytest.approx(m4.get_activity(units='Bq/m3', by_nuclide=True)["H3"]) == 355978108155965.94*3/2*1e6 # [Bq/m3]
# volume is required to calculate total activity
m4.volume = 10.
assert pytest.approx(m4.get_activity(units='Bq')) == 355978108155965.94*3/2*10 # [Bq]
Expand Down Expand Up @@ -650,6 +652,8 @@ def test_get_decay_heat():
assert pytest.approx(m4.get_decay_heat(units='W/g', by_nuclide=True)["I135"]) == 40175.15720273193 # [W/g]
assert pytest.approx(m4.get_decay_heat(units='W/cm3')) == 40175.15720273193*3/2 # [W/cc]
assert pytest.approx(m4.get_decay_heat(units='W/cm3', by_nuclide=True)["I135"]) == 40175.15720273193*3/2 #[W/cc]
assert pytest.approx(m4.get_decay_heat(units='W/m3')) == 40175.15720273193*3/2*1e6 # [W/m3]
assert pytest.approx(m4.get_decay_heat(units='W/m3', by_nuclide=True)["I135"]) == 40175.15720273193*3/2*1e6 # [W/m3]
# volume is required to calculate total decay heat
m4.volume = 10.
assert pytest.approx(m4.get_decay_heat(units='W')) == 40175.15720273193*3/2*10 # [W]
Expand Down Expand Up @@ -680,6 +684,8 @@ def test_decay_photon_energy():
src_per_bqg = m.get_decay_photon_energy(units='Bq/g')
src_per_bqkg = m.get_decay_photon_energy(units='Bq/kg')
assert pytest.approx(src_per_bqg.integral()) == src_per_bqkg.integral() / 1000.
src_per_bqm3 = m.get_decay_photon_energy(units='Bq/m3')
assert pytest.approx(src_per_bqm3.integral()) == src_per_cm3.integral() * 1e6

# If we add Xe135 (which has a tabular distribution), the photon source
# should be a mixture distribution
Expand Down
Loading