mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 13:45:36 -04:00
Python API cells, surfaces, lattices and materials now use labels
This commit is contained in:
parent
b48dc23e69
commit
aff76b82a1
4 changed files with 18 additions and 20 deletions
|
|
@ -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)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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]
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
self._type = 'z-cone'
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue