예제 #1
0
    def plotbands(self, bravais, kpoints, title='', ylim=[-3, 3]):
        """
        plot the bandstructure

        Args:
            filename: string
            styles: string (`normal` or `projected`)
            ylim: list, the range of energy values on the y-axis, e.g. [-5, 3]
            p_max: float (the ratio of color plot in the `projected` mode)

        Returns:
            A figure with band structure
        """
        cell = self.values["finalpos"]["basis"]
        self.parse_bandpath()
        efermi = self.values["calculation"]["efermi"]
        eigens = np.array(self.values['calculation']['eband_eigenvalues'])
        paths = self.values['band_paths']
        band_pts = self.values['band_points']
        proj = np.array(self.values["calculation"]
                        ["projected"])  #[N_kpts, N_band, Ions, 9]
        cm = plt.cm.get_cmap('RdYlBu')
        nkpt, nband, nocc = np.shape(eigens)

        from ase import io
        from ase.dft.kpoints import ibz_points, get_bandpath, special_paths

        # Define special points
        # See https://wiki.fysik.dtu.dk/ase/ase/dft/kpoints.html
        # for special points in different Bravais cells
        points = ibz_points[bravais]
        for i in range(len(kpoints)):
            k = kpoints[i]
            kpoints[i] = points[k]

        # Define path to be plotted. Has to be the same that was
        # calculated by VASP (defined in KPOINTS)
        path = get_bandpath(kpoints, cell, npoints=nkpt)
        x2, X2, labels = path.get_linear_kpoint_axis()
        labels = [label.replace('G', '\Gamma') for label in labels]

        # Hardcode plots with even distance between special points:
        nkpoints = int(nkpt / (len(labels) - 1))
        x1 = list(range(nkpt))
        X1 = [x1[0]] + x1[nkpoints - 1::nkpoints]

        plt.xticks(X1, ['$%s$' % n for n in labels])

        # Create plot
        for iband in range(nband):
            band = eigens[:, iband, 0] - efermi
            plt.plot(x1, band, color='b')

            # Change range:
            plt.ylim(ylim)

        plt.title(title)
        plt.xlabel('Wave Vector')
        plt.ylabel('$E - E_{Fermi}$ (eV)')
예제 #2
0
def cmca4_kpath(axes, npt=16):
  G = [0.0,  0.0, 0.0]
  Y = [0.5, -0.5, 0.0]
  S = [0.5,  0.0, 0.0]
  Z = [0.0,  0.0, 0.5]
  kpts_reduced, kpath, sp_points = get_bandpath([G, Y, S, G, Z],
    axes, npoints=npt)
  return kpts_reduced, kpath, sp_points
예제 #3
0
def plot_bands(atoms,
               sp_kpts,
               kpts_names=None,
               nkpts=60,
               calculator='vasp',
               window=None,
               output_filename=None,
               show=False,
               spin=0):
    """
    plot the bands.
    window: (Emin,Emax), the range of energy to be plotted in the figure.
    speicial_kpts_name
    """
    kpts, xcords, sp_xcords = get_bandpath(sp_kpts, atoms.get_cell(), nkpts)
    kpoints, eigenvalues, efermi = calc_bands(atoms, kpts)
    print(len(atoms.calc.get_ibz_k_points()))
    print(atoms.calc.get_number_of_bands())

    print(eigenvalues)
    print(np.shape(eigenvalues))
    mycalc = atoms.calc
    if output_filename is None:
        output_filename = 'band.png'
    plt.clf()
    if window is not None:
        plt.ylim(window[0], window[1])
    if not mycalc.get_spin_polarized():
        eigenvalues = []
        for ik in range(nkpts):
            eigenvalues_ik = np.array(mycalc.get_eigenvalues(kpt=ik))
            eigenvalues.append(eigenvalues_ik)
        eigenvalues = np.array(eigenvalues)
        for i in range(mycalc.get_number_of_bands()):
            band_i = eigenvalues[:, i] - efermi
            plt.plot(xcords, band_i)
    else:
        eigenvalues = []
        for ik in range(nkpts):
            eigenvalues_ik = np.array(mycalc.get_eigenvalues(kpt=ik,
                                                             spin=spin))
            eigenvalues.append(eigenvalues_ik)
        eigenvalues = np.array(eigenvalues)
        for i in range(mycalc.get_number_of_bands()):
            band_i = eigenvalues[:, i] - efermi
            plt.plot(xcords, band_i)
    plt.xlabel('K-points')
    plt.ylabel('$Energy-E_{fermi} (eV)$')

    plt.axhline(0, color='black', linestyle='--')
    if kpts_names is not None:
        plt.xticks(sp_xcords, kpts_names)
    if output_filename is not None:
        plt.savefig(output_filename)
    if show:
        plt.show()
