diff --git a/openmc/deplete/results.py b/openmc/deplete/results.py index e1fcb26b6d6..adb0d3dbc04 100644 --- a/openmc/deplete/results.py +++ b/openmc/deplete/results.py @@ -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 @@ -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 diff --git a/openmc/material.py b/openmc/material.py index 239bc01f771..2dbe691f525 100644 --- a/openmc/material.py +++ b/openmc/material.py @@ -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 @@ -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") @@ -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': @@ -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. @@ -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: @@ -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': @@ -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 @@ -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': diff --git a/tests/unit_tests/test_material.py b/tests/unit_tests/test_material.py index 58cd4d563df..911b8867f96 100644 --- a/tests/unit_tests/test_material.py +++ b/tests/unit_tests/test_material.py @@ -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] @@ -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] @@ -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