Esempio n. 1
0
    def to_string(self, verbose=0):
        """
        Human-readable string with useful information on the object.

        Args:
            verbose: Verbosity level.
        """
        lines = []; app = lines.append

        app(self.structure.to_string(verbose=verbose, title="Structure"))
        app("")
        app(marquee(r"Fullfilment of \int dw g_ij(w) = \delta_ij", mark="="))
        app("")
        from scipy.integrate import simps
        for iatom, site in enumerate(self.structure):
            d = simps(self.values[iatom], x=self.wmesh)
            app("For site: %s" % site)
            app(str(d))
            app("Trace: %.4f, determinant: %.4f" % (d.trace(), np.linalg.det(d)))
            app("")

        for fmt in ("cartesian", "cif"):
            df = self.get_dataframe(temp=300, view="inequivalent", fmt=fmt, verbose=verbose)
            s = print_dataframe(df, title="Format: %s" % fmt, file="string")
            lines.extend(s.splitlines())

        title = marquee("Constraints on tensor components in reduced coords induced by site symmetries", mark="=")
        s = print_dataframe(self.structure.site_symmetries.get_tensor_rank2_dataframe(), file="string", title=title)
        lines.extend(s.splitlines())

        #if verbose > 1:
            #max_err = self.check_site_symmetries(verbose=verbose)

        return "\n".join(lines)
Esempio n. 2
0
    def to_string(self, verbose=0, title=None):
        """String representation."""
        lines = []
        app = lines.append
        if title is not None: app(marquee(title, mark="="))

        app(marquee("File Info", mark="="))
        app(self.filestat(as_string=True))
        app("")
        app(
            self.initial_structure.to_string(verbose=verbose,
                                             title="Initial Structure"))
        app("")
        app("Number of relaxation steps performed: %d" % self.num_steps)
        app(
            self.final_structure.to_string(verbose=verbose,
                                           title="Final structure"))
        app("")

        an = self.get_relaxation_analyzer()
        app("Volume change in percentage: %.2f%%" %
            (an.get_percentage_volume_change() * 100))
        d = an.get_percentage_lattice_parameter_changes()
        vals = tuple(d[k] * 100 for k in ("a", "b", "c"))
        app("Percentage lattice parameter changes:\n\ta: %.2f%%, b: %.2f%%, c: %2.f%%"
            % vals)
        #an.get_percentage_bond_dist_changes(max_radius=3.0)
        app("")

        cart_stress_tensors, pressures = self.reader.read_cart_stress_tensors()
        app("Stress tensor (Cartesian coordinates in Ha/Bohr**3):\n%s" %
            cart_stress_tensors[-1])
        app("Pressure: %.3f [GPa]" % pressures[-1])

        return "\n".join(lines)
Esempio n. 3
0
    def to_string(self, verbose=0):
        """String representation"""
        lines = []
        app = lines.append

        app(marquee("File Info", mark="="))
        app(self.filestat(as_string=True))
        app("")
        app(self.structure.to_string(verbose=verbose, title="Structure"))
        app("")
        app(
            self.ebands.to_string(with_structure=False,
                                  verbose=verbose,
                                  title="KS Electron Bands"))
        app("")

        # Transport section.
        app(marquee("Transport calculation", mark="="))
        app("Number of temperatures: %d" % self.ntemp)
        app("Mobility:")
        app("Temperature [K]     Electrons [cm^2/Vs]     Holes [cm^2/Vs]")
        for itemp in range(self.ntemp):
            temp = self.tmesh[itemp]
            mobility_mu_e = self.get_mobility_mu(0, itemp)
            mobility_mu_h = self.get_mobility_mu(1, itemp)
            app("%14.1lf %18.6lf %18.6lf" %
                (temp, mobility_mu_e, mobility_mu_h))

        return "\n".join(lines)
