コード例 #1
0
ファイル: exciting.py プロジェクト: slabanja/ase
 def write(self, atoms):
     from lxml import etree as ET
     from ase.io.exciting import atoms2etree
     if not os.path.isdir(self.dir):
         os.mkdir(self.dir)
     root = atoms2etree(atoms)
     root.find('structure').attrib['speciespath'] = self.speciespath
     root.find('structure').attrib['autormt'] = 'false'
     groundstate = ET.SubElement(root, 'groundstate', tforce='true')
     for key, value in self.groundstate_attributes.items():
         groundstate.attrib[key] = str(value)
     if self.template:
         xslf = open(self.template, 'r')
         xslt_doc = ET.parse(xslf)
         transform = ET.XSLT(xslt_doc)
         result = transform(root)
         fd = open('%s/input.xml' % self.dir, 'w')
         fd.write(
             ET.tostring(result,
                         method='xml',
                         pretty_print=True,
                         xml_declaration=True,
                         encoding='UTF-8'))
         fd.close()
     else:
         fd = open('%s/input.xml' % self.dir, 'w')
         fd.write(
             ET.tostring(root,
                         method='xml',
                         pretty_print=True,
                         xml_declaration=True,
                         encoding='UTF-8'))
         fd.close()
コード例 #2
0
    def write(self, atoms):
        if not os.path.isdir(self.dir):
            os.mkdir(self.dir)
        root = atoms2etree(atoms)
        root.find('structure').attrib['speciespath'] = self.speciespath
        root.find('structure').attrib['autormt'] = str(self.autormt).lower()
        root.find('structure').attrib['tshift'] = str(self.tshift).lower()

        def prettify(elem):
            rough_string = ET.tostring(elem, 'utf-8')
            reparsed = minidom.parseString(rough_string)
            return reparsed.toprettyxml(indent="\t")

        if(self.paramdict):
            self.dicttoxml(self.paramdict, root)
            fd = open('%s/input.xml' % self.dir, 'w')
            fd.write(prettify(root))
            fd.close()
        else:
            groundstate = ET.SubElement(root, 'groundstate', tforce='true')
            for key, value in self.groundstate_attributes.items():
                if key == 'title':
                    root.findall('title')[0].text = value
                else:
                    groundstate.attrib[key] = str(value)
            fd = open('%s/input.xml' % self.dir, 'w')
            fd.write(prettify(root))
            fd.close()
コード例 #3
0
ファイル: exciting.py プロジェクト: vorwerkc/excitingscripts
    def write(self, atoms):
        from lxml import etree as ET
        from ase.io.exciting import atoms2etree
        if not os.path.isdir(self.dir):
            os.mkdir(self.dir)
        root = atoms2etree(atoms)
        root.find('structure').attrib['speciespath'] = self.speciespath
        root.find('structure').attrib['autormt'] = 'false'

        if (self.paramdict):
            self.dicttoxml(self.paramdict, root)
            fd = open('%s/input.xml' % self.dir, 'w')
            fd.write(
                ET.tostring(root,
                            method='xml',
                            pretty_print=True,
                            xml_declaration=True,
                            encoding='UTF-8'))
            fd.close()
        else:
            groundstate = ET.SubElement(root, 'groundstate', tforce='true')
            for key, value in self.groundstate_attributes.items():
                if key == "title":
                    root.findall("title")[0].text = value
                else:
                    groundstate.attrib[key] = str(value)
            fd = open('%s/input.xml' % self.dir, 'w')
            fd.write(
                ET.tostring(root,
                            method='xml',
                            pretty_print=True,
                            xml_declaration=True,
                            encoding='UTF-8'))
            fd.close()
コード例 #4
0
ファイル: exciting.py プロジェクト: gjuhasz/ase
 def write(self, atoms):
     from lxml import etree as ET
     from ase.io.exciting import  atoms2etree
     if not os.path.isdir(self.dir):
         os.mkdir(self.dir)
     root = atoms2etree(atoms)
     root.find('structure').attrib['speciespath'] = self.speciespath
     root.find('structure').attrib['autormt'] = 'false'
     groundstate = ET.SubElement(root, 'groundstate', tforce='true')
     for key, value in self.groundstate_attributes.items():
         groundstate.attrib[key] = str(value)
     if self.template:
         xslf = open(self.template, 'r')
         xslt_doc = ET.parse(xslf)
         transform = ET.XSLT(xslt_doc)
         result = transform(root)
         fd = open('%s/input.xml' % self.dir, 'w')
         fd.write(ET.tostring(result, method='xml', pretty_print=True,
                              xml_declaration=True, encoding='UTF-8'))
         fd.close()
     else:
         fd = open('%s/input.xml' % self.dir, 'w')
         fd.write(ET.tostring(root, method='xml', pretty_print=True,
                              xml_declaration=True, encoding='UTF-8'))
         fd.close()
コード例 #5
0
ファイル: exciting.py プロジェクト: sr76/excitingscripts
 def write(self, atoms):
     from lxml import etree as ET
     from ase.io.exciting import  atoms2etree
     if not os.path.isdir(self.dir):
         os.mkdir(self.dir)
     root = atoms2etree(atoms)
     root.find('structure').attrib['speciespath'] = self.speciespath
     root.find('structure').attrib['autormt'] = 'false'
    
     
     if(self.paramdict):
         self.dicttoxml(self.paramdict,root)
         fd = open('%s/input.xml' % self.dir, 'w')
         fd.write(ET.tostring(root, method='xml', pretty_print=True,
                              xml_declaration=True, encoding='UTF-8'))
         fd.close()
     else:
         groundstate = ET.SubElement(root, 'groundstate', tforce='true')
         for key, value in self.groundstate_attributes.items():
             if key=="title":
                 root.findall("title")[0].text=value
             else:
                 groundstate.attrib[key] = str(value)
         fd = open('%s/input.xml' % self.dir, 'w')
         fd.write(ET.tostring(root, method='xml', pretty_print=True,
                              xml_declaration=True, encoding='UTF-8'))
         fd.close()