Exemple #1
0
    def _createFCMfield(obj):
        # a new field for force_constant_matrix
        doc = lc.document(title='force constant matrix', Class='force-constant-matrix-input-container')
        from luban.content.FormTextField import FormTextField

        # left and right
        sp = doc.splitter()
        left = sp.section(Class='force-constant-matrix')
        right = sp.section(Class='force-constant-matrix-constraints-section')

        # left is grid for the matrix
        grid = lc.grid(); left.add(grid)
        fcm = obj.force_constant_matrix
        for i in range(3):
            gr = grid.row()
            for j in range(3):
                gc = gr.cell()
                v = fcm[i,j]
                w = FormTextField(value=v, name='%s_%s_%s' % ('force_constant_matrix', i, j))
                gc.add(w)
            continue

        # right is the container for constraints
        cdoc = right.document(name='force-constant-matrix-constraints', title='constraints')

        return doc
Exemple #2
0
    def _latticeTable(self, lp):
        "Takes lattice parameters and returns formatted table of lattice structure"
        if not self._output:    # No output
            return NONE

        table    = QEGrid(lc.grid(Class="qe-table-forces"))
        table.addRow(("A", "B", "C", "cosAB", "cosAC", "cosBC"))
        table.addRow(self._fstr(lp))
        table.setRowStyle(0, "qe-table-header-left")
        return table.grid()
Exemple #3
0
    def _latticeTable(self, lp):
        "Takes lattice parameters and returns formatted table of lattice structure"
        if not self._output:  # No output
            return NONE

        table = QEGrid(lc.grid(Class="qe-table-forces"))
        table.addRow(("A", "B", "C", "cosAB", "cosAC", "cosBC"))
        table.addRow(self._fstr(lp))
        table.setRowStyle(0, "qe-table-header-left")
        return table.grid()
Exemple #4
0
    def _setOptimField(self, director, table, form):
        "Special field: Optimization - depends on server"
        # Explain link
        visual_ = "material_simulations/espresso/link-opt"
        explLink = director.retrieveVisual(visual_, form=form)

        localdisk = FormCheckBox(name="localdisk", value=OPT_DEFAULT)

        diskgrid = QEGrid(lc.grid())
        diskgrid.addRow((localdisk, explLink))

        table.addRow(("Optimization:", diskgrid.grid()))
Exemple #5
0
    def _setOptimField(self, director, table, form):
        "Special field: Optimization - depends on server"
        # Explain link
        visual_     = "material_simulations/espresso/link-opt"
        explLink    = director.retrieveVisual(visual_, form=form)

        localdisk       = FormCheckBox(name="localdisk", value = OPT_DEFAULT)

        diskgrid    = QEGrid(lc.grid())
        diskgrid.addRow((localdisk, explLink))


        table.addRow(("Optimization:", diskgrid.grid()))
Exemple #6
0
    def _position(self, poslist):
        "Returns formatted structure of atomic positions"
        # Example: poslist = [('a', [0, 0, 0]), ('b', [1, 1, 1])]
        if not self._output:    # No output
            return NONE

        table    = QEGrid(lc.grid(Class="qe-table-forces"))
        table.addRow(("Atom", "Coordinates"))
        for pl in poslist:
            table.addRow((pl[0], "%.2f, %.2f, %.2f" % (pl[1][0], pl[1][1], pl[1][2])))
        
        table.setRowStyle(0, "qe-table-header-left")
        return table.grid()
Exemple #7
0
    def stress(self):
        "Returns formatted stress"
        if not self._output:    # No output
            return NONE

        stress  = self._outputStress()
        if not stress:          # No stress in the output
            return NONE

        table    = QEGrid(lc.grid(Class="qe-table-stress"))
        for s in stress:
            table.addRow(("%.2f %.2f %.2f" % (s[0], s[1], s[2]) ))

        return table.grid()