Esempio n. 4
0
    def to_string(self, verbose=0):
        """String representation."""
        lines = []; app = lines.append

        app(marquee("File Info", mark="="))
        app(self.filestat(as_string=True))
        app("")
        app(self.structure.to_string(verbose=verbose, title="Structure"))
        app("")
        app(self.ebands.to_string(with_structure=False, verbose=verbose, title="KS Electron Bands"))
        app("")

        # Transport section.
        app(marquee("Transport calculation", mark="="))
        app("")
        #app("edos_intmeth: %d" % self.edos_intmeth)
        #app("edos_broad: %d (meV): " % (self.edos_broad * 1000))
        app(edos_infos(self.edos_intmeth, self.edos_broad))
        app("mesh step for energy integrals: %.1f (meV) " % ((self.edos_mesh_eV[1] - self.edos_mesh_eV[0]) * 1000))
        app("")

        components = ("xx", "yy", "zz") if verbose == 0 else ("xx", "yy", "zz", "xy", "xz", "yx")
        for component in components:
            for irta in range(self.nrta):
                app("Mobility (%s Cartesian components), RTA type: %s" % (component, irta2s(irta)))
                app("Temperature [K]     Electrons (cm^2/Vs)     Holes (cm^2/Vs)")
                for itemp in range(self.ntemp):
                    temp = self.tmesh[itemp]
                    mobility_mu_e = self.get_mobility_mu(eh=0, itemp=itemp, component=component, irta=irta)
                    mobility_mu_h = self.get_mobility_mu(eh=1, itemp=itemp, component=component, irta=irta)
                    app("%14.1lf %18.6lf %18.6lf" % (temp, mobility_mu_e, mobility_mu_h))
                app("")

        return "\n".join(lines)
Esempio n. 5
0
    def to_string(self, verbose=0):
        """String representation."""
        lines = []; app = lines.append

        app(marquee("File Info", mark="="))
        app(self.filestat(as_string=True))
        app("")
        app(self.structure.to_string(verbose=verbose, title="Structure"))
        app("")
        app(self.ebands.to_string(with_structure=False, title="Electronic Bands"))

        app(marquee("Optic calculation", mark="="))
        # Show Optic variables.
        app("broadening: %s [Ha], %.3f (eV)" % (self.broadening, self.broadening * abu.Ha_eV))
        app("scissor: %s [Ha], %.3f (eV)" % (self.scissor, self.scissor * abu.Ha_eV))
        app("tolerance: %s [Ha], %.3f (eV)" % (self.tolerance, self.tolerance * abu.Ha_eV))
        app("maxomega: %s [Ha], %.3f (eV)" % (self.maxomega, self.maxomega * abu.Ha_eV))
        app("domega: %s [Ha], %.3f (eV)" % (self.domega, self.domega * abu.Ha_eV))
        app("do_antiresonant %s, do_ep_renorm %s" % (self.do_antiresonant, self.do_ep_renorm))
        app("Number of temperatures: %d" % self.reader.ntemp)

        # Show available tensors and computed components.
        for key, info in ALL_CHIS.items():
            if not self.reader.computed_components[key]: continue
            app("%s components computed: %s" % (
                info["longname"], ", ".join(self.reader.computed_components[key])))

        if verbose > 1:
            app(marquee("Abinit Header", mark="="))
            app(self.hdr.to_string(verbose=verbose))

        return "\n".join(lines)