예제 #4
0
def test_band_ase_kpts():
    from ase.lattice import bulk
    from ase.dft.kpoints import ibz_points, get_bandpath
    c = bulk('C', 'diamond', a=3.5668)
    print c.get_volume()
    points = ibz_points['fcc']
    G = points['Gamma']
    X = points['X']
    W = points['W']
    K = points['K']
    L = points['L']
    band_kpts, x, X = get_bandpath([L, G, X, W, K, G], c.cell, npoints=30)

    cell = pbcgto.Cell()
    cell.atom = pyscf_ase.ase_atoms_to_pyscf(c)
    cell.h = c.cell.T

    cell.basis = 'gth-szv'
    cell.pseudo = 'gth-pade'
    cell.gs = np.array([5, 5, 5])
    cell.verbose = 7
    cell.build(None, None)

    scaled_kpts = ase.dft.kpoints.monkhorst_pack((1, 1, 1))
    abs_kpts = cell.get_abs_kpts(scaled_kpts)

    kmf = pbckscf.KRKS(cell, abs_kpts)
    kmf.analytic_int = False
    kmf.xc = 'lda,vwn'
    print kmf.scf()

    e_kn = []
    for kpt in band_kpts:
        fb, sb = kmf.get_band_fock_ovlp(kmf.get_hcore() + kmf.get_veff(),
                                        kmf.get_ovlp(), kpt)
        e, c = hf.eig(fb, sb)
        print kpt, e
        e_kn.append(e)

    emin = -1
    emax = 2

    plt.figure(figsize=(5, 6))
    nbands = cell.nao_nr()
    for n in range(nbands):
        plt.plot(x, [e_kn[i][n] for i in range(len(x))])
    for p in X:
        plt.plot([p, p], [emin, emax], 'k-')
    plt.plot([0, X[-1]], [0, 0], 'k-')
    plt.xticks(X, ['$%s$' % n for n in ['L', 'G', 'X', 'W', 'K', r'\Gamma']])
    plt.axis(xmin=0, xmax=X[-1], ymin=emin, ymax=emax)
    plt.xlabel('k-vector')

    plt.show()
예제 #5
0
def test_band_ase_kpts():
    from ase.lattice import bulk
    from ase.dft.kpoints import ibz_points, get_bandpath
    c = bulk('C', 'diamond', a=3.5668)
    print c.get_volume()
    points = ibz_points['fcc']
    G = points['Gamma']
    X = points['X']
    W = points['W']
    K = points['K']
    L = points['L']
    band_kpts, x, X = get_bandpath([L, G, X, W, K, G], c.cell, npoints=30)

    cell = pbcgto.Cell()
    cell.atom=pyscf_ase.ase_atoms_to_pyscf(c)
    cell.a=c.cell

    cell.basis = 'gth-szv'
    cell.pseudo = 'gth-pade'
    cell.gs=np.array([5,5,5])
    cell.verbose=7
    cell.build(None,None)
    
    scaled_kpts=ase.dft.kpoints.monkhorst_pack((1,1,1))
    abs_kpts=cell.get_abs_kpts(scaled_kpts)

    kmf = pbckscf.KRKS(cell, abs_kpts)
    kmf.analytic_int=False
    kmf.xc = 'lda,vwn'
    print kmf.scf()
 
    e_kn = []
    for kpt in band_kpts:
        fb, sb=kmf.get_band_fock_ovlp(kmf.get_hcore()+kmf.get_veff(),
                                      kmf.get_ovlp(), kpt)
        e, c=hf.eig(fb, sb)
        print kpt, e
        e_kn.append(e)
    
    emin = -1 
    emax = 2

    plt.figure(figsize=(5, 6))
    nbands = cell.nao_nr()
    for n in range(nbands):
        plt.plot(x, [e_kn[i][n] for i in range(len(x))])
    for p in X:
        plt.plot([p, p], [emin, emax], 'k-')
    plt.plot([0, X[-1]], [0, 0], 'k-')
    plt.xticks(X, ['$%s$' % n for n in ['L', 'G', 'X', 'W', 'K', r'\Gamma']])
    plt.axis(xmin=0, xmax=X[-1], ymin=emin, ymax=emax)
    plt.xlabel('k-vector')

    plt.show()
예제 #6
0
def getBandKpoints(atoms, npoints=50, selectedPath = ['G','M','K','G','A','L','H'],shape='Hexagonal'):
  """
  Generate the line mode k along the selected path
  not very kind ase interface lead to a puzzling input parameters
  """
  from ase.dft.kpoints import get_bandpath, get_special_points
  points = get_special_points(shape,atoms.get_cell())
  #print points
  GXW = [points[k] for k in selectedPath]
  kpts,rk,rspk = get_bandpath(GXW, atoms.get_cell(), npoints=npoints)
  reciprocal_vectors = 2*np.pi*atoms.get_reciprocal_cell()
  return np.dot(kpts,reciprocal_vectors)
예제 #7
0
def get_bandpath(crystal, cell, npoints=50):
    """
    Return a list of k-points sampling the band-structure for the respective
    crystal.
    """
    bs = band_structures[crystal]
    symp = symmetry_points[crystal]

    points = reduce(lambda y1, y2: y1 + y2,
                    [[symp[x1], symp[x2]] for x1, x2 in zip(bs[:-1], bs[1:])])

    return kpoints.get_bandpath(points, cell, npoints)
예제 #8
0
파일: helpers.py 프로젝트: berquist/pyscf
def get_bandpath_fcc(ase_atom, npoints=30):
    # Set-up the band-path via special points
    from ase.dft.kpoints import ibz_points, kpoint_convert, get_bandpath

    points = ibz_points["fcc"]
    G = points["Gamma"]
    X = points["X"]
    W = points["W"]
    K = points["K"]
    L = points["L"]
    kpts_reduced, kpath, sp_points = get_bandpath([L, G, X, W, K, G], ase_atom.cell, npoints=npoints)
    kpts_cartes = kpoint_convert(ase_atom.cell, skpts_kc=kpts_reduced)

    return kpts_reduced, kpts_cartes, kpath, sp_points
