From cd20c2b82d13e4839cf6dbbbc0d5e0bc37cca358 Mon Sep 17 00:00:00 2001 From: Sterling Harper Date: Mon, 18 Jan 2016 16:28:11 -0500 Subject: [PATCH 1/3] Fix error with void fills in universe.py --- openmc/universe.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/openmc/universe.py b/openmc/universe.py index ccd0cb27c3..a828d8da90 100644 --- a/openmc/universe.py +++ b/openmc/universe.py @@ -402,22 +402,23 @@ class Cell(object): if len(self._name) > 0: element.set("name", str(self._name)) - if isinstance(self._fill, openmc.Material): - element.set("material", str(self._fill._id)) + if isinstance(self.fill, basestring): + assert self.fill.strip().lower() == 'void' + element.set("material", "void") - elif isinstance(self._fill, Iterable): + elif isinstance(self.fill, openmc.Material): + element.set("material", str(self.fill.id)) + + elif isinstance(self.fill, Iterable): element.set("material", ' '.join([m if m == 'void' else str(m.id) for m in self.fill])) - elif isinstance(self._fill, (Universe, Lattice)): - element.set("fill", str(self._fill._id)) + elif isinstance(self.fill, (Universe, Lattice)): + 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)) + element.set("fill", str(self.fill)) self._fill.create_xml_subelement(xml_element) if self.region is not None: From f34093f1589fc02edad27d27cc4a676d1bf24a09 Mon Sep 17 00:00:00 2001 From: Sterling Harper Date: Mon, 18 Jan 2016 19:05:39 -0500 Subject: [PATCH 2/3] Use more properties over attributes --- openmc/universe.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/openmc/universe.py b/openmc/universe.py index a828d8da90..8e06ba1821 100644 --- a/openmc/universe.py +++ b/openmc/universe.py @@ -397,10 +397,10 @@ class Cell(object): def create_xml_subelement(self, xml_element): element = ET.Element("cell") - element.set("id", str(self._id)) + element.set("id", str(self.id)) if len(self._name) > 0: - element.set("name", str(self._name)) + element.set("name", str(self.name)) if isinstance(self.fill, basestring): assert self.fill.strip().lower() == 'void' @@ -415,11 +415,11 @@ class Cell(object): elif isinstance(self.fill, (Universe, Lattice)): element.set("fill", str(self.fill.id)) - self._fill.create_xml_subelement(xml_element) + self.fill.create_xml_subelement(xml_element) else: element.set("fill", str(self.fill)) - self._fill.create_xml_subelement(xml_element) + self.fill.create_xml_subelement(xml_element) if self.region is not None: # Set the region attribute with the region specification @@ -446,11 +446,11 @@ class Cell(object): # Call the recursive function from the top node create_surface_elements(self.region, xml_element) - if self._translation is not None: - element.set("translation", ' '.join(map(str, self._translation))) + if self.translation is not None: + element.set("translation", ' '.join(map(str, self.translation))) - if self._rotation is not None: - element.set("rotation", ' '.join(map(str, self._rotation))) + if self.rotation is not None: + element.set("rotation", ' '.join(map(str, self.rotation))) return element From 9d431fbbafd25486855ec9daabc7c1be6291b4f6 Mon Sep 17 00:00:00 2001 From: Sterling Harper Date: Mon, 18 Jan 2016 19:11:40 -0500 Subject: [PATCH 3/3] Remove frivolous assertion --- openmc/universe.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openmc/universe.py b/openmc/universe.py index 8e06ba1821..237ddce1f7 100644 --- a/openmc/universe.py +++ b/openmc/universe.py @@ -403,7 +403,6 @@ class Cell(object): element.set("name", str(self.name)) if isinstance(self.fill, basestring): - assert self.fill.strip().lower() == 'void' element.set("material", "void") elif isinstance(self.fill, openmc.Material):