Esempio n. 6
0
    def to_string(self, verbose=0):
        """String representation with verbosity level verbose."""
        lines = []; app = lines.append

        app(marquee("File Info", mark="="))
        app(self.filestat(as_string=True))
        app("")
        app(self.structure.to_string(verbose=verbose, title="Structure"))
        app("")
        app(self.ebands.to_string(title="Electronic Bands", with_structure=False, with_kpoints=True, verbose=verbose))
        app("")
        app(marquee("Wannier90 Results", mark="="))

        for spin in range(self.nsppol):
            if self.nsppol == 2: app("For spin: %d" % spin)
            app("No of Wannier functions: %d, No bands: %d, Number of k-point neighbours: %d" %
                (self.nwan_spin[spin], self.num_bands_spin[spin], self.nntot))
            app("Disentanglement: %s, exclude_bands: %s" %
                (self.have_disentangled_spin[spin], "no" if np.all(self.bands_in[spin]) else "yes"))
            app("")
            table = [["WF_index", "Center", "Spread"]]
            for iwan in range(self.nwan_spin[spin]):
                table.append([iwan,
                             "%s" % np.array2string(self.wann_centers[spin, iwan], precision=5),
                             "%.3f" % self.wann_spreads[spin, iwan]])
            app(tabulate(table, tablefmt="plain"))
            app("")

        if verbose and np.any(self.have_disentangled_spin):
            app(marquee("Lwindow", mark="="))
            app("[nsppol, nkpt, max_num_bands] array. True if state lies within the outer window.\n")
            for spin in range(self.nsppol):
                if self.nsppol == 2: app("For spin: %d" % spin)
                for ik in range(self.nkpt):
                    app("For ik: %d, %s" % (ik, self.lwindow[spin, ik]))
                app("")

        if verbose and np.any(self.bands_in):
            app(marquee("Bands_in", mark="="))
            app("[nsppol, mband] array. True if (spin, band) is included in the calculation. Set by exclude_bands.\n")
            for spin in range(self.nsppol):
                if self.nsppol == 2: app("For spin: %d" % spin)
                app("%s" % str(self.bands_in[spin]))
                app("")

        if verbose > 1:
            app("")
            app(self.hdr.to_string(verbose=verbose, title="Abinit Header"))
            #app("irvec and ndegen")
            #for r, n in zip(self.irvec, self.ndegen):
            #    app("%s %s" % (r, n))

        return "\n".join(lines)
Esempio n. 7
0
    def to_string(self, verbose=0):
        """String representation."""
        lines = []
        app = lines.append

        app(marquee("File Info", mark="="))
        app(self.filestat(as_string=True))
        app("")
        app(self.structure.to_string(verbose=verbose, title="Structure"))
        app("")
        app("Wannier90 version: %s" % self.version)
        app("Number of Wannier functions: %d" % self.nwan)
        app("K-grid: %s" % self.grid_size)
        if self.use_disentangle:
            app("Using DISENTANGLE algorithm")
            #for k, v in self.params_section["DISENTANGLE"].items():
            #    app("%s: %s" % (k, v))
        app("")

        if self.dis_df is not None:
            # Print first and last n cycles.
            app(marquee("DISENTANGLE", mark="="))
            n = 5 if not verbose else 20
            if len(self.dis_df) > 2 * n:
                app(
                    pd.concat([self.dis_df.head(n),
                               self.dis_df.tail(n)]).to_string(index=False))
            else:
                app(self.dis_df.to_string(index=False))
            app("")

        if self.conv_df is not None:
            # Print first and last n cycles.
            app(marquee("WANNIERISE", mark="="))
            n = 5 if not verbose else 20
            if len(self.conv_df) > 2 * n:
                app(
                    pd.concat([self.conv_df.head(n),
                               self.conv_df.tail(n)]).to_string(index=False))
            else:
                app(self.conv_df.to_string(index=False))
            app("")

        if self.warnings:
            app("Found %d warnings in output file:" % len(self.warnings))
            for i, w in enumerate(self.warnings):
                app("[%d] %s" % (i, w))

        #if verbose:

        return "\n".join(lines)
Esempio n. 8
0
    def to_string(self, verbose=0):
        """String representation."""
        lines = []
        app = lines.append

        app(marquee("File Info", mark="="))
        app(self.filestat(as_string=True))
        app("")
        app(self.structure.to_string(title="Structure"))

        app(marquee("Q-points", mark="="))
        app(str(self.qpoints))

        return "\n".join(lines)