예제 #9
0
def get_bandpath(crystal, cell, npoints=50):
    """
    Return a list of k-points sampling the band-structure for the respective
    crystal.
    """
    bs = band_structures[crystal]
    symp = symmetry_points[crystal]

    points = reduce(
        lambda y1, y2: y1+y2,
        [ [ symp[x1], symp[x2] ] for x1, x2 in zip(bs[:-1], bs[1:]) ]
        )

    return kpoints.get_bandpath(points, cell, npoints)
예제 #10
0
def get_bandpath_fcc(ase_atom, npoints=30):
    # Set-up the band-path via special points
    from ase.dft.kpoints import ibz_points, kpoint_convert, get_bandpath
    points = ibz_points['fcc']
    G = points['Gamma']
    X = points['X']
    W = points['W']
    K = points['K']
    L = points['L']
    kpts_reduced, kpath, sp_points = get_bandpath([L, G, X, W, K, G], 
                                                  ase_atom.cell, npoints=npoints)
    kpts_cartes = kpoint_convert(ase_atom.cell, skpts_kc=kpts_reduced)

    return kpts_reduced, kpts_cartes, kpath, sp_points
예제 #11
0
파일: helpers.py 프로젝트: eronca/pyscf
def get_bandpath_fcc(ase_atom, npoints=30):
    # Set-up the band-path via special points
    from ase.dft.kpoints import ibz_points, kpoint_convert, get_bandpath
    points = ibz_points['fcc']
    G = points['Gamma']
    X = points['X']
    W = points['W']
    K = points['K']
    L = points['L']
    kpts_reduced, kpath, sp_points = get_bandpath([L, G, X, W, K, G], 
                                                  ase_atom.cell, npoints=npoints)
    kpts_cartes = kpoint_convert(ase_atom.cell, skpts_kc=kpts_reduced)

    return kpts_reduced, kpts_cartes, kpath, sp_points
예제 #12
0
 def __init__(self,lattice,path,special_points,npts=50):
     import ase.dft.kpoints as ase
     self.special_points=special_points
     path_tmp=[]
     self.symbols=[]
     #construct the path
     for p in path:
         if isinstance(p,str):
             #then this is a special point
             path_tmp.append(self.special_points[p])
             self.symbols.append(p.replace('G', '$\Gamma$'))
         else:
             path_tmp.append(p.values()[0])
             self.symbols.append(p.keys()[0])
     self.path,self.xaxis,self.xlabel=ase.get_bandpath(path_tmp,lattice,npts)
예제 #13
0
def get_bard_bands():
    '''get bare band structure.
    '''
    # load aTB
    with open('aTB.pckl', 'rb') as f:
        a, aTB = pickle.load(f)

    # k-point path
    kG = [0.0, 0.0, 0]
    kX = [0.5, 0.0, 0]
    kM = [0.5, 0.5, 0]

    # set up a ase.dft.kpoints kpath object
    kps = kpoints.get_bandpath([kG, kX, kM, kG], a.cell)

    # get band structure of a square lattice
    aTB.get_bandstructure(kps, saveto="bare_bands.dat")
예제 #14
0
    def band_calculation(self, special_kpoints, names, npoints=60):
        """
        calculate the band structure.
        """
        self.set(icharg=11, nsw=0, ibrion=-1, ismear=0)
        cell = self.atoms.get_cell()
        kpts, xcords, sp_xcords = get_bandpath(
            special_kpoints, cell, npoints=npoints)

        self.band_xs = xcords
        self.band_special_xs = sp_xcords
        self.special_kpts_names = names
        self.set(kpts=kpts, reciprocal=True)
        self.calculate(self.atoms)
        if not os.path.exists('BAND'):
            os.mkdir('BAND')
        for f in ['POSCAR', 'OUTCAR', 'EIGENVAL', 'PROCAR', 'INCAR', 'log']:
            if os.path.exists(f):
                copyfile(f, os.path.join('BAND', f))
        self.plot_bands()
예제 #15
0
cell = pbcgto.Cell()
cell.atom = pyscf_ase.ase_atoms_to_pyscf(c)
cell.a = c.cell

cell.basis = 'gth-szv'
cell.pseudo = 'gth-pade'
cell.verbose = 5
cell.build(None,None)

points = special_points['fcc']
G = points['G']
X = points['X']
W = points['W']
K = points['K']
L = points['L']
band_kpts, kpath, sp_points = get_bandpath([L, G, X, W, K, G], c.cell, npoints=50)
band_kpts = cell.get_abs_kpts(band_kpts)

#
# band structure from Gamma point sampling
#

mf = pbcdft.RKS(cell)
print(mf.kernel())

