Exemplo n.º 1
0
    def export_to_xml(self, filename='mgxs.xml'):
        """Create an mgxs.xml file that can be used for a
        simulation.

        Parameters
        ----------
        filename : str, optional
            filename of file, default is mgxs.xml

        """

        # Reset xml element tree
        self._cross_sections_file.clear()

        self._create_groups_subelement()
        self._create_group_structure_subelement()
        self._create_inverse_velocities_subelement()
        self._create_xsdata_subelements()

        # Clean the indentation in the file to be user-readable
        sort_xml_elements(self._cross_sections_file)
        clean_xml_indentation(self._cross_sections_file)

        # Write the XML Tree to the xsdatas.xml file
        tree = ET.ElementTree(self._cross_sections_file)
        tree.write(filename, xml_declaration=True,
                   encoding='utf-8', method='xml')
Exemplo n.º 2
0
    def export_to_xml(self):
        """Create a materials.xml file that can be used for a simulation.

        """

        # Reset xml element tree
        self._materials_file.clear()

        self._create_material_subelements()

        # Clean the indentation in the file to be user-readable
        sort_xml_elements(self._materials_file)
        clean_xml_indentation(self._materials_file)

        # Write the XML Tree to the materials.xml file
        tree = ET.ElementTree(self._materials_file)
        tree.write("materials.xml", xml_declaration=True,
                   encoding='utf-8', method="xml")
Exemplo n.º 3
0
    def export_to_xml(self, path='geometry.xml'):
        """Export geometry to an XML file.

        Parameters
        ----------
        path : str
            Path to file to write. Defaults to 'geometry.xml'.

        """
        # Create XML representation
        root_element = ET.Element("geometry")
        self.root_universe.create_xml_subelement(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 geometry.xml file
        tree = ET.ElementTree(root_element)
        tree.write(path, xml_declaration=True, encoding='utf-8', method="xml")
Exemplo n.º 4
0
    def export_to_xml(self):
        """Create a geometry.xml file that can be used for a simulation.

        """

        # Clear OpenMC written IDs used to optimize XML generation
        openmc.universe.WRITTEN_IDS = {}

        # Create XML representation
        geometry_file = ET.Element("geometry")
        self.root_universe.create_xml_subelement(geometry_file)

        # Clean the indentation in the file to be user-readable
        sort_xml_elements(geometry_file)
        clean_xml_indentation(geometry_file)

        # Write the XML Tree to the geometry.xml file
        tree = ET.ElementTree(geometry_file)
        tree.write("geometry.xml",
                   xml_declaration=True,
                   encoding='utf-8',
                   method="xml")
Exemplo n.º 5
0
    def export_to_xml(self, path='materials.xml'):
        """Export material collection to an XML file.

        Parameters
        ----------
        path : str
            Path to file to write. Defaults to 'materials.xml'.

        """

        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)

        # 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")
Exemplo n.º 6
0
    def export_to_xml(self, path='materials.xml'):
        """Export material collection to an XML file.

        Parameters
        ----------
        path : str
            Path to file to write. Defaults to 'materials.xml'.

        """

        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)

        # 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")