mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 14:15:42 -04:00
Sort materials list before creating <material> elements
This commit is contained in:
parent
ee8b7edd9c
commit
726d1a268f
2 changed files with 5 additions and 6 deletions
|
|
@ -87,7 +87,7 @@ class Geometry(object):
|
|||
|
||||
# Write the XML Tree to the geometry.xml file
|
||||
tree = ET.ElementTree(root_element)
|
||||
tree.write(path, xml_declaration=True, encoding='utf-8', method="xml")
|
||||
tree.write(path, xml_declaration=True, encoding='utf-8')
|
||||
|
||||
def find(self, point):
|
||||
"""Find cells/universes/lattices which contain a given point
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import numpy as np
|
|||
import openmc
|
||||
import openmc.data
|
||||
import openmc.checkvalue as cv
|
||||
from openmc.clean_xml import sort_xml_elements, clean_xml_indentation
|
||||
from openmc.clean_xml import clean_xml_indentation
|
||||
from .mixin import IDManagerMixin
|
||||
|
||||
|
||||
|
|
@ -1129,7 +1129,7 @@ class Materials(cv.CheckedList):
|
|||
material.make_isotropic_in_lab()
|
||||
|
||||
def _create_material_subelements(self, root_element):
|
||||
for material in self:
|
||||
for material in sorted(self, key=lambda x: x.id):
|
||||
root_element.append(material.to_xml_element(self.cross_sections))
|
||||
|
||||
def _create_cross_sections_subelement(self, root_element):
|
||||
|
|
@ -1153,14 +1153,13 @@ class Materials(cv.CheckedList):
|
|||
"""
|
||||
|
||||
root_element = ET.Element("materials")
|
||||
self._create_material_subelements(root_element)
|
||||
self._create_cross_sections_subelement(root_element)
|
||||
self._create_multipole_library_subelement(root_element)
|
||||
self._create_material_subelements(root_element)
|
||||
|
||||
# Clean the indentation in the file to be user-readable
|
||||
sort_xml_elements(root_element)
|
||||
clean_xml_indentation(root_element)
|
||||
|
||||
# Write the XML Tree to the materials.xml file
|
||||
tree = ET.ElementTree(root_element)
|
||||
tree.write(path, xml_declaration=True, encoding='utf-8', method="xml")
|
||||
tree.write(path, xml_declaration=True, encoding='utf-8')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue