From aff76b82a199272b82aa553fbbeedb074df5b40a Mon Sep 17 00:00:00 2001 From: Will Boyd Date: Wed, 1 Apr 2015 18:48:03 -0400 Subject: [PATCH] Python API cells, surfaces, lattices and materials now use labels --- src/utils/openmc/material.py | 7 +++---- src/utils/openmc/summary.py | 2 +- src/utils/openmc/surface.py | 6 +++++- src/utils/openmc/universe.py | 23 +++++++++-------------- 4 files changed, 18 insertions(+), 20 deletions(-) diff --git a/src/utils/openmc/material.py b/src/utils/openmc/material.py index 7034feb6e..92c78bfdb 100644 --- a/src/utils/openmc/material.py +++ b/src/utils/openmc/material.py @@ -344,6 +344,9 @@ class Material(object): element = ET.Element("material") element.set("id", str(self._id)) + if len(self._name) > 0: + element.set("label", str(self._name)) + # Create density XML subelement subelement = ET.SubElement(element, "density") if self._density_units is not 'sum': @@ -470,10 +473,6 @@ class MaterialsFile(object): for material in self._materials: xml_element = material.get_material_xml() - - if len(material._name) > 0: - self._materials_file.append(ET.Comment(material._name)) - self._materials_file.append(xml_element) diff --git a/src/utils/openmc/summary.py b/src/utils/openmc/summary.py index 43ab01854..cde206721 100644 --- a/src/utils/openmc/summary.py +++ b/src/utils/openmc/summary.py @@ -274,7 +274,7 @@ class Summary(object): surfaces = list() # Create this Cell - cell = openmc.Cell(cell_id=cell_id, name) + cell = openmc.Cell(cell_id=cell_id, name=name) if fill_type == 'universe': translated = self._f['geometry/cells'][key]['translated'][0] diff --git a/src/utils/openmc/surface.py b/src/utils/openmc/surface.py index 269bfd1c7..5894cf250 100644 --- a/src/utils/openmc/surface.py +++ b/src/utils/openmc/surface.py @@ -110,6 +110,10 @@ class Surface(object): element = ET.Element("surface") element.set("id", str(self._id)) + + if len(self._name) > 0: + element.set("label", str(self._name)) + element.set("type", self._type) element.set("boundary", self._bc_type) @@ -592,4 +596,4 @@ class ZCone(Cone): # Initialize ZCone class attributes super(ZCone, self).__init__(surface_id, bc_type, x0, y0, z0, R2, name=name) - self._type = 'z-cone' \ No newline at end of file + self._type = 'z-cone' diff --git a/src/utils/openmc/universe.py b/src/utils/openmc/universe.py index e70b6effd..77d541e86 100644 --- a/src/utils/openmc/universe.py +++ b/src/utils/openmc/universe.py @@ -292,6 +292,9 @@ class Cell(object): element = ET.Element("cell") element.set("id", str(self._id)) + if len(self._name) > 0: + element.set("label", str(self._name)) + if isinstance(self._fill, openmc.Material): element.set("material", str(self._fill._id)) @@ -320,10 +323,6 @@ class Cell(object): # Create the XML subelement for this Surface surface = self._surfaces[surface_id][0] surface_subelement = surface.create_xml_subelement() - - if len(surface._name) > 0: - xml_element.append(ET.Comment(surface._name)) - xml_element.append(surface_subelement) # Append the halfspace and Surface ID @@ -547,10 +546,6 @@ class Universe(object): # Append the Universe ID to the subelement and add to Element cell_subelement.set("universe", str(self._id)) - - if len(cell._name) > 0: - xml_element.append(ET.Comment(cell._name)) - xml_element.append(cell_subelement) @@ -883,6 +878,9 @@ class RectLattice(Lattice): lattice_subelement = ET.Element("lattice") lattice_subelement.set("id", str(self._id)) + if len(self._name) > 0: + lattice_subelement.set("label", str(self._name)) + # Export the Lattice cell pitch if len(self._pitch) == 3: pitch = ET.SubElement(lattice_subelement, "pitch") @@ -966,9 +964,6 @@ class RectLattice(Lattice): universes = ET.SubElement(lattice_subelement, "universes") universes.text = universe_ids - if len(self._name) > 0: - xml_element.append(ET.Comment(self._name)) - # Append the XML subelement for this Lattice to the XML element xml_element.append(lattice_subelement) @@ -1190,6 +1185,9 @@ class HexLattice(Lattice): lattice_subelement = ET.Element("hex_lattice") lattice_subelement.set("id", str(self._id)) + if len(self._name) > 0: + lattice_subelement.set("label", str(self._name)) + # Export the Lattice cell pitch if len(self._pitch) == 2: pitch = ET.SubElement(lattice_subelement, "pitch") @@ -1260,9 +1258,6 @@ class HexLattice(Lattice): universes = ET.SubElement(lattice_subelement, "universes") universes.text = '\n' + universe_ids - if len(self._name) > 0: - xml_element.append(ET.Comment(self._name)) - # Append the XML subelement for this Lattice to the XML element xml_element.append(lattice_subelement)