コード例 #1
0
ファイル: rta.py プロジェクト: jbouquiaux/abipy
    def plot_mobility_kconv(self, eh=0, component='xx', itemp=0, spin=0, fontsize=14, ax=None, **kwargs):
        """
        Plot the convergence of the mobility as a function of the number of k-points.

        Args:
            eh: 0 for electrons, 1 for holes.
            component: Cartesian component to plot ('xx', 'xy', ...)
            itemp: temperature index.
            spin: Spin index.
            fontsize: fontsize for legends and titles
            ax: |matplotlib-Axes| or None if a new figure should be created.

        Returns: |matplotlib-Figure|
        """
        ax, fig, plt = get_ax_fig_plt(ax=ax)
        ax.grid(True)
        i, j = abu.s2itup(component)
        irta = 0

        res, temps = []
        for ncfile in self.abifiles:
            #kptrlattx, kptrlatty, kptrlattz = ncfile.ngkpt
            kptrlatt = ncfile.reader.read_value("kptrlatt")
            kptrlattx = kptrlatt[0, 0]
            kptrlatty = kptrlatt[1, 1]
            kptrlattz = kptrlatt[2, 2]
            # nctkarr_t('mobility_mu',"dp", "three, three, two, ntemp, nsppol, nrta")]
            mobility = ncfile.reader.read_variable("mobility_mu")[irta, spin, itemp, eh, j, i]
            #print(mobility)
            res.append([kptrlattx, mobility])
            temps.append(ncfile.tmesh[itemp])

        res.sort(key=lambda t: t[0])
        res = np.array(res)
        #print(res)

        size = 14
        ylabel = r"%s mobility (cm$^2$/(V$\cdot$s))" % {0: "Electron", 1: "Hole"}[eh]
        ax.set_ylabel(ylabel, size=size)

        #if "title" not in kwargs:
        #    title = r"$\frac{1}{N_k} \sum_{nk} \delta(\epsilon - \epsilon_{nk})$"
        #    ax.set_title(title, fontsize=fontsize)

        from fractions import Fraction
        ratio1 = Fraction(kptrlatty, kptrlattx)
        ratio2 = Fraction(kptrlattz, kptrlattx)
        text1 = '' if ratio1.numerator == ratio1.denominator else \
                r'$\frac{{{0}}}{{{1}}}$'.format(ratio1.numerator, ratio1.denominator)
        text2 = '' if ratio2.numerator == ratio2.denominator else \
                r'$\frac{{{0}}}{{{1}}}$'.format(ratio2.numerator, ratio2.denominator)

        ax.set_xlabel(r'Homogeneous $N_k \times$ ' + text1 + r'$N_k \times$ ' + text2 + r'$N_k$ $\mathbf{k}$-point grid',
                      size=size)

        ax.plot(res[:,0], res[:,1], **kwargs)
        ax.legend(loc="best", shadow=True, fontsize=fontsize)

        return fig
コード例 #2
0
ファイル: transportfile.py プロジェクト: rajeshprasanth/abipy
 def read_mobility(self, eh, itemp, component, spin):
     """
     Read mobility from the TRANSPORT.nc file
     The mobility is computed separately for electrons and holes.
     """
     i,j = abu.s2itup(component)
     wvals = self.read_variable("vvdos_mesh")
     mobility = self.read_variable("mobility")[eh,itemp,i,j,spin,:]
     return wvals, mobility
