From c900e4784e68b3ea833e3b60fe80d3cc345f33eb Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Thu, 4 Aug 2022 07:55:35 +0100 Subject: [PATCH] Corrections to activity calcs Co-authored-by: Ethan Peterson --- openmc/material.py | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/openmc/material.py b/openmc/material.py index 05b69287d..48684ed67 100644 --- a/openmc/material.py +++ b/openmc/material.py @@ -927,23 +927,15 @@ class Material(IDManagerMixin): cv.check_value('normalization', normalization, {'total', 'mass', 'volume'}) cv.check_type('by_nuclide', by_nuclide, bool) - if normalization=='total': - activity = {} - for nuclide, atoms in self.get_nuclide_atoms().items(): - inv_seconds = openmc.data.decay_constant(nuclide) - activity[nuclide] = inv_seconds * atoms - - elif normalization=='mass': - activity = {} - for nuclide, atoms in self.get_nuclide_atom_densities().items(): - inv_seconds = openmc.data.decay_constant(nuclide) - activity[nuclide] = (inv_seconds * atoms * 1.0e24) / self.density - # normalization must be volume by this stage so else can be used + if normalization == 'total': + multiplier = self.volume else: - activity = {} - for nuclide, atoms in self.get_nuclide_atom_densities().items(): - inv_seconds = openmc.data.decay_constant(nuclide) - activity[nuclide] = (inv_seconds * atoms * 1.0e24) / self.volume + multiplier = 1 if normalization == 'volume' else 1.0 / self.get_mass_density() + + activity = {} + for nuclide, atoms_per_bcm in self.get_nuclide_atom_densities().items(): + inv_seconds = openmc.data.decay_constant(nuclide) + activity[nuclide] = inv_seconds * 1e24 * atoms_per_bcm * multiplier if by_nuclide: return activity