Several small fixes

This commit is contained in:
Paul Romano 2022-12-22 18:27:42 -06:00
parent 2eca57a299
commit 25f2bd50f9
3 changed files with 8 additions and 11 deletions

View file

@ -27,7 +27,7 @@ def clean_indentation(element, level=0, spaces_per_level=2, trailing_indent=True
element.tail = i
for sub_element in element:
# `trailing_indent` is intentionally not forwarded to the recursive
# call. Any child element of the topmost clement should add
# call. Any child element of the topmost element should add
# indentation at the end to ensure its parent's indentation is
# correct.
clean_indentation(sub_element, level+1, spaces_per_level)

View file

@ -244,6 +244,8 @@ class Model:
def from_model_xml(cls, path='model.xml'):
"""Create model from single XML file
.. vesionadded:: 0.13.3
Parameters
----------
path : str or Pathlike
@ -259,13 +261,6 @@ class Model:
model.materials = openmc.Materials.from_xml_element(root.find('materials'))
model.geometry = openmc.Geometry.from_xml_element(root.find('geometry'), model.materials)
# gather meshes from other classes before reading the tally node
if model.settings.entropy_mesh is not None:
meshes[model.settings.entropy_mesh.id] = model.settings.entropy_mesh
for ww in model.settings.weight_windows:
meshes[ww.mesh.id] = ww.mesh
if root.find('tallies'):
model.tallies = openmc.Tallies.from_xml_element(root.find('tallies'), meshes)
@ -474,6 +469,8 @@ class Model:
def export_to_model_xml(self, path='model.xml', remove_surfs=False):
"""Export model to a single XML file.
.. versionadded:: 0.13.3
Parameters
----------
path : str or Pathlike
@ -483,7 +480,6 @@ class Model:
Whether or not to remove redundant surfaces from the geometry when
exporting.
.. versionadded:: 0.13.1
"""
xml_path = Path(path)
# if the provided path doesn't end with the XML extension, assume the

View file

@ -1100,7 +1100,8 @@ class Settings:
path = f"./mesh[@id='{self.entropy_mesh.id}']"
if root.find(path) is None:
root.append(self.entropy_mesh.to_xml_element())
if mesh_memo is not None: mesh_memo.add(self.entropy_mesh.id)
if mesh_memo is not None:
mesh_memo.add(self.entropy_mesh.id)
def _create_trigger_subelement(self, root):
if self._trigger_active is not None:
@ -1609,7 +1610,7 @@ class Settings:
self._create_temperature_subelements(element)
self._create_trace_subelement(element)
self._create_track_subelement(element)
self._create_ufs_mesh_subelement(element)
self._create_ufs_mesh_subelement(element, mesh_memo)
self._create_resonance_scattering_subelement(element)
self._create_volume_calcs_subelement(element)
self._create_create_fission_neutrons_subelement(element)