Esempio n. 9
0
    def to_string(self):
        lines = []
        app, extend = lines.append, lines.extend
        #extend(super(DdbFile, self).__str__().splitlines())

        app(marquee("File Info", mark="="))
        app(self.filestat(as_string=True))
        app("")
        app(marquee("Structure", mark="="))
        app(str(self.structure))

        app(marquee("Q-points", mark="="))
        app(str(self.qpoints))
        app("guessed_ngqpt: %s" % self.guessed_ngqpt)

        return "\n".join(lines)
Esempio n. 10
0
    def __init__(self, parent, phbst, **kwargs):
        """
        Args:
            parent:
                parent window.
            phbst:
                `PhbstFile` instance.
        """
        super(PhbstFileTab, self).__init__(parent, -1, **kwargs)
        self.phbst = phbst
        self.phdos_file = None

        splitter = wx.SplitterWindow(self, id=-1, style=wx.SP_3D)
        splitter.SetSashGravity(0.95)

        self.qpoints_panel = KpointsPanel(splitter, phbst.structure, phbst.qpoints)

        # Add Python shell
        msg = "PHBST_File object is accessible via the phbst variable. Use phbst.<TAB> to access the list of methods."
        msg = marquee(msg, width=len(msg) + 8, mark="#")
        msg = "#"*len(msg) + "\n" + msg + "\n" + "#"*len(msg) + "\n"

        pyshell = Shell(splitter, introText=msg, locals={"phbst": self.phbst})
        splitter.SplitHorizontally(self.qpoints_panel, pyshell)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(splitter, 1, wx.EXPAND, 5)
        self.SetSizerAndFit(sizer)
Esempio n. 11
0
    def to_string(self, verbose=0):
        """String representation."""
        lines = []; app = lines.append

        app(marquee("File Info", mark="="))
        app(self.filestat(as_string=True))
        app("")
        app(self.structure.to_string(verbose=verbose, title="Structure"))
        app("")
        app(self.ebands.to_string(with_structure=False, verbose=verbose, title="Electronic Bands"))
        app("qpoint: %s" % str(self.qpoint))
        app("Macroscopic dielectric tensor in Cartesian coordinates")
        app(str(self.epsinf_cart))
        app("")
        app("Born effective charges in Cartesian coordinates:")
        for i, (site, bec) in enumerate(zip(self.structure, self.becs_cart)):
            app("[%d]: %s" % (i, repr(site)))
            app(str(bec))
            app("")

        app(r"Fulfillment of charge neutrality, F_{ij} = \sum_{atom} Z^*_{ij,atom}")
        f = np.sum(self.becs_cart, axis=0)
        app(str(f) + "\n")

        return "\n".join(lines)
Esempio n. 12
0
    def print_results(self, fmt="abivars", verbose=0, file=sys.stdout):
        """
        Print pandas dataframe, structures using format `fmt`, and data to file `file`.
        `fmt` is automaticall set to `cif` if structure is disordered.
        Set fmt to None or empty string to disable structure output.
        """
        print("\n# Found %s structures in %s database (use `verbose` to get further info)\n"
                % (len(self.structures), self.dbname), file=file)

        if self.dataframe is not None: print_dataframe(self.dataframe, file=file)
        if verbose and self.data is not None: pprint(self.data, stream=file)

        # Print structures
        print_structures = not (fmt is None or str(fmt) == "None")
        if print_structures:
            for i, structure in enumerate(self.structures):
                print(" ", file=file)
                print(marquee("%s input for %s" % (fmt, self.ids[i]), mark="#"), file=file)
                print("# " + structure.spget_summary(verbose=verbose).replace("\n", "\n# ") + "\n", file=file)
                if not structure.is_ordered:
                    print(structure.convert(fmt="cif"), file=file)
                else:
                    print(structure.convert(fmt=fmt), file=file)
                print(2 * "\n", file=file)

        if len(self.structures) > 10:
            # Print info again
            print("\n# Found %s structures in %s database (use `verbose` to get further info)\n"
                    % (len(self.structures), self.dbname), file=file)
