Address comments by @pshriwise

This commit is contained in:
Mikolaj Adam Kowalski 2020-03-19 12:04:44 +00:00
parent 06ffd256bc
commit ec10221219
5 changed files with 14 additions and 21 deletions

View file

@ -188,8 +188,8 @@ the :class:`openmc.Cell` class::
In this example, an instance of :class:`openmc.Material` is assigned to the
:attr:`Cell.fill` attribute. One can also fill a cell with a :ref:`universe
<usersguide_universes>` or :ref:`lattice <usersguide_lattices>`. If you provide
no fill to a cell, it will be filled with void on export to XML.
<usersguide_universes>` or :ref:`lattice <usersguide_lattices>`. If no fill
is provided to a cell, it will be filled with void by default.
The classes :class:`Halfspace`, :class:`Intersection`, :class:`Union`, and
:class:`Complement` and all instances of :class:`openmc.Region` and can be

View file

@ -89,9 +89,9 @@ class Cell(IDManagerMixin):
:meth:`Cell.add_volume_information` method. For 'distribmat' cells
it is the total volume of all instances.
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, ...}.
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, ...}.
"""
@ -140,10 +140,7 @@ class Cell(IDManagerMixin):
string += '\t{0: <15}=\t{1}\n'.format('Temperature',
self.temperature)
string += '{: <16}=\t{}\n'.format('\tTranslation', self.translation)
# Print volume only when it is set to avoid breaking regression
if self._volume is not None:
string += '{: <16}=\t{}\n'.format('\tVolume', self.volume)
string += '{: <16}=\t{}\n'.format('\tVolume', self.volume)
return string
@ -364,13 +361,7 @@ class Cell(IDManagerMixin):
def volume(self, volume):
if volume is not None:
cv.check_type('cell volume', volume, (Real, UFloat))
# Note that ufloat(0.0, 0.1) >= 0.0 is False
# We need special treatment for UFloat input
val = volume
if isinstance(val, UFloat):
val = volume.nominal_value
cv.check_greater_than('cell volume', val, 0.0)
cv.check_greater_than('cell volume', volume, 0.0, equality=True)
self._volume = volume

View file

@ -7,3 +7,4 @@ Cell
Region = -9
Rotation = None
Translation = None
Volume = None

View file

@ -39,3 +39,4 @@ Cell
Rotation = None
Temperature = [500. 700. 0. 800.]
Translation = None
Volume = None

View file

@ -130,13 +130,13 @@ def test_volume_setting():
c.volume = 3
c.volume = u.ufloat(3, 0.7)
# Test errors for -ve and 0 volume
with pytest.raises(ValueError):
c.volume = 0.0
# Allow volume to be set to 0.0
c.volume = 0.0
c.volume = u.ufloat(0.0, 0.1)
# Test errors for -ve volume
with pytest.raises(ValueError):
c.volume = -1.0
with pytest.raises(ValueError):
c.volume = u.ufloat(0.0, 0.1)
with pytest.raises(ValueError):
c.volume = u.ufloat(-0.05, 0.1)