コード例 #3
0
ファイル: transportfile.py プロジェクト: vishankkumar/abipy
    def plot_mobility_conv(self, eh=0, component='xx', itemp=0, spin=0, fontsize=14, ax=None, **kwargs):
        """
        Plot the convergence of the mobility obtained in a list of files

        Args:
            eh: 0 for electrons, 1 for holes
            component: Component to plot ('xx', 'xy', ...)
            itemp: Index of the temperature.
            spin: Spin index.
            fontsize: fontsize for legends and titles
            ax: |matplotlib-Axes| or None if a new figure should be created.

        Returns: |matplotlib-Figure|
        """
        ax, fig, plt = get_ax_fig_plt(ax=ax)
        ax.grid(True)

        i, j = abu.s2itup(component)

        res = []
        for ncfile in self.abifiles:
            kptrlatt  = ncfile.reader.read_value('kptrlatt')
            kptrlattx = kptrlatt[0, 0]
            kptrlatty = kptrlatt[1, 1]
            kptrlattz = kptrlatt[2, 2]
            #nkpt      = ncfile.nkpt
            mobility  = ncfile.reader.read_value('mobility_mu')[itemp][i,j][spin][eh]
            res.append([kptrlattx, mobility])

        res.sort(key=lambda t: t[0])
        res = np.array(res)

        size = 14
        if eh == 0:
            ax.set_ylabel(r'Electron mobility (cm$^2$/(V$\cdot$s))', size=size)
        elif eh == 1:
            ax.set_ylabel(r'Hole mobility (cm$^2$/(V$\cdot$s))', size=size)
        else:
            raise ValueError("Invalid value for eh argument: %s" % eh)

        from fractions import Fraction
        ratio1 = Fraction(kptrlatty, kptrlattx)
        ratio2 = Fraction(kptrlattz, kptrlattx)
        text1  = '' if ratio1.numerator == ratio1.denominator else \
                 r'$\frac{{{0}}}{{{1}}}$'.format(ratio1.numerator, ratio1.denominator)
        text2  = '' if ratio2.numerator == ratio2.denominator else \
                 r'$\frac{{{0}}}{{{1}}}$'.format(ratio2.numerator, ratio2.denominator)

        ax.set_xlabel(r'Homogeneous $N_k \times$ '+ text1 + r'$N_k \times$ '+ text2 + r'$N_k$ $\mathbf{k}$-point grid',
                      size=size)

        ax.plot(res[:,0], res[:,1], **kwargs)

        ax.legend(loc="best", shadow=True, fontsize=fontsize)

        return fig
コード例 #4
0
ファイル: transportfile.py プロジェクト: vishankkumar/abipy
    def read_mobility(self, eh, itemp, component, spin):
        """
        Read mobility from the TRANSPORT.nc file
        The mobility is computed separately for electrons and holes.
        """
        # nctkarr_t('mobility',"dp", "edos_nw, nsppol, three, three, ntemp, two"), &
        i, j = abu.s2itup(component)
        wvals = self.read_variable("vvdos_mesh")
        mobility = self.read_variable("mobility")[eh,itemp,i,j,spin,:]

        return wvals, mobility
コード例 #5
0
ファイル: rta.py プロジェクト: jbouquiaux/abipy
    def read_mobility(self, eh, itemp, component, spin, irta=0):
        """
        Read mobility from the RTA.nc file
        The mobility is computed separately for electrons and holes.
        """
        # nctkarr_t('mobility',"dp", "three, three, edos_nw, ntemp, two, nsppol, nrta")
        i, j = abu.s2itup(component)
        wvals = self.read_variable("edos_mesh")
        #wvals = self.read_value("edos_mesh") * abu.Ha_eV
        mobility = self.read_variable("mobility")[irta, spin, eh, itemp, :, j, i]

        return wvals, mobility
コード例 #6
0
ファイル: transportfile.py プロジェクト: rajeshprasanth/abipy
 def read_vvdos(self, component='xx', spin=1):
     """
     Read the group velocity density of states
     The vvdos_vals array has 3 dimensions (9,nsppolplus1,nw)
       1. 3x3 components of the tensor
       2. the spin polarization + 1 for the sum
       3. the number of frequencies
     """
     i,j = abu.s2itup(component)
     wmesh = self.read_variable("vvdos_mesh")[:] * abu.Ha_eV
     vals = self.read_variable("vvdos_vals")
     vvdos = vals[i,j,spin,:]
     return wmesh, vvdos
