示例#1
0
def showElectronDosFrame(parent, filepath):
    """
    Read the electron bands from file filepath and shows an `ElectronDosFrame`.
    """
    bands = ElectronBands.from_file(filepath)
    title = "File: %s" % os.path.relpath(filepath)
    ElectronDosFrame(parent, bands, title=title).Show()
示例#2
0
    def test_jdos(self):
        """Test JDOS methods."""
        bands = ElectronBands.from_file(get_reference_file("si_WFK-etsf.nc"))

        spin = 0
        conduction = [4,]
        for v in range(1,5):
            valence = range(0,v)
            jdos = bands.get_jdos(spin, valence, conduction)
            intg = jdos.integral()[-1][-1]
            self.assert_almost_equal(intg, len(conduction) * len(valence))

        # Need a homogeneous sampling.
        with self.assertRaises(ValueError):
            bands = ElectronBands.from_file(get_reference_file("si_nscf_WFK-etsf.nc"))
            bands.get_jdos(spin, 0, 4)
示例#3
0
def showElectronDosFrame(parent, filepath):
    """
    Read the electron bands from file filepath and shows an `ElectronDosFrame`.
    """
    bands = ElectronBands.from_file(filepath)
    title = "File: %s" % os.path.relpath(filepath)
    ElectronDosFrame(parent, bands, title=title).Show()
示例#4
0
def showElectronBandsPlot(parent, filepath):
    """
    Read the electron bands from file filepath and plot the bands.
    """
    ebands = ElectronBands.from_file(filepath)
    title = "File: %s" % os.path.relpath(filepath)
    ebands.plot(title=title)
示例#5
0
def showElectronBandsPlot(parent, filepath):
    """
    Read the electron bands from file filepath and plot the bands.
    """
    ebands = ElectronBands.from_file(filepath)
    title = "File: %s" % os.path.relpath(filepath)
    ebands.plot(title=title)
示例#6
0
文件: wfkfile.py 项目: sponce24/abipy
    def __init__(self, filepath):
        """
        Initialized the object from a Netcdf file.
        """
        super(WFK_File, self).__init__(filepath)

        # Initialize the  structure from file.
        self.structure = Structure.from_file(filepath)

        # Initialize the band energies.
        self.bands = ElectronBands.from_file(filepath)

        self.kpoints = kpoints_factory(filepath)
        self.nkpt = len(self.kpoints)

        with WFK_Reader(filepath) as reader:
            assert reader.has_pwbasis_set
            assert reader.cplex_ug == 2
            self.npwarr = reader.npwarr
            self.nband_sk = reader.nband_sk

            self.nspinor = reader.nspinor
            self.nsppol = reader.nsppol
            self.nspden = reader.nspden

        # FFT mesh (augmented divisions reported in the WFK file)
        self.fft_mesh = Mesh3D(reader.fft_divs, self.structure.lattice_vectors())

        # Build G-spheres for each k-point
        gspheres = len(self.kpoints) * [None]
        ecut = reader.ecut
        for k, kpoint in enumerate(self.kpoints):
            gvec_k, istwfk = reader.read_gvec_istwfk(k)
            gspheres[k] = GSphere(ecut, self.structure.reciprocal_lattice, kpoint, gvec_k, istwfk=istwfk)

        self._gspheres = tuple(gspheres)

        # Save reference to the reader.
        self.reader = reader
示例#7
0
 def test_dos(self):
     """Test DOS methods."""
     gs_bands = ElectronBands.from_file(get_reference_file("si_WFK-etsf.nc"))
     dos = gs_bands.get_dos()
     mu = dos.find_mu(8, atol=1.e-4)
     self.assert_almost_equal(mu, 6.1443350264585996, decimal=4)
示例#8
0
 def test_ncread_ebands(self):
     """Read ElectronBands from WFK data files"""
     for filename in WFK_NCFILES:
         bands = ElectronBands.from_file(filename)
示例#9
0
文件: wxdos.py 项目: sponce24/abipy
 def read_bands(self, path):
     try:
         self.bands = ElectronBands.from_file(path)
         ewx.ElectronDosFrame(bands=self.bands, parent=self).Show()
     except Exception:
         awx.showErrorMessage(self)
示例#10
0
def showElectronJdosFrame(parent, filepath):
    bands = ElectronBands.from_file(filepath)
    ElectronJdosFrame(parent, bands).Show()
示例#11
0
def showElectronBandsPlot(parent, filepath):
    bands = ElectronBands.from_file(filepath)
    bands.plot(title="File: %s" % filepath)