e_kn = mf.get_bands(band_kpts)[0]
vbmax = -99
for en in e_kn:
    vb_k = en[cell.nelectron//2-1]
    if vb_k > vbmax:
        vbmax = vb_k
예제 #16
0
파일: ag.py 프로젝트: robwarm/gpaw-symm
# Restart from ground state and fix potential:
calc = GPAW('Ag_GLLBSC.gpw',
            nbands=16,
            fixdensity=True,
            usesymm=None,
            convergence={'bands': 12})

# Use ase.dft module for obtaining k-points along high symmetry directions
points = ibz_points['fcc']
G = points['Gamma']
X = points['X']
W = points['W']
K = points['K']
L = points['L']
kpts, x, X = get_bandpath([W, L, G, X, W, K], calc.atoms.cell, npoints=60)
calc.set(kpts=kpts)
calc.get_potential_energy()
e_kn = np.array([calc.get_eigenvalues(k) for k in range(len(kpts))])

# Plot the band structure
import matplotlib.pyplot as plt

e_kn -= ef
emin = e_kn.min() - 1.0
emax = e_kn[:, 12].max() + 1.0

plt.figure(figsize=(5, 8))
for n in range(12):
    plt.plot(x, e_kn[:, n])
for p in X:
예제 #17
0
def plot_bands(scftype, basis, ngs, nmp=None):
    # Set-up the unit cell
    from ase.lattice import bulk
    from ase.dft.kpoints import ibz_points, kpoint_convert, get_bandpath
    ase_atom = bulk('C', 'diamond', a=3.5668*ANG2BOHR)
    print "Cell volume =", ase_atom.get_volume(), "Bohr^3"

    # Set-up the band-path via special points
    points = ibz_points['fcc']
    G = points['Gamma']
    X = points['X']
    W = points['W']
    K = points['K']
    L = points['L']
    band_kpts, x, X = get_bandpath([L, G, X, W, K, G], ase_atom.cell, npoints=30)
    abs_kpts = kpoint_convert(ase_atom.cell, skpts_kc=band_kpts) 

    # Build the cell
    cell = pbcgto.Cell()
    cell.unit = 'B'
    cell.atom = pyscf_ase.ase_atoms_to_pyscf(ase_atom)
    cell.h = ase_atom.cell
    cell.basis = 'gth-%s'%(basis)
    #cell.basis = 'gth-szv'
    #cell.basis = 'gth-dzvp'
    cell.pseudo = 'gth-pade'
    cell.gs = np.array([ngs,ngs,ngs])
    cell.verbose = 7
    cell.build(None,None)

    # Perform the gamma-point SCF
    if scftype == 'dft':
        mf = pbcdft.RKS(cell)
        mf.xc = 'lda,vwn'
    elif scftype == 'hf':
        mf = pbchf.RHF(cell, exxdiv=None)
    else: 
        scaled_mp_kpts = ase.dft.kpoints.monkhorst_pack((nmp,nmp,nmp))
        abs_mp_kpts = cell.get_abs_kpts(scaled_mp_kpts)
        if scftype == 'kdft':
            mf = pbcdft.KRKS(cell, abs_mp_kpts)
            mf.xc = 'lda,vwn'
        else:
            mf = pbchf.KRHF(cell, abs_mp_kpts, exxdiv='vcut_sph')

    mf.analytic_int = False
    mf.scf()
    print "SCF evals =", mf.mo_energy

    # Proceed along k-point band-path
    e_kn = []
    efermi = -99
    for kpt in abs_kpts:
        e, c = mf.get_bands(kpt)
        print kpt, e
        e_kn.append(e)
        if e[4-1] > efermi:
            efermi = e[4-1]
    for k, ek in enumerate(e_kn):
        e_kn[k] = ek-efermi

    # Write the bands to stdout 
    f = open('bands_%s_%s_%d_%d.dat'%(scftype,basis,ngs,nmp),'w')
    f.write("# Special points:\n")
    for point, label in zip(X,['L', 'G', 'X', 'W', 'K', 'G']):
        f.write("# %0.6f %s\n"%(point,label))
    for kk, ek in zip(x, e_kn):
        f.write("%0.6f "%(kk))
        for ekn in ek:
            f.write("%0.6f "%(ekn))
        f.write("\n")
    f.close()

    # Plot the band structure via matplotlib
    emin = -1.0
    emax = 1.0
    plt.figure(figsize=(8, 4))
    nbands = cell.nao_nr()
    for n in range(nbands):
        plt.plot(x, [e_kn[i][n] for i in range(len(x))])
    for p in X:
        plt.plot([p, p], [emin, emax], 'k-')
    plt.plot([0, X[-1]], [0, 0], 'k-')
    plt.xticks(X, ['$%s$' % n for n in ['L', r'\Gamma', 'X', 'W', 'K', r'\Gamma']])
    plt.axis(xmin=0, xmax=X[-1], ymin=emin, ymax=emax)
    plt.xlabel('k-vector')
    plt.ylabel('Energy [au]')

    #plt.show()
    if nmp is None:
        plt.savefig('bands_%s_%s_%d.png'%(scftype,basis,ngs))
    else:
        plt.savefig('bands_%s_%s_%d_%d.png'%(scftype,basis,ngs,nmp))
예제 #18
0
# Ensure that the master does not enter here before all files have been created
world.barrier()

# Calculate band-structure and plot on master
if rank == 0:

    # High-symmetry points in the Brillouin zone
    points = ibz_points['fcc']
    G = points['Gamma']
    X = points['X']
    W = points['W']
    K = points['K']
    L = points['L']

    atoms = ph.get_atoms()
    path_kc, q, Q = get_bandpath([G, K, X, G, L, X, W, L],
                                 atoms.cell, 100)
    point_names = ['$\Gamma$', 'K', 'X', '$\Gamma$', 'L', 'X', 'W', 'L']
    
    # Calculate band-structure
    omega_kn = ph.band_structure(path_kc)
    
    # Convert from sqrt(Ha / Bohr**2 / amu) -> meV
    s = units.Hartree**0.5 * units._hbar * 1.e10 / \
        (units._e * units._amu)**(0.5) / units.Bohr
    omega_kn *= s * 1000
    
    # Plot the band-structure
    plt.figure(1)
    for n in range(len(omega_kn[0])):
       plt.plot(q, omega_kn[:, n], 'k-', lw=2)
        
예제 #19
0
# Convert to numpy array
band_energies = np.array(band_energies)
# Renormalize energy to the Fermi level
band_energies = band_energies - Fermi

# Define special points
# See https://wiki.fysik.dtu.dk/ase/ase/dft/kpoints.html
# for special points in different Bravais cells
points = sc_special_points["hexagonal"]

M = points["M"]
K = points["K"]
G = points["G"]
# Define path to be plotted. Has to be the same that was
# calculated by VASP (defined in KPOINTS)
path = get_bandpath([G, M, K, G], atoms.cell, npoints=npoints)
x2, X2, labels = path.get_linear_kpoint_axis()
labels = [label.replace('G', '\Gamma') for label in labels]

# Hardcode plots with even distance between special points:
nkpoints = int(npoints / (len(labels) - 1))
x1 = list(range(npoints))
X1 = [x1[0]] + x1[nkpoints - 1::nkpoints]

xticks(X1, ['$%s$' % n for n in labels])

# Create plot
for iband in range(nbands):
    plot(x1, band_energies[iband, :], linewidth=0.75, color="k")

# 0.5731
예제 #20
0
#  bandpath = atoms.cell.bandpath(
#      # path="GXWKLG",
#      path="GKLG",
#      npoints=50,
#      density=None,
#      special_points=None,
#      eps=0.0002,
#      pbc=True,
#      )
#  kpts = bandpath.kpts

# COMBAK How to handle this more generally?
ip = ibz_points["fcc"]
points = ["Gamma", "X", "W", "K", "L", "Gamma"]
bzpath = [ip[p] for p in points]
kpts, x, X = get_bandpath(bzpath, atoms.cell, npoints=300)

energies = atoms.calc.calc_bandstructure(kpts, atomic_projections=True)

print("")
print("energies = atoms.calc.calc_bandstructure(kpts, atomic_projections=True)")

if not os.path.exists("dir_bands"):
    os.makedirs("dir_bands")
with open("dir_bands/band_disp.pickle", "w") as fle:
    pickle.dump((points, kpts, x, X, energies), fle)

# COMBAK This broke when file already existed, tried a fix - 180405 - RF
shutil.move("charge_den.tgz", "dir_bands/charge_den.tgz")
atoms.write("dir_bands/out_bands.traj")
예제 #21
0
#         k_x[n] = 0
#         k_y[n] = 0
#         k_z[n] = 0

# This section of code by Kacey Leavitt

# In[13]:

# print(W)
# cell = [rlv1, rlv2, rlv3]
cell = [[-1, 1, 1], [1, -1, 1], [1, 1, -1]]

from ase import Atoms
Npts = 100

path_kc, q, Q = kpt.get_bandpath(path, cell, Npts)
print(path_kc)

# In[14]:

K = path_kc * 2 * np.pi / a

E = np.empty([len(K), len(h), len(h)], dtype=complex)

d2 = np.array([a / 4, a / 4, a / 4])
# d2 = a/4

for kk in range(0, len(K)):
    for i in range(0, len(h)):
        for j in range(0, len(h)):
            d = dij(i, j)
예제 #22
0
import pickle
import numpy as np
from ase.dft.kpoints import ibz_points, get_bandpath
from gpaw import GPAW
points = ibz_points['fcc']
G = points['Gamma']
X = points['X']
W = points['W']
K = points['K']
L = points['L']
calc = GPAW('Si-PBE.gpw',
            txt=None,
            parallel={'domain': 1},
            fixdensity=True,
            symmetry='off',
            convergence={'bands': 4})
kpts, x, X = get_bandpath([W, L, G, X, W, K], calc.atoms.cell)
calc.set(kpts=kpts)
calc.get_potential_energy()
e_kn = np.array([calc.get_eigenvalues(k) for k in range(len(kpts))])
pickle.dump((x, X, e_kn), open('eigenvalues.pckl', 'w'))
예제 #23
0
파일: phonons.py 프로젝트: grhawk/ASE
# Read forces and assemble the dynamical matrix
ph.read(acoustic=True)

# High-symmetry points in the Brillouin zone
points = ibz_points['fcc']
G = points['Gamma']
X = points['X']
W = points['W']
K = points['K']
L = points['L']
U = points['U']

point_names = ['$\Gamma$', 'X', 'U', 'L', '$\Gamma$', 'K']
path = [G, X, U, L, G, K]
path_kc, q, Q = get_bandpath(path, atoms.cell, 100)
omega_kn = 1000 * ph.band_structure(path_kc)

# DOS
omega_e, dos_e = ph.dos(kpts=(50, 50, 50), npts=5000, delta=1e-4)
omega_e *= 1000

# Plot phonon dispersion
import matplotlib
#matplotlib.use('Agg')
import pylab as plt

plt.figure(1, (8, 6))
plt.axes([.1, .07, .67, .85])
for n in range(len(omega_kn[0])):
    omega_n = omega_kn[:, n]
예제 #24
0
# Ensure that the master does not enter here before all files have been created
world.barrier()

# Calculate band-structure and plot on master
if rank == 0:

    # High-symmetry points in the Brillouin zone
    points = ibz_points['fcc']
    G = points['Gamma']
    X = points['X']
    W = points['W']
    K = points['K']
    L = points['L']

    atoms = ph.get_atoms()
    path_kc, q, Q = get_bandpath([G, K, X, G, L, X, W, L], atoms.cell, 100)
    point_names = ['$\Gamma$', 'K', 'X', '$\Gamma$', 'L', 'X', 'W', 'L']

    # Calculate band-structure
    omega_kn = ph.band_structure(path_kc)

    # Convert from sqrt(Ha / Bohr**2 / amu) -> meV
    s = units.Hartree**0.5 * units._hbar * 1.e10 / \
        (units._e * units._amu)**(0.5) / units.Bohr
    omega_kn *= s * 1000

    # Plot the band-structure
    plt.figure(1)
    for n in range(len(omega_kn[0])):
        plt.plot(q, omega_kn[:, n], 'k-', lw=2)
예제 #25
0
import pyscf.pbc.dft as pbcdft

import matplotlib.pyplot as plt

from ase.lattice import bulk
from ase.dft.kpoints import ibz_points, get_bandpath
c = bulk('C', 'diamond', a=3.5668)
print c.get_volume()
points = ibz_points['fcc']
G = points['Gamma']
X = points['X']
W = points['W']
K = points['K']
L = points['L']
band_kpts, kpath, sp_points = get_bandpath([L, G, X, W, K, G],
                                           c.cell,
                                           npoints=30)

#
# band for Gamma point DFT
#
cell = pbcgto.Cell()
cell.atom = pyscf_ase.ase_atoms_to_pyscf(c)
cell.a = c.cell

cell.basis = 'gth-szv'
cell.pseudo = 'gth-pade'
cell.verbose = 5
cell.build(None, None)

mf = pbcdft.RKS(cell)
예제 #26
0
# Read forces and assemble the dynamical matrix
ph.read(acoustic=True)

# High-symmetry points in the Brillouin zone
points = ibz_points['fcc']
G = points['Gamma']
X = points['X']
W = points['W']
K = points['K']
L = points['L']
U = points['U']

point_names = ['$\Gamma$', 'X', 'U', 'L', '$\Gamma$', 'K']
path = [G, X, U, L, G, K]
path_kc, q, Q = get_bandpath(path, atoms.cell, 100)
omega_kn = 1000 * ph.band_structure(path_kc)

# DOS
omega_e, dos_e = ph.dos(kpts=(50, 50, 50), npts=5000, delta=1e-4)
omega_e *= 1000

# Plot phonon dispersion
import matplotlib
matplotlib.use('Agg')
import pylab as plt

plt.figure(1, (8, 6))
plt.axes([.1, .07, .67, .85])
for n in range(len(omega_kn[0])):
    omega_n = omega_kn[:, n]
예제 #27
0
                xc=xc,
                nbands=8,
                eigensolver=eigensolver,
                parallel={'band': band})
    atoms.set_calculator(calc)
    atoms.get_potential_energy()
    calc.write('Cgs.gpw')

    # Calculate accurate KS-band gap from band structure
    points = ibz_points['fcc']

    # CMB is in G-X
    G = points['Gamma']
    X = points['X']

    kpts, x, X = get_bandpath([G, X], atoms.cell, npoints=12)
    calc = GPAW('Cgs.gpw',
                kpts=kpts,
                fixdensity=True,
                symmetry='off',
                nbands=8,
                convergence=dict(bands=8),
                eigensolver=eigensolver,
                parallel={'band': band})
    calc.get_atoms().get_potential_energy()
    # Get the accurate KS-band gap
    homolumo = calc.occupations.get_homo_lumo(calc.wfs)
    h**o, lumo = homolumo
    print("band gap ", (lumo - h**o) * 27.2)

    # Redo the ground state calculation
