From 064426a05fdac019917d613eb2805fb80f5fb5ad Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Tue, 2 Aug 2022 13:17:33 +0100 Subject: [PATCH] added specific_activity --- openmc/material.py | 25 +++++++++++++++++++++++++ tests/unit_tests/test_material.py | 18 ++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/openmc/material.py b/openmc/material.py index 6c2641680..61015f5b0 100644 --- a/openmc/material.py +++ b/openmc/material.py @@ -94,6 +94,9 @@ class Material(IDManagerMixin): activity : float Activity of the material in [Bq]. Requires that the :attr:`volume` attribute is set. + specific_activity : float + Activity of the material per unit mass in [Bq/kg]. Requires that the + :attr:`volume` and :attr:`density` attributes are set. """ @@ -155,6 +158,11 @@ class Material(IDManagerMixin): """Returns the total activity of the material in Becquerels.""" return sum(self.get_nuclide_activity().values()) + @property + def specific_activity(self): + """Returns the total specific activity of the material in Becquerels per gram.""" + return sum(self.get_nuclide_specific_activity().values()) + @property def name(self): return self._name @@ -925,6 +933,23 @@ class Material(IDManagerMixin): activity[nuclide] = inv_seconds * atoms return activity + def get_nuclide_specific_activity(self): + """Return specific activity in [Bq/g] for each nuclide in the material + + .. versionadded:: 0.13.1 + + Returns + ------- + dict + Dictionary whose keys are nuclide names and values are specific + activity in [Bq/g]. + """ + activity = {} + for nuclide, atoms in self.get_nuclide_atoms().items(): + inv_seconds = openmc.data.decay_constant(nuclide) + activity[nuclide] = (inv_seconds * atoms) / self.get_mass() + return activity + def get_nuclide_atoms(self): """Return number of atoms of each nuclide in the material diff --git a/tests/unit_tests/test_material.py b/tests/unit_tests/test_material.py index 2c5cc2874..d70161f48 100644 --- a/tests/unit_tests/test_material.py +++ b/tests/unit_tests/test_material.py @@ -496,3 +496,21 @@ def test_activity_of_metastable(): m1.set_density('g/cm3', 1) m1.volume = 98.9 assert pytest.approx(m1.activity, rel=0.001) == 1.93e19 + + +def test_specific_activity_of_tritium(): + """Checks that specific activity stays the same for all volumes and + densities while activity changes proportionally to mass""" + 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