Exemple #8
0
    def stress(self):
        "Returns formatted stress"
        if not self._output:  # No output
            return NONE

        stress = self._outputStress()
        if not stress:  # No stress in the output
            return NONE

        table = QEGrid(lc.grid(Class="qe-table-stress"))
        for s in stress:
            table.addRow(("%.2f %.2f %.2f" % (s[0], s[1], s[2])))

        return table.grid()
Exemple #9
0
    def _electronStructure(self, director, section):
        "Electron Structure"

        # output exists
        section.add(lc.paragraph(text="Electron System", Class="qe-section"))
        table = QEGrid(lc.grid(Class="qe-table-analysis"))
        section.add(table.grid())

        table.addRow(('Total Energy:', self._pwresult.totalEnergy(True)))
        table.addRow(('Fermi Energy:', self._pwresult.fermiEnergy(True)))
        table.addRow(("Forces:", self._pwresult.forces()))
        table.addRow(("Stress (Ry/bohr^2):", self._pwresult.stress()))

        table.setColumnStyle(0, "qe-cell-param-analysis")
Exemple #10
0
    def _position(self, poslist):
        "Returns formatted structure of atomic positions"
        # Example: poslist = [('a', [0, 0, 0]), ('b', [1, 1, 1])]
        if not self._output:  # No output
            return NONE

        table = QEGrid(lc.grid(Class="qe-table-forces"))
        table.addRow(("Atom", "Coordinates"))
        for pl in poslist:
            table.addRow(
                (pl[0], "%.2f, %.2f, %.2f" % (pl[1][0], pl[1][1], pl[1][2])))

        table.setRowStyle(0, "qe-table-header-left")
        return table.grid()
Exemple #11
0
    def atomicStructure(self):
        "Atom mass name: mass<number>, atom pseudo potential name: pseudo<number>"
        atoms       = QEGrid(lc.grid(Class="qe-table-atomic"))
        list        = self._atomsList()

        if not list:
            return NONE

        atoms.addRow(("Atom", "Position (bohr)", "Mass (u)", "Pseudo-Potential"))

        for row in list:
            atoms.addRow((row[1], row[2], row[3], row[4]))

        atoms.setRowStyle(0, "qe-table-header-left")
        return atoms.grid()
Exemple #12
0
    def atomicStructure(self):
        "Atom mass name: mass<number>, atom pseudo potential name: pseudo<number>"
        atoms = QEGrid(lc.grid(Class="qe-table-atomic"))
        list = self._atomsList()

        if not list:
            return NONE

        atoms.addRow(
            ("Atom", "Position (bohr)", "Mass (u)", "Pseudo-Potential"))

        for row in list:
            atoms.addRow((row[1], row[2], row[3], row[4]))

        atoms.setRowStyle(0, "qe-table-header-left")
        return atoms.grid()
Exemple #13
0
    def forces(self):
        "Returns formatted force vector for each atom"
        if not self._output:    # No output
            return NONE

        forces  = self._outputForces()
        if not forces:          # No forces in the output
            return NONE
        
        table    = QEGrid(lc.grid(Class="qe-table-forces"))
        table.addRow(("Atom", "Force (Ry/bohr)"))
        
        for f in forces:
            table.addRow((f[1], "%.2f, %.2f, %.2f" % (f[2], f[3], f[4]) ))

        table.setRowStyle(0, "qe-table-header-left")
        return table.grid()
Exemple #14
0
    def forces(self):
        "Returns formatted force vector for each atom"
        if not self._output:  # No output
            return NONE

        forces = self._outputForces()
        if not forces:  # No forces in the output
            return NONE

        table = QEGrid(lc.grid(Class="qe-table-forces"))
        table.addRow(("Atom", "Force (Ry/bohr)"))

        for f in forces:
            table.addRow((f[1], "%.2f, %.2f, %.2f" % (f[2], f[3], f[4])))

        table.setRowStyle(0, "qe-table-header-left")
        return table.grid()
