From 63b517aebc775fc4c060c18868895960c95100ae Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Mon, 8 Aug 2022 14:52:35 +0100 Subject: [PATCH] updated tests to use units args by @eepeterson Co-authored-by: Ethan Peterson --- openmc/material.py | 3 ++- tests/unit_tests/test_material.py | 24 ++++++++++++------------ 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/openmc/material.py b/openmc/material.py index c194a8229c..724b88ab47 100644 --- a/openmc/material.py +++ b/openmc/material.py @@ -910,9 +910,10 @@ class Material(IDManagerMixin): units : {'Bq', 'Bq/g', 'Bq/cm3'} Specifies the type of activity to return, options include total activity [Bq], specific [Bq/g] or volumetric activity [Bq/cm3]. + 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. + whole or per nuclide. Default is False. Returns ------- diff --git a/tests/unit_tests/test_material.py b/tests/unit_tests/test_material.py index 7e91216081..451c5308a4 100644 --- a/tests/unit_tests/test_material.py +++ b/tests/unit_tests/test_material.py @@ -480,37 +480,37 @@ def test_get_activity(): m1.add_element("Li", 0.3) m1.set_density('g/cm3', 1.5) # activity in Bq/cc and Bq/g should not require volume setting - assert m1.get_activity(normalization='volume') == 0 - assert m1.get_activity(normalization='mass') == 0 + assert m1.get_activity(units='Bq/cm3') == 0 + assert m1.get_activity(units='Bq/g') == 0 m1.volume = 1 - assert m1.get_activity(normalization='total') == 0 + assert m1.get_activity(units='Bq') == 0 # Checks that 1g of tritium has the correct activity scaling m2 = openmc.Material() m2.add_nuclide("H3", 1) m2.set_density('g/cm3', 1) m2.volume = 1 - assert pytest.approx(m2.get_activity(normalization='total')) == 3.559778e14 + assert pytest.approx(m2.get_activity(units='Bq')) == 3.559778e14 m2.set_density('g/cm3', 2) - assert pytest.approx(m2.get_activity(normalization='total')) == 3.559778e14*2 + assert pytest.approx(m2.get_activity(units='Bq')) == 3.559778e14*2 m2.volume = 3 - assert pytest.approx(m2.get_activity(normalization='total')) == 3.559778e14*2*3 + assert pytest.approx(m2.get_activity(units='Bq')) == 3.559778e14*2*3 # Checks that 1 mol of a metastable nuclides has the correct activity m3 = openmc.Material() m3.add_nuclide("Tc99_m1", 1) m3.set_density('g/cm3', 1) m3.volume = 98.9 - assert pytest.approx(m3.get_activity(normalization='total'), rel=0.001) == 1.93e19 + assert pytest.approx(m3.get_activity(units='Bq'), rel=0.001) == 1.93e19 # Checks that specific and volumetric activity of tritium are correct m4 = openmc.Material() m4.add_nuclide("H3", 1) m4.set_density('g/cm3', 1.5) - assert pytest.approx(m4.get_activity(normalization='mass')) == 355978108155965.94 # [Bq/g] - assert pytest.approx(m4.get_activity(normalization='mass', by_nuclide=True)["H3"]) == 355978108155965.94 # [Bq/g] - assert pytest.approx(m4.get_activity(normalization='volume')) == 355978108155965.94*3/2 # [Bq/cc] - assert pytest.approx(m4.get_activity(normalization='volume', by_nuclide=True)["H3"]) == 355978108155965.94*3/2 # [Bq/cc] + assert pytest.approx(m4.get_activity(units='Bq/g')) == 355978108155965.94 # [Bq/g] + 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] # volume is required to calculate total activity m4.volume = 10. - assert pytest.approx(m4.get_activity(normalization='total')) == 355978108155965.94*3/2*10 # [Bq] + assert pytest.approx(m4.get_activity(units='Bq')) == 355978108155965.94*3/2*10 # [Bq]