From 98c287b83a692beac38eb1617f3f7315a6fa8a20 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Tue, 2 Aug 2022 17:24:48 +0100 Subject: [PATCH] volume not needed when finding specific activity --- openmc/material.py | 4 ++-- tests/unit_tests/test_material.py | 21 ++++++++------------- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/openmc/material.py b/openmc/material.py index 61015f5b0..57f9a6f86 100644 --- a/openmc/material.py +++ b/openmc/material.py @@ -945,9 +945,9 @@ class Material(IDManagerMixin): activity in [Bq/g]. """ activity = {} - for nuclide, atoms in self.get_nuclide_atoms().items(): + for nuclide, atoms in self.get_nuclide_atom_densities().items(): inv_seconds = openmc.data.decay_constant(nuclide) - activity[nuclide] = (inv_seconds * atoms) / self.get_mass() + activity[nuclide] = (inv_seconds * atoms * 1.0e24) / self.density return activity def get_nuclide_atoms(self): diff --git a/tests/unit_tests/test_material.py b/tests/unit_tests/test_material.py index d70161f48..c959ba276 100644 --- a/tests/unit_tests/test_material.py +++ b/tests/unit_tests/test_material.py @@ -481,12 +481,16 @@ def test_activity_of_stable(): def test_activity_of_tritium(): - """Checks that 1g of tritium has the correct activity""" + """Checks that 1g of tritium has the correct activity activity scaling""" m1 = openmc.Material() m1.add_nuclide("H3", 1) m1.set_density('g/cm3', 1) m1.volume = 1 assert pytest.approx(m1.activity) == 3.559778e14 + m1.set_density('g/cm3', 2) + assert pytest.approx(m1.activity) == 3.559778e14*2 + m1.volume = 3 + assert pytest.approx(m1.activity) == 3.559778e14*2*3 def test_activity_of_metastable(): @@ -499,18 +503,9 @@ def test_activity_of_metastable(): def test_specific_activity_of_tritium(): - """Checks that specific activity stays the same for all volumes and - densities while activity changes proportionally to mass""" + """Checks that specific activity of tritium is correct""" m1 = openmc.Material() m1.add_nuclide("H3", 1) m1.set_density('g/cm3', 1) - m1.volume = 1 - # activity and specific_activity are initially the same as we have 1g - assert pytest.approx(m1.specific_activity) == 3.559778e14 - assert pytest.approx(m1.activity) == 3.559778e14 - m1.set_density('g/cm3', 2) - assert pytest.approx(m1.specific_activity) == 3.559778e14 - assert pytest.approx(m1.activity) == 3.559778e14*2 - m1.volume = 3 - assert pytest.approx(m1.specific_activity) == 3.559778e14 - assert pytest.approx(m1.activity) == 3.559778e14*2*3 + assert m1.specific_activity == 355978108155965.9 + assert m1.get_nuclide_specific_activity() == {"H3": 355978108155965.9} \ No newline at end of file