コード例 #7
0
ファイル: rta.py プロジェクト: jbouquiaux/abipy
    def plot_transport_tensors_mu(self, component="xx", spin=0,
                                  what_list=("sigma", "seebeck", "kappa", "pi"),
                                  colormap="jet", fontsize=8, **kwargs):
        """
        Plot selected Cartesian components of transport tensors as a function
        of the chemical potential mu at the given temperature.

        Args:
            ax_list: |matplotlib-Axes| or None if a new figure should be created.
            fontsize: fontsize for legends and titles

        Return: |matplotlib-Figure|
        """
        i, j = abu.s2itup(component)

        num_plots, ncols, nrows, what_list = x2_grid(what_list)
        ax_list, fig, plt = get_axarray_fig_plt(None, nrows=nrows, ncols=ncols,
                                                sharex=True, sharey=False, squeeze=False)
        ax_list = ax_list.ravel()
        # don't show the last ax if numeb is odd.
        if num_plots % ncols != 0: ax_list[-1].axis("off")

        cmap = plt.get_cmap(colormap)

        for iax, (what, ax) in enumerate(zip(what_list, ax_list)):
            irow, icol = divmod(iax, ncols)
            # nctkarr_t('seebeck', "dp", "three, three, edos_nw, ntemp, nsppol, nrta")
            what_var = self.reader.read_variable(what)

            for irta in range(self.nrta):
                for itemp, temp in enumerate(self.tmesh):
                    ys = what_var[irta, spin, itemp, :, j, i]
                    label = "T = %dK" % temp
                    if itemp == 0: label = "%s (%s)" % (label, irta2s(irta))
                    if irta == 0 and itemp > 0: label = None
                    ax.plot(self.edos_mesh_eV, ys, c=cmap(itemp / self.ntemp), label=label, **style_for_irta(irta))

            ax.grid(True)
            ax.set_ylabel(transptens2latex(what, component))

            ax.legend(loc="best", fontsize=fontsize, shadow=True)
            if irow == nrows - 1:
                ax.set_xlabel(r"$\mu$ (eV)")

            self._add_vline_at_bandedge(ax, spin, "both")

        if "title" not in kwargs:
            fig.suptitle("Transport tensors", fontsize=fontsize)

        return fig
コード例 #8
0
ファイル: rta.py プロジェクト: jbouquiaux/abipy
    def plot_vvtau_dos(self, component="xx", spin=0, ax=None, colormap="jet", fontsize=8, **kwargs):
        r"""
        Plot (v_i * v_j * tau) DOS.

            $\frac{1}{N_k} \sum_{nk} v_i v_j \delta(\epsilon - \epsilon_{nk})$

        Args:
            component: Cartesian component to plot: "xx", "yy" "xy" ...
            ax: |matplotlib-Axes| or None if a new figure should be created.
            colormap: matplotlib colormap.
            fontsize (int): fontsize for titles and legend

        Return: |matplotlib-Figure|
        """
        i, j = abu.s2itup(component)

        ax, fig, plt = get_ax_fig_plt(ax=ax)
        cmap = plt.get_cmap(colormap)

        for irta in range(self.nrta):
            # nctkarr_t('vvtau_dos', "dp", "edos_nw, three, three, ntemp, nsppol, nrta")
            var = self.reader.read_variable("vvtau_dos")
            for itemp, temp in enumerate(self.tmesh):
                vvtau_dos = var[irta, spin, itemp, j, i, :] / (2 * abu.Ha_s)
                label = "T = %dK" % temp
                if (itemp == 0): label = "%s (%s)" % (label, irta2s(irta))
                if (irta == 0 and itemp > 0): label = None
                ax.plot(self.edos_mesh_eV, vvtau_dos, c=cmap(itemp / self.ntemp), label=label, **style_for_irta(irta))

                # This to plot the vv dos along without tau
                #if itemp == 1:
                #    # nctkarr_t('vv_dos', "dp", "edos_nw, three, three, nsppol"), &
                #    vv_dos_var = self.reader.read_variable("vv_dos")
                #    vv_dos = vv_dos_var[spin, j, i] # / (2 * abu.Ha_s)
                #    ax.plot(self.edos_mesh_eV, vv_dos, c=cmap(itemp / self.ntemp), label='VVDOS' % temp)

        self._add_vline_at_bandedge(ax, spin, "both")

        ax.grid(True)
        ax.set_xlabel('Energy (eV)')
        ax.set_ylabel(r'$v_{%s} v_{%s} \tau$ DOS' % (component[0], component[1]))
        ax.set_yscale('log')
        ax.legend(loc="best", shadow=True, fontsize=fontsize)

        if "title" not in kwargs:
            vvt = r'v_{%s} v_{%s} \tau' % (component[0], component[1])
            title = r"$\frac{1}{N_k} \sum_{nk} %s\,\delta(\epsilon - \epsilon_{nk})$" % vvt
            fig.suptitle(title, fontsize=fontsize)

        return fig
コード例 #9
0
ファイル: transportfile.py プロジェクト: rajeshprasanth/abipy
 def read_vvdos_tau(self, itemp, component='xx', spin=1):
     """
     Read the group velocity density of states times lifetime for different temperatures
     The vvdos_tau array has 4 dimensions (ntemp,9,nsppolplus1,nw)
       1. the number of temperatures
       2. 3x3 components of the tensor
       3. the spin polarization + 1 for the sum
       4. the number of frequencies
     """
     i, j = abu.s2itup(component)
     wmesh = self.read_variable("vvdos_mesh")[:] * abu.Ha_eV
     vals = self.read_variable("vvdos_tau")
     vvdos_tau = vals[itemp,i,j,spin,:] / (2 * abu.Ha_s)
     return wmesh, vvdos_tau
コード例 #10
0
ファイル: rta.py プロジェクト: vishankkumar/abipy
    def plot_mobility(self,
                      eh=0,
                      irta=0,
                      component='xx',
                      spin=0,
                      ax=None,
                      colormap='jet',
                      fontsize=8,
                      yscale="log",
                      **kwargs):
        """
        Read the mobility from the netcdf file and plot it

        Args:
            component: Component to plot: "xx", "yy" "xy" ...
            ax: |matplotlib-Axes| or None if a new figure should be created.
            colormap: matplotlib colormap.
            fontsize (int): fontsize for titles and legend

        Return: |matplotlib-Figure|
        """
        ax, fig, plt = get_ax_fig_plt(ax=ax)
        cmap = plt.get_cmap(colormap)

        # nctkarr_t('mobility',"dp", "three, three, edos_nw, ntemp, two, nsppol, nrta")
        mu_var = self.reader.read_variable("mobility")
        i, j = abu.s2itup(component)

        for irta in range(self.nrta):
            for itemp, temp in enumerate(self.tmesh):
                mu = mu_var[irta, spin, eh, itemp, :, j, i]
                label = "T = %dK" % temp
                if (itemp == 0): label = "%s (%s)" % (label, irta2s(irta))
                if (irta == 0 and itemp > 0): label = None
                ax.plot(self.edos_mesh_eV,
                        mu,
                        c=cmap(itemp / self.ntemp),
                        label=label,
                        **style_for_irta(irta))

        self._add_vline_at_bandedge(ax, spin, "cbm" if eh == 0 else "vbm")

        ax.grid(True)
        ax.set_xlabel('Fermi level (eV)')
        ax.set_ylabel(r'%s-mobility $\mu_{%s}(\epsilon_F)$ (cm$^2$/Vs)' %
                      (eh2s(eh), component))
        ax.set_yscale(yscale)
        ax.legend(loc="best", shadow=True, fontsize=fontsize)

        return fig
コード例 #11
0
    def read_vvdos_tau(self, itemp, component='xx', spin=1):
        """
        Read the group velocity density of states
        The vvdos_vals array has 3 dimensions (3, 3, nsppolplus1, nw)

          1. 3x3 components of the tensor
          2. the spin polarization + 1 for the sum
          3. the number of frequencies
        """
        # nctkarr_t('vvdos_tau', "dp", "edos_nw, nsppol_plus1, three, three, ntemp"), &
        i, j = abu.s2itup(component)
        wmesh = self.read_variable("vvdos_mesh")[:] * abu.Ha_eV
        vals = self.read_variable("vvdos_tau")
        vvdos_tau = vals[itemp, i, j, spin, :] / (2 * abu.Ha_s)

        return wmesh, vvdos_tau