Exemple #15
0
    def taskInfo(self):
        table = QEGrid(lc.grid(Class="qe-tasks-info"))

        if self._task:  # If task exists
            self._setTaskInfo(table)  # Main scenario
            return table.grid()

        # No task created, show link "Create New Task"
        link = lc.link(label="Create New Task",
                       onclick=load(
                           actor='material_simulations/espresso/task-create',
                           routine='createRecord',
                           simid=self._simid,
                           tasktype=self._type,
                           linkorder=self._linkorder))

        table.addRow((link, ))
        #table.addRow(("or", ))                 # Keep
        #table.addRow(("Use Existing Task", ))  # Keep
        return table.grid()
Exemple #16
0
    def tasks(self):
        container   = ""

        simrecord   = SimulationRecord(self._director, self._simid)
        tasklist    = simrecord.taskList()

        if not tasklist:
            return container

        self._types     = simrecord.typeList()
        table           = QEGrid(lc.grid(Class="qe-tasks-table"))
        doshow          = self._showActions(tasklist)  # show "Run Task"?

        for i in range(len(tasklist)):
            rows    = self._list(doshow)
            self._setTaskCell(table, i, tasklist[i], rows)
            if doshow:
                # Special layout for action buttons (e.g. "Run Task")
                table.setCellStyle(2, i, "qe-action-task")

        return table.grid()
Exemple #17
0
    def taskInfo(self):
        table   = QEGrid(lc.grid(Class="qe-tasks-info"))
        
        if self._task:  # If task exists
            self._setTaskInfo(table)    # Main scenario
            return table.grid()


        # No task created, show link "Create New Task"
        link    = lc.link(label="Create New Task",
                          onclick = load(actor      = 'material_simulations/espresso/task-create',
                                         routine    = 'createRecord',
                                         simid      = self._simid,
                                         tasktype   = self._type,
                                         linkorder  = self._linkorder)
                         )

        table.addRow((link, ))
        #table.addRow(("or", ))                 # Keep
        #table.addRow(("Use Existing Task", ))  # Keep
        return table.grid()
Exemple #18
0
    def _createGraphicalViewM(self, ids, director):
        nids = len(ids)
        nrows = (nids + 1) / 2
        doc = lc.document(Class='container')
        grid = lc.grid()
        doc.add(grid)
        for i in range(nrows):
            row = grid.row()

            cell1 = row.cell()
            id = ids[2 * i]
            cell1.add(self._createGraphicalView1(id, director))

            if 2 * i + 1 < nids:
                cell2 = row.cell()
                id = ids[2 * i + 1]
                cell2.add(self._createGraphicalView1(id, director))

            continue

        return doc
Exemple #19
0
    def _summary(self, director, section):
        "System Summary"
        section.add(lc.paragraph(text="System Summary", Class="qe-section"))
        table = QEGrid(lc.grid(Class="qe-table-analysis"))
        section.add(table.grid())

        table.addRow(("Material Type:", self._pwresult.materialType()))
        table.addRow(("Lattice Type:", self._pwresult.latticeType()))
        table.addRow(
            ("Atomic Structure:", self._pwresult.atomicStructure()
             ))  # "# Atom Position (bohr) Mass (u)  Pseudo-Potentials"
        table.addRow(("Energy Cutoff:", self._pwresult.energyCutoff()))
        table.addRow(("Density Cutoff:", self._pwresult.densityCutoff()))
        if self._pwresult.materialType(
        ) == "Metal":  # Parameters specific for metals
            table.addRow(("Smearing Type:",
                          self._pwresult.smearingType()))  # For metals only
            table.addRow(("Smearing Degree:",
                          self._pwresult.smearingDegree()))  # For metals only
        table.addRow(("K points:", self._pwresult.kPoints()))

        table.setColumnStyle(0, "qe-cell-param-analysis")