Esempio n. 13
0
    def __init__(self, parent, gsr, **kwargs):
        """
        Args:
            parent:
                parent window.
            gsr:
                `GsrFile` instance.
        """
        super(GsrFileTab, self).__init__(parent, -1, **kwargs)
        self.gsr = gsr

        splitter = wx.SplitterWindow(self, id=-1, style=wx.SP_3D)
        splitter.SetSashGravity(0.95)

        self.kpoints_panel = KpointsPanel(splitter, gsr.structure, gsr.kpoints)

        # Add Python shell
        msg = "GSR_File object is accessible via the gsr variable. Use gsr.<TAB> to access the list of methods."
        msg = marquee(msg, width=len(msg) + 8, mark="#")
        msg = "#" * len(msg) + "\n" + msg + "\n" + "#" * len(msg) + "\n"

        pyshell = Shell(splitter, introText=msg, locals={"gsr": self.gsr})
        splitter.SplitHorizontally(self.kpoints_panel, pyshell)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(splitter, 1, wx.EXPAND, 5)
        self.SetSizerAndFit(sizer)
Esempio n. 14
0
    def to_string(self, verbose=0):
        """String representation."""
        lines = []
        app = lines.append

        app(marquee("File Info", mark="="))
        app(self.filestat(as_string=True))
        app("")
        app(self.structure.to_string(verbose=verbose, title="Structure"))
        if self.is_scf_run:
            app("")
            app("Stress tensor (Cartesian coordinates in GPa):\n%s" %
                self.cart_stress_tensor)
            #if verbose:
            #    app("Stress tensor (Cartesian coordinates in Ha/Bohr**3):\n%s" % self.cart_stress_tensor / abu.HaBohr3_GPa)
            app("")
            app("Pressure: %.3f (GPa)" % self.pressure)
            app("Energy: %.8f (eV)" % self.energy)
        app("")
        app(
            self.ebands.to_string(with_structure=False,
                                  verbose=verbose,
                                  title="Electronic Bands"))

        if verbose > 1:
            app("")
            app(self.hdr.to_string(verbose=verbose, title="Abinit Header"))

        return "\n".join(lines)
Esempio n. 15
0
    def __init__(self, parent, wfk, **kwargs):
        """
        Args:
            parent:
                parent window.
            wfk:
        """
        super(WfkFileTab, self).__init__(parent, -1, **kwargs)
        self.wfk = wfk

        splitter = wx.SplitterWindow(self, id=-1, style=wx.SP_3D)
        splitter.SetSashGravity(0.95)

        self.skb_panel = skb_panel = SpinKpointBandPanel(
            splitter, wfk.structure, wfk.nsppol, wfk.kpoints, wfk.mband)

        # Set the callback for double click on k-point row..
        self.Bind(skb_panel.MYEVT_SKB_ACTIVATED, self.onVisualizeSKB)

        # Add Python shell
        msg = "WFK_File object is accessible via the wfk variable. Use wfk.<TAB> to access the list of methods."
        msg = marquee(msg, width=len(msg) + 8, mark="#")
        msg = "#" * len(msg) + "\n" + msg + "\n" + "#" * len(msg) + "\n"

        # FIXME <Error>: CGContextRestoreGState: invalid context 0x0
        pyshell = Shell(splitter, introText=msg, locals={"wfk": self.wfk})
        splitter.SplitHorizontally(self.skb_panel, pyshell)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(splitter, 1, wx.EXPAND, 5)
        self.SetSizerAndFit(sizer)
Esempio n. 16
0
    def __init__(self, parent, sigres, **kwargs):
        """
        Args:
            parent:
                parent window.
            sigres:
                `SigresFile` object
        """
        super(SigresFileTab, self).__init__(parent, -1, **kwargs)
        self.sigres = sigres

        splitter = wx.SplitterWindow(self, style=wx.SP_LIVE_UPDATE)
        splitter.SetSashGravity(0.95)

        self.skb_panel = SpinKpointBandPanel(splitter, sigres.structure, sigres.nsppol, sigres.gwkpoints, sigres.max_gwbstop,
                                             bstart=sigres.min_gwbstart)

        # Set the callback for double click on k-point row..
        self.Bind(self.skb_panel.MYEVT_SKB_ACTIVATED, self.onShowQPTable)

        # Add Python shell
        msg = "SIGRES_File object is accessible via the sigres variable. Use sigres.<TAB> to access the list of methods."
        msg = marquee(msg, width=len(msg) + 8, mark="#")
        msg = "#"*len(msg) + "\n" + msg + "\n" + "#"*len(msg) + "\n"

        pyshell = Shell(splitter, introText=msg, locals={"sigres": sigres})
        splitter.SplitHorizontally(self.skb_panel, pyshell)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(splitter, 1, wx.EXPAND, 5)
        self.SetSizerAndFit(sizer)
Esempio n. 17
0
    def to_string(self, verbose=0):
        """String representation."""
        lines = []
        app = lines.append

        app(marquee("File Info", mark="="))
        app(self.filestat(as_string=True))
        app("")
        app(self.structure.to_string(verbose=verbose, title="Structure"))
        app("")
        app(
            self.ebands.to_string(with_structure=False,
                                  title="Electronic Bands"))

        app("Direct lattice of the primitive cell:")
        to_s = lambda x: "%0.6f" % x
        app("abc   : " +
            " ".join([to_s(i).rjust(10) for i in self.pc_lattice.abc]))
        app("angles: " +
            " ".join([to_s(i).rjust(10) for i in self.pc_lattice.angles]))
        if is_diagonal(self.fold_matrix):
            app("Diagonal folding: %s" % (str(np.diagonal(self.fold_matrix))))
        else:
            app("Folding matrix: %s" % str(self.fold_matrix))

        if verbose:
            app(
                self.uf_kpoints.to_string(verbose=verbose,
                                          title="Unfolded k-points"))

        if verbose > 2:
            app(self.hdr.to_string(verbose=verbose, title="Abinit Header"))

        return "\n".join(lines)
Esempio n. 18
0
    def __init__(self, parent, mdf_file, **kwargs):
        """
        Args:
            parent:
                parent window.
            mdf_file:
        """
        super(MdfFileTab, self).__init__(parent, -1, **kwargs)
        self.mdf_file = mdf_file

        splitter = wx.SplitterWindow(self, id=-1, style=wx.SP_3D)
        splitter.SetSashGravity(0.95)

        self.qpoints_panel = MdfQpointsPanel(splitter, mdf_file)

        # Add Python shell
        msg = "MDF_object is accessible via the mdf_file variable. Use mdf_file.<TAB> to access the list of methods."
        msg = marquee(msg, width=len(msg) + 8, mark="#")
        msg = "#" * len(msg) + "\n" + msg + "\n" + "#" * len(msg) + "\n"

        # FIXME <Error>: CGContextRestoreGState: invalid context 0x0
        pyshell = Shell(splitter, introText=msg, locals={"mdf_file": mdf_file})
        splitter.SplitHorizontally(self.qpoints_panel, pyshell)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(splitter, 1, wx.EXPAND, 5)
        self.SetSizerAndFit(sizer)
Esempio n. 19
0
File: scr.py Progetto: zbwang/abipy
    def to_string(self, verbose=0):
        """String representation."""
        lines = []
        app = lines.append

        app(marquee("File Info", mark="="))
        app(self.filestat(as_string=True))
        app("")
        app(self.structure.to_string(verbose=verbose, title="Structure"))
        app("")
        # TODO: Fix problem with efermi
        #app(self.ebands.to_string(with_structure=False, title="Electronic Bands"))
        app(
            self.kpoints.to_string(verbose=verbose,
                                   title="K-points for screening function"))
        app("")
        app("Number of G-vectors in screening matrices: %d" % self.ng)
        app("Number of frequencies: %d (real: %d, imaginary: %d)" %
            (self.nw, self.nrew, self.nimw))

        if verbose:
            app(str(self.params))

        if verbose > 1:
            app("")
            app(self.hdr.to_string(verbose=verbose, title="Abinit Header"))

        return "\n".join(lines)
Esempio n. 20
0
    def to_string(self):
        """Return string representation."""
        lines = []; app = lines.append

        app(marquee("File Info", mark="="))
        app(self.filestat(as_string=True))
        app("")
        app(marquee("Final structure", mark="="))
        app("Number of relaxation steps performed: %d" % self.num_steps)
        app(str(self.final_structure))
        app("")

        cart_stress_tensors, pressures = self.reader.read_cart_stress_tensors()
        app("Stress tensor (Cartesian coordinates in Ha/Bohr**3):\n%s" % cart_stress_tensors[-1])
        app("Pressure: %.3f [GPa]" % pressures[-1])

        return "\n".join(lines)
Esempio n. 21
0
    def to_string(self):
        """Return string representation."""
        lines = []
        app = lines.append

        app(marquee("File Info", mark="="))
        app(self.filestat(as_string=True))
        app("")
        app(marquee("Structure", mark="="))
        app(str(self.structure))
        app("")
        app(
            self.ebands.to_string(with_structure=False,
                                  title="Electronic Bands"))
        app("XC functional: %s" % str(self.xc))

        return "\n".join(lines)
Esempio n. 22
0
    def to_string(self):
        lines = []
        app = lines.append

        app(marquee("File Info", mark="="))
        app(self.filestat(as_string=True))
        app("")
        app(marquee("Structure", mark="="))
        app(str(self.structure))
        app("")
        app(marquee("Q-points", mark="="))
        app(str(self.qpoints))
        app("")
        #app("  Number of G-vectors: %d" % self.ng)
        #app("  Number of frequencies: %d (real:%d, imag%d)" % (self.nw, self.nrew, self.nimw))

        return "\n".join(lines)
Esempio n. 23
0
    def to_string(self, verbose=0):
        """String representation."""
        lines = [
            "ndtset: %d, completed: %s" % (self.ndtset, self.run_completed)
        ]
        app = lines.append

        # Different cases depending whether final structures are available
        # and whether structures are equivalent.
        if self.run_completed:
            if self.has_same_final_structures:
                if self.initial_structure != self.final_structure:
                    # Structural relaxation.
                    df = dataframes_from_structures(
                        [self.initial_structure, self.final_structure],
                        index=["initial", "final"])
                    app("Lattice parameters:")
                    app(str(df.lattice))
                    app("Atomic coordinates:")
                    app(str(df.coords))
                else:
                    # initial == final. Print final structure.
                    app(self.final_structure.to_string(verbose=verbose))
        else:
            # Final structures are not available.
            if self.has_same_initial_structures:
                app(self.initial_structure.to_string(verbose=verbose))
            else:
                df = dataframes_from_structures(
                    self.initial_structures,
                    index=[i + 1 for i in range(self.ndtset)])
                app("Lattice parameters:")
                app(str(df.lattice))
                app("Atomic coordinates:")
                app(str(df.coords))

        # Print dataframe with dimensions.
        dims_dataset, spginfo_dataset = self.get_dims_spginfo_dataset(
            verbose=verbose)
        rows = []
        for dtind, dims in dims_dataset.items():
            d = OrderedDict()
            d["dataset"] = dtind
            d.update(dims)
            d.update(spginfo_dataset[dtind])
            rows.append(d)

        from abipy.tools.printing import print_dataframe
        df = pd.DataFrame(rows, columns=list(rows[0].keys()) if rows else None)
        df = df.set_index('dataset')
        strio = cStringIO()
        print_dataframe(df, file=strio)
        strio.seek(0)
        app("")
        app(marquee("Dimensions of calculation", mark="="))
        app("".join(strio))

        return "\n".join(lines)