예제 #28
0
파일: plotbands.py 프로젝트: Moejay10/DFT
def band():
    
    # Read crystal structure from POSCAR
    atoms = io.read('POSCAR')

    # Read Fermi level from OUTCAR
    Fermi =   float( os.popen('grep fermi OUTCAR').readlines()[1].split()[2] )

    # Hard code Fermi level from SCF calculation
    Fermi = -0.7460

    # Read band energies from EIGENVAL
    with open('EIGENVAL') as f:
        line1 = f.readline()
        line2 = f.readline()
        line3 = f.readline()
        line4 = f.readline()
        comment = f.readline()
        unknown, npoints, nbands = [int(x) for x in f.readline().split()]
        blankline = f.readline()
        band_energies = [[] for i in range(nbands)]
        for i in range(npoints):
            x, y, z, weight = [float(x) for x in f.readline().split()]
            for j in range(nbands):
                fields = f.readline().split()
                id, energy = int(fields[0]), float(fields[1])
                band_energies[id-1].append(energy)
            blankline = f.readline()
    f.close()
    # Convert to numpy array
    band_energies = np.array(band_energies)
    # Renormalize energy to the Fermi level
    band_energies = band_energies-Fermi

    # Define special points
    # See https://wiki.fysik.dtu.dk/ase/ase/dft/kpoints.html
    # for special points in different Bravais cells
    points = ibz_points['orthorhombic']
    X = points['X']
    G = points['Gamma']
    Y = points['Y']
    T = points['T']
    Z = points['Z']


    # Define path to be plotted. Has to be the same that was 
    # calculated by VASP (defined in KPOINTS)
    path = get_bandpath([G, Y, T, Z, G], atoms.cell, npoints=npoints)
    x2, X2, labels = path.get_linear_kpoint_axis() 
    labels = [label.replace('G','\Gamma') for label in labels]


    # Hardcode plots with even distance between special points:
    nkpoints=int(npoints/(len(labels)-1))
    x1 = list(range(npoints))
    X1 = [x1[0]]+x1[nkpoints-1::nkpoints]

    xticks(X1, ['$%s$' % n for n in labels])

    # Create plot
    for iband in range(nbands):
        plot(x1,band_energies[iband,:],color='k')


    # Change range:
        ylim(-2,2)
    
    # Making the line for zero point
    a = linspace(1,100)
    b = zeros(len(a))
    plot(a,b,"--k")


    xlabel('k points')
    ylabel('$E - E_{Fermi}$ [eV]')

    # Print figure to file
    #savefig('BaSi2.png')

    show()
