当前位置: 首页>>代码示例>>Python>>正文


Python Geometry.get_lattice_text方法代码示例

本文整理汇总了Python中Geometry.get_lattice_text方法的典型用法代码示例。如果您正苦于以下问题:Python Geometry.get_lattice_text方法的具体用法?Python Geometry.get_lattice_text怎么用?Python Geometry.get_lattice_text使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Geometry的用法示例。


在下文中一共展示了Geometry.get_lattice_text方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import Geometry [as 别名]
# 或者: from Geometry import get_lattice_text [as 别名]
class GUI:
    def __init__(self):
        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.window.set_title ('qmcPACK Input Builder')
        manager = MainManager()
        self.window.add_accel_group (manager.get_accel_group())
        manager.Setup()
        mainMenu = manager.get_widget("/MenuBar")
        mainBox = gtk.VBox()
        mainBox.pack_start (mainMenu, False, False)
        # Connect menu callbacks
        manager.SaveAsAction.connect("activate", self.save_as_callback)
        manager.SaveAction.connect("activate", self.save_callback)
        self.About = GUIAboutDialog()
        manager.AboutAction.connect("activate", self.about_callback)
        
        self.window.connect("delete_event", self.delete)
        notebook = gtk.Notebook()
        notebook.set_tab_pos (gtk.POS_LEFT)
        self.GeometryFrame = Geometry()
        self.WavefunctionFrame = Wavefunction(self.GeometryFrame)
        self.RunFrame = Run()
        notebook.append_page (self.GeometryFrame, gtk.Label("Geometry"))
        notebook.append_page (self.WavefunctionFrame, gtk.Label("Wave function"))
        notebook.append_page (self.RunFrame, gtk.Label("Run"))
        if (viewerOkay):
            self.Viewer = StructureViewer()
            notebook.append_page(self.Viewer, gtk.Label("Viewer"))
        mainBox.pack_start (notebook, False, False, 5)
        self.window.add (mainBox)
        # Setup dialogs
        buttons = (gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_SAVE,gtk.RESPONSE_OK)
        self.SaveAsDialog = gtk.FileChooserDialog("Save qmcPACK input as", \
                                                  self.window, gtk.FILE_CHOOSER_ACTION_SAVE, buttons)
        self.SaveAsDialog.hide()
        self.Filename = None
        self.window.show_all()

    def about_callback (self, action):
        self.About.run()
    
    def save_as_callback(self, action):
        if (self.SaveAsDialog.run() == gtk.RESPONSE_OK):
            self.Filename = self.SaveAsDialog.get_filename()
            self.write_qmcPACK(self.Filename)
            self.window.set_title (basename(self.Filename))
        self.SaveAsDialog.hide()
                

    def save_callback(self, action):
        if (self.Filename == None):
            self.save_as_callback(action)
        else:
            self.write_qmcPACK (self.Filename)

    def write_qmcPACK(self, filename):
        impl = getDOMImplementation()
        doc = impl.createDocument(None, "qmcPACK", None)
        topElem = doc.documentElement
        # Write out structural geometry elements
        systemElem  = doc.createElement("qmcsystem")
        systemElem.setAttribute("dim", "3")
        # Simulation cell information
        cellElem    = doc.createElement ("simulationcell")
        latticeElem = doc.createElement ("parameter")
        latticeElem.setAttribute("name", "lattice")
        latticeText = doc.createTextNode("\n"+self.GeometryFrame.get_lattice_text()+"      ")
        latticeElem.appendChild (latticeText)
        bcondsElem  = doc.createElement ("bconds")
        bcondsText  = doc.createTextNode(" " + self.GeometryFrame.get_periodic_text() + " ")
        bcondsElem.appendChild (bcondsText)
        cellElem.appendChild (latticeElem)
        cellElem.appendChild (bcondsElem)
        # Atom position information
        particleSetElem = doc.createElement ("particleset")
        particleSetElem.setAttribute ("name", "i")
        particleSetElem.setAttribute ("size", repr (self.GeometryFrame.get_num_atoms()))
        systemElem.appendChild(cellElem)

        # Ion types
        ionData = self.GeometryFrame.get_atom_data()
        bareIons = False
        pseudoIons = False
        for data in ionData:
            groupElem = doc.createElement ("group")
            groupElem.setAttribute("name", data[0])
            chargeElem = doc.createElement("parameter")
            chargeElem.setAttribute("name", "charge")
            chargeElem.appendChild(doc.createTextNode(repr(data[2])))
            valenceElem = doc.createElement("parameter")
            valenceElem.setAttribute("name", "valence")
            valenceElem.appendChild(doc.createTextNode(repr(data[2])))
            zElem = doc.createElement("parameter")
            zElem.setAttribute("name", "atomicnumber")
            zElem.appendChild(doc.createTextNode(repr(data[1])))
            groupElem.appendChild(chargeElem)
            groupElem.appendChild(valenceElem)
            groupElem.appendChild(zElem)
            particleSetElem.appendChild (groupElem)
            if ((data[3]=="Nonlocal PP") or (data[3] == "LocalPP")):
#.........这里部分代码省略.........
开发者ID:digideskio,项目名称:qmcpack,代码行数:103,代码来源:qmcGUI.py


注:本文中的Geometry.get_lattice_text方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。