Esempio n. 24
0
File: ddk.py Progetto: zbwang/abipy
    def to_string(self, verbose=0):
        """String representation."""
        lines = []; app = lines.append

        app(marquee("File Info", mark="="))
        app(self.filestat(as_string=True))
        app("")
        app(self.structure.to_string(verbose=verbose, title="Structure"))
        app("")
        app(self.ebands.to_string(with_structure=False, title="Electronic Bands"))
        app(marquee("DDK perturbation", mark="="))
        app("idir: {}, ipert: {}, kptopt: {}".format(self.idir, self.ipert, self.kptopt))

        if verbose > 1:
            app("")
            app(self.hdr.to_string(verbose=verbose, title="Abinit Header"))

        return "\n".join(lines)
Esempio n. 25
0
    def to_string(self, **kwargs):
        """String representation."""
        lines = []
        app = lines.append

        for label, mdf_dict in self._mdfs.items():
            app(marquee(label, mark="="))
            for mdf_type, mdf in mdf_dict.items():
                app("%s: %s" % (mdf_type, mdf.to_string(**kwargs)))

        return "\n".join(lines)
Esempio n. 26
0
    def to_string(self):
        lines = []
        app = lines.append

        app(marquee("File Info", mark="="))
        app(self.filestat(as_string=True))
        app("")
        app(marquee("Structure", mark="="))
        app(str(self.structure))
        if self.is_scf_run:
            app("")
            app("Stress tensor (Cartesian coordinates in Ha/Bohr**3):\n%s" %
                self.cart_stress_tensor)
            app("Pressure: %.3f [GPa]" % self.pressure)
        app("")
        app(
            self.ebands.to_string(with_structure=False,
                                  title="Electronic Bands"))

        return "\n".join(lines)
Esempio n. 27
0
    def to_string(self, verbose=0):
        """String representation."""
        lines = []; app = lines.append
        app(marquee("File Info", mark="="))
        app(self.filestat(as_string=True))
        app("")
        app(self.structure.to_string(verbose=verbose, title="Structure"))
        app("")
        for iq, qpt in enumerate(self.qpoints):
            app("[%d] %s" % (iq, repr(qpt)))

        return "\n".join(lines)
Esempio n. 28
0
    def to_string(self, verbose=0):
        """String representation."""
        lines = []
        app = lines.append
        app(marquee("File Info", mark="="))
        app(self.filestat(as_string=True))
        app("")
        app(self.structure.to_string(verbose=verbose, title="Structure"))
        app("")
        app("symv1scf: %s" % self.symv1scf)

        return "\n".join(lines)
Esempio n. 29
0
    def to_string(self, verbose=0):
        """String representation."""
        lines = []; app = lines.append

        app(marquee("File Info", mark="="))
        app(self.filestat(as_string=True))
        app("")
        app(self.structure.to_string(verbose=verbose, title="Structure"))
        app("")
        app(self.ebands.to_string(with_structure=False, title="Electronic Bands"))
        app("XC functional: %s" % str(self.xc))

        # Add info on the field
        app(marquee(self.field.__class__.__name__, mark="="))
        app(str(self.field))

        if verbose > 1:
            app("")
            app(self.hdr.to_string(verbose=verbose, title="Abinit Header"))

        return "\n".join(lines)
Esempio n. 30
0
    def to_string(self, verbose=0, title=None, **kwargs):
        """
        String representation. kwargs are passed to `pprint.pformat`.

        Args:
            verbose: Verbosity level
            title: Title string.
        """
        from pprint import pformat
        s = pformat(self, **kwargs)
        if title is not None:
            return "\n".join([marquee(title, mark="="), s])
        return s