Apply suggestions from code review

Co-Authored-By: Patrick Shriwise <pshriwise@gmail.com>
This commit is contained in:
Mikolaj-A-Kowalski 2020-03-19 11:23:12 +00:00 committed by GitHub
parent 7ee102795f
commit 06ffd256bc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 9 deletions

View file

@ -88,7 +88,7 @@ class Cell(IDManagerMixin):
calculated in a stochastic volume calculation and added via the
:meth:`Cell.add_volume_information` method. For 'distribmat' cells
it is the total volume of all instances.
atoms : dict
atoms : collections.OrderedDict
Mapping of nuclides to the total number of atoms for each nuclide present
in the cell, or in all of its instances for a 'distribmat' fill. For example,
{'U235': 1.0e22, 'U238': 5.0e22, ...}.
@ -199,7 +199,7 @@ class Cell(IDManagerMixin):
Returns
-------
atoms: collections.OrderedDict
Dictionary in which keys are nuclides and values the number of
Dictionary in which keys are nuclides and values are the number of
atoms. For example, {'H1':1.0e22, 'O16':0.5e22, ...}
Raises
@ -224,7 +224,7 @@ class Cell(IDManagerMixin):
elif self.fill_type in ['lattice', 'universe']:
msg = ('Universe and Lattice cells can contain multiple '
'materials in diffrent proportions. Atom content must '
'be calculated with stochastic volume calculation')
'be calculated with stochastic volume calculation.')
raise ValueError(msg)
elif self.fill_type == 'material':
@ -244,14 +244,14 @@ class Cell(IDManagerMixin):
for mat in self.fill:
for key, nuclide in mat.get_nuclide_atom_densities().items():
# To account for overlap of nuclides between distribmat
# we need to append new atoms # to any existing value
# we need to append new atoms to any existing value
# hence it is necessary to ask for default.
atom = self._atoms.setdefault(key, 0)
atom += nuclide[1] * partial_volume * 1.0e+24
self._atoms[key] = atom
else:
msg = 'Unrecognised fill_type:{}'.format(self.fill_type)
msg = 'Unrecognised fill_type: {}'.format(self.fill_type)
raise ValueError(msg)
return self._atoms

View file

@ -150,7 +150,7 @@ def test_atoms_material_cell(uo2, water):
expected_nucs = ['U235', 'O16']
# Precalculate the expected number of atoms
M = ((atomic_mass('U235') + 2 * atomic_mass('O16'))/3)
M = (atomic_mass('U235') + 2 * atomic_mass('O16')) / 3
expected_atoms = list()
expected_atoms.append(1/3 * uo2.density/M * AVOGADRO * 2.0) # U235
expected_atoms.append(2/3 * uo2.density/M * AVOGADRO * 2.0) # O16
@ -174,7 +174,7 @@ def test_atoms_material_cell(uo2, water):
# Change material and check if OK
c.fill = water
expected_nucs = ['H1', 'O16']
M = ((2 * atomic_mass('H1') + atomic_mass('O16'))/3)
M = (2 * atomic_mass('H1') + atomic_mass('O16')) / 3
expected_atoms = list()
expected_atoms.append(2/3 * water.density/M * AVOGADRO * 3.0) # H1
expected_atoms.append(1/3 * water.density/M * AVOGADRO * 3.0) # O16
@ -194,8 +194,8 @@ def test_atoms_distribmat_cell(uo2, water):
# Calculate the expected number of atoms
expected_nucs = ['U235', 'O16', 'H1']
M_uo2 = ((atomic_mass('U235') + 2 * atomic_mass('O16'))/3)
M_water = ((2 * atomic_mass('H1') + atomic_mass('O16'))/3)
M_uo2 = (atomic_mass('U235') + 2 * atomic_mass('O16')) / 3
M_water = (2 * atomic_mass('H1') + atomic_mass('O16')) / 3
expected_atoms = list()
expected_atoms.append(1/3 * uo2.density/M_uo2 * AVOGADRO * 3.0) # U235
expected_atoms.append(2/3 * uo2.density/M_uo2 * AVOGADRO * 3.0 +