예제 #29
0
파일: tbASE.py 프로젝트: xydeng/pyGutz
    ### set up an AtomsTB object. one band without spin degeneracy.
    a = AtomsTB("N", [(0, 0, 0)], cell=(1, 1, 1))
    a.set_orbitals_spindeg()

    # sqare lattice
    ### set up a TB object and the hoppings. This corresponds to a 2D squared lattice with nearest-neighbor hopping. This is the default one in TB.gallery()
    aTB = TB(a)
    aTB.set_hop([((0, 1, 0), 0, 0, -1), ((1, 0, 0), 0, 0, -1), ((0, -1, 0), 0, 0, -1), ((-1, 0, 0), 0, 0, -1)])

    # bands and dos
    ### set special k points for bands
    kG = [0, 0, 0]
    kX = [0.5, 0, 0]
    kM = [0.5, 0.5, 0]
    ### set up a ase.dft.kpoints kpath object
    kps = kpoints.get_bandpath([kG, kX, kM, kG], a.cell)
    ### get band structure of a square lattice
    aTB.get_bandstructure(kps, saveto="pcell_band.dat")

    quit()

    ### get density of states of a square lattice.
    aTB.get_dos(kps_size=(400, 400, 1), saveto="pcell_dos.dat")

    # test supercell
    ## construct a 2x1 supercell of the 2D square lattice
    sTB = aTB.supercell(extent=(2, 1, 1))
    ## for plotting the band structure and compare to the one of the unite cell, redefine the k path.
    kX = [1.0, 0, 0]
    kM = [1.0, 0.5, 0]
    kps = kpoints.get_bandpath([kG, kX, kM, kG], sTB.Atoms.cell)
예제 #30
0
            symmetry='off',
            kpts={
                'path': 'MGKMLAH',
                'npoints': 60
            },
            convergence={'bands': nbands})

# Use ase.dft module for obtaining k-points along high symmetry directions
points = ibz_points['hexagonal']
G = points['Gamma']
M = points['M']
K = points['K']
H = points['H']
L = points['L']
A = points['A']
kpts, x, X = get_bandpath([M, G, K, M, L, A, H], calc.atoms.cell, npoints=60)
calc.set(kpts=kpts)
calc.get_potential_energy()
e_kn = np.array([calc.get_eigenvalues(k) for k in range(len(kpts))])

# Plot the band structure

bs = calc.band_structure()
bs.plot(filename='GaN_band.png', show=True, emax=15.0)

import matplotlib.pyplot as plt

e_kn -= ef
emin = e_kn.min() - 1.0
emax = e_kn[:, nbands].max() + 1.0
예제 #31
0
파일: bs.py 프로젝트: robwarm/gpaw-symm
import pickle
import numpy as np
from ase.dft.kpoints import ibz_points, get_bandpath
from gpaw import GPAW
points = ibz_points['fcc']
G = points['Gamma']
X = points['X']
W = points['W']
K = points['K']
L = points['L']
calc = GPAW('Si-PBE.gpw',
            txt=None,
            parallel={'domain': 1},
            fixdensity=True,
            usesymm=None,
            convergence={'bands': 4})
kpts, x, X = get_bandpath([W, L, G, X, W, K], calc.atoms.cell)
calc.set(kpts=kpts)
calc.get_potential_energy()
e_kn = np.array([calc.get_eigenvalues(k) for k in range(len(kpts))])
pickle.dump((x, X, e_kn), open('eigenvalues.pckl', 'w'))
예제 #32
0
# Restart from ground state and fix potential:
calc = GPAW('Ge_gs.gpw',
            nbands=16,
            fixdensity=True,
            symmetry='off',
            convergence={'bands': nbands})

# Use ase.dft module for obtaining k-points along high symmetry directions
points = ibz_points['fcc']
G = points['Gamma']
X = points['X']
W = points['W']
K = points['K']
L = points['L']
kpts, x, X = get_bandpath([W, L, G, X, W, K], calc.atoms.cell, npoints=60)
calc.set(kpts=kpts)
calc.get_potential_energy()
e_kn = np.array([calc.get_eigenvalues(k) for k in range(len(kpts))])

# Plot the band structure

bs = calc.band_structure()
bs.plot(filename='Ge_band.png', show=True, emax=15.0)

import matplotlib.pyplot as plt

e_kn -= ef
emin = e_kn.min() - 1.0
emax = e_kn[:, nbands].max() + 1.0
예제 #33
0
atoms.get_potential_energy()
calc.write('Cgs.gpw')

# Calculate accurate KS-band gap from band structure
points = ibz_points['fcc']

# CMB is in G-X
G = points['Gamma']
X = points['X']

#W = points['W']
#K = points['K']
#L = points['L']
#[W, L, G, X, W, K]

kpts, x, X = get_bandpath([G, X], atoms.cell, npoints=12)
calc = GPAW('Cgs.gpw', kpts=kpts, fixdensity=True, usesymm=None,
            convergence=dict(bands=6), eigensolver=Davidson(niter=2))
calc.get_atoms().get_potential_energy()
# Get the accurate KS-band gap
homolumo = calc.occupations.get_homo_lumo(calc.wfs)
h**o, lumo = homolumo
print "band gap ",(lumo-h**o)*27.2
    
# Redo the ground state calculation
calc = GPAW(h=0.15, kpts=(4,4,4), xc=xc, nbands = 6,
            eigensolver=Davidson(niter=2))
atoms.set_calculator(calc)
atoms.get_potential_energy()
# And calculate the discontinuity potential with accurate band gap
response = calc.hamiltonian.xc.xcs['RESPONSE']
예제 #34
0
파일: Si_guc.py 프로젝트: yihsuanliu/gpaw
    calc = GPAW(kpts=(k, k, k),
                xc='PBE')
    si.set_calculator(calc)
    e = si.get_potential_energy()
    efermi = calc.get_fermi_level()
    calc.write('Si-gs.gpw')
else:
    efermi = GPAW('Si-gs.gpw', txt=None).get_fermi_level()

points = ibz_points['fcc']
G = points['Gamma']
X = points['X']
W = points['W']
K = points['K']
L = points['L']
kpts, x, X = get_bandpath([W, L, G, X, W, K], si.cell)
print len(kpts), len(x), len(X)
point_names = ['W', 'L', '\Gamma', 'X', 'W', 'K']

if 1:
    calc = GPAW('Si-gs.gpw',
                kpts=kpts,
                fixdensity=True,
                usesymm=None,#False,
                basis='dzp',
                convergence=dict(nbands=8))
    e = calc.get_atoms().get_potential_energy()
    calc.write('Si-bs.gpw')

calc = GPAW('Si-bs.gpw', txt=None)
import matplotlib.pyplot as plt
예제 #35
0
파일: tbASE.py 프로젝트: henhans/CyGutz
                    f['/IKP_' + str(ik + 1) + '/ek0'] = ek
                    f['/IKP_' + str(ik + 1) + '/ISYM_1/HK0'] = self.hk.T
                    f['/IKP_' + str(ik + 1) + '/T_PSIK0_TO_HK0_BASIS'] = Uk.T


if __name__ == "__main__":
    # The following is a simple test for the above codes.

    # AtomsTB object
    # set up an AtomsTB object. one band without spin degeneracy.
    a = AtomsTB("N", [(0, 0, 0)], cell=(1, 1, 1))
    a.set_orbitals_spindeg()

    # sqare lattice
    # set up a TB object and the hoppings. This corresponds to a 2D squared
    # lattice with nearest-neighbor hopping. This is the default one in
    # TB.gallery()
    aTB = TB(a)
    aTB.set_hop([((0, 1, 0), 0, 0, -1), ((1, 0, 0), 0, 0, -1),
                 ((0, -1, 0), 0, 0, -1), ((-1, 0, 0), 0, 0, -1)])

    # bands and dos
    # set special k points for bands
    kG = [0, 0, 0]
    kX = [0.5, 0, 0]
    kM = [0.5, 0.5, 0]
    # set up a ase.dft.kpoints kpath object
    kps = kpoints.get_bandpath([kG, kX, kM, kG], a.cell)
    # get band structure of a square lattice
    aTB.get_bandstructure(kps, saveto="pcell_band.dat")
예제 #36
0
            convergence={'bands': nbands})

# Obtain k-points along high symmetry directions of FCC Brilloin-zone
# ibz_points is a dictionary of high symm k-pints for cubic, fcc, bcc, hexagonal and tetragonal structures
points = ibz_points['fcc']
# Points are stored in dictionary with the names 'Gamma', 'X', 'W', 'K', 'L', 'U' for FCC
G = points['Gamma']  # [0, 0, 0]
X = points['X']  # [1/2, 0, 1/2]
W = points['W']  # [1/2, 1/4, 3/4]
K = points['K']  # [3/8, 3/8, 3/4]
L = points['L']  # [1/2, 1/2, 1/2]
U = points['U']
# Make list of 60 kpoints defining path between list of special IBZ point pairs
# Return the list of k-points, list of x-coordinates and list of X-coordinates of special points
#kpts, x, X = get_bandpath([L, G, X, W, K, G], calc.atoms.cell, npoints=100)
kpts, x, X = get_bandpath([L, G, X, U, G], calc.atoms.cell, npoints=100)
calc.set(kpts=kpts)

##################PLOT THE BAND STRUCTURE#########################

calc.get_potential_energy()
# Create an array of eigenvalue arrays of kpoints
e_kn = np.array([calc.get_eigenvalues(k) for k in range(len(kpts))])

import pylab as plt

# Subtract the fermi level from the eigenvalues
e_kn -= efermi
emin = e_kn.min() - 1.0
emax = e_kn[:, nbands].max() - 1.0