示例#12
0
def showElectronJdosFrame(parent, filepath):
    """
    Read the electron bands from file filepath and shows an `ElectronJdosFrame`.
    """
    ebands = ElectronBands.from_file(filepath)
    ElectronJdosFrame(parent, ebands).Show()
示例#13
0
def showElectronBandsPlot(parent, filepath):
    ebands = ElectronBands.from_file(filepath)
    title = "File: %s" % os.path.relpath(filepath)
    ebands.plot(title=title)
示例#14
0
def showElectronDosFrame(parent, filepath):
    bands = ElectronBands.from_file(filepath)
    title = "File: %s" % os.path.relpath(filepath)
    ElectronDosFrame(parent, bands, title=title).Show()
示例#15
0
def showElectronJdosFrame(parent, filepath):
    """
    Read the electron bands from file filepath and shows an `ElectronJdosFrame`.
    """
    ebands = ElectronBands.from_file(filepath)
    ElectronJdosFrame(parent, ebands).Show()
示例#16
0
def showElectronDosFrame(parent, filepath):
    bands = ElectronBands.from_file(filepath)
    ElectronDosFrame(parent, bands, title="File: %s" % filepath).Show()
示例#17
0
文件: gwpp.py 项目: sponce24/abipy
def build_scissors(options, args):
    import matplotlib.pyplot as plt
    from matplotlib.gridspec import GridSpec
    #gw_fname = raw_input('Enter the name of the GW file: ').strip()
    #
    # Init the corrections from gw_fname
    try:
        gw_fname = options.gw_files[0]
    except:
        show_examples_and_exit(1, err_msg = "GW file name must be specified")

    qp_corrections = read_GWFile(gw_fname)
    #
    # Construct the scissors operator for each spin.
    nsppol = len(qp_corrections)
    scissor_spin = list()
    for spin in range(nsppol):

        qpc = qp_corrections[spin].sort_by_energy()

        e0mesh = qpc.get_e0mesh()
        e0_min = np.min(e0mesh)
        e0_max = np.max(e0mesh)
        #print e0_min, e0_max

        corr = qpc.get_qpcorr()

        vb_idx = raw_input('Enter the index of the valence band maximum: ')
        vb_idx = int(vb_idx)

        h**o = qpc.max_e0(vb_idx)
        lumo = qpc.min_e0(vb_idx + 1)
        #print h**o, lumo

        #qpc.plot()

        ndomains = raw_input('How many fitting intervals do you want? (default is 2: valence/conduction): ')

        if ndomains:
            ndomains = int(ndomains)
            s = raw_input('Enter the boundaries for domains: ')
            tokens = s.split(",")
            domains = list()
            for t in tokens:
                bound = [float(v) for v in t.split()]
                domains.append(bound)
            print("Domains are: ", bound)
        else:
            ndomains = 2
            pad_hl = 0.1 / Ha_eV
            #h**o += 0.00000001
            #lumo -= 0.00000001
            domains = [(e0_min - pad_hl, h**o), (lumo, e0_max + pad_hl)]

        sciss = qpc.make_scissor(domains)

        qpc.plot(scissor=sciss)

        scissor_spin.append(sciss)

    #return scissor_spin
    # Save the list of objects with cPickle.
    # fname = "SCISSOR.cpickle"
    # fh = file(fname, mode="wb")
    # pickle.dump(scissor_spin, fh)
    # fh.close()

    #bst_fname = raw_input('Enter the name of the band structure file: ').strip()

    bst_fname = options.bands_file

    ks_bands = ElectronBands.from_file(bst_fname)

    qp_bands = ks_bands.apply_scissors(scissor_spin)

    # Plot the KS and the QPState band structures.
    fig = plt.figure()

    ax = fig.add_subplot(1, 1, 1)

    ax.grid(True)
    #ax.legend(loc="upper left")
    #title = None
    #if title: ax.set_title(title)

    ax.set_xlabel('k-point')
    ax.set_ylabel('Energy [eV]')

    for spin in range(ks_bands.nsppol):
        for band in range(ks_bands.mband):
            ks_bands.plot_ax(ax, spin, band)
            qp_bands.plot_ax(ax, spin, band)

    plt.show()

    #qp_bands.raw_print(fh=None, units="eV")

    # Write the GW file with the updated band structure.
    gw_fname = raw_input('Enter the name of the GW file: ').strip()
    if gw_fname: qp_bands.write_GWfile(gw_fname, ks_bands)