Merge pull request #374 from smharper/pyapi_void_mat

This commit is contained in:
Will Boyd 2015-04-24 23:41:42 -04:00
commit 2bc76cbd83

View file

@ -114,23 +114,30 @@ class Cell(object):
@fill.setter
def fill(self, fill):
if not isinstance(fill, (openmc.Material, Universe, Lattice)) \
and fill != 'void':
if isinstance(fill, str):
if fill.strip().lower() == 'void':
self._type = 'void'
else:
msg = 'Unable to set Cell ID={0} to use a non-Material or ' \
'Universe fill {1}'.format(self._id, fill)
raise ValueError(msg)
elif isinstance(fill, openmc.Material):
self._type = 'normal'
elif isinstance(fill, Universe):
self._type = 'fill'
elif isinstance(fill, Lattice):
self._type = 'lattice'
else:
msg = 'Unable to set Cell ID={0} to use a non-Material or ' \
'Universe fill {1}'.format(self._id, fill)
raise ValueError(msg)
self._fill = fill
if isinstance(fill, Lattice):
self._type = 'lattice'
elif isinstance(fill, Universe):
self._type = 'fill'
elif fill == 'void':
self._type = 'normal'
else:
self._type = 'normal'
@rotation.setter
def rotation(self, rotation):
@ -247,7 +254,7 @@ class Cell(object):
path = path[1:]
# If the Cell is filled by a Material
if self._type == 'normal':
if self._type == 'normal' or self._type == 'void':
offset = 0
# If the Cell is filled by a Universe
@ -345,6 +352,9 @@ class Cell(object):
element.set("fill", str(self._fill._id))
self._fill.create_xml_subelement(xml_element)
elif self._fill.strip().lower() == "void":
element.set("material", "void")
else:
element.set("fill", str(self._fill))
self._fill.create_xml_subelement(xml_element)