Exemplo n.º 1
0
 def __init__(self, calc, filename='gw0', **kwargs):
     G0W0.__init__(self, calc, filename, savew=True, **kwargs)
     try:
         self.qp_xsin = np.load(filename + '-gw0.npy')
     except IOError:
         self.qp_xsin = np.empty((1,) + self.shape)
         
     self.iteration = len(self.qp_xsin)
Exemplo n.º 2
0
    def __init__(self, calc, filename='gw0', **kwargs):
        G0W0.__init__(self, calc, filename, savew=True, **kwargs)
        try:
            self.qp_xsin = np.load(filename + '-gw0.npy')
        except IOError:
            self.qp_xsin = np.empty((1, ) + self.shape)

        self.iteration = len(self.qp_xsin)
Exemplo n.º 3
0
def run(atoms, symm, name):
    atoms.calc = GPAW(mode=PW(250),
                      eigensolver='rmm-diis',
                      occupations=FermiDirac(0.01),
                      symmetry=symm,
                      kpts={
                          'size': (2, 2, 2),
                          'gamma': True
                      },
                      txt=name + '.txt')
    e = atoms.get_potential_energy()
    scalapack = atoms.calc.wfs.bd.comm.size
    atoms.calc.diagonalize_full_hamiltonian(nbands=8, scalapack=scalapack)
    atoms.calc.write(name, mode='all')
    gw = G0W0(
        name,
        'gw-' + name,
        nbands=8,
        integrate_gamma=0,
        kpts=[(0, 0, 0), (0.5, 0.5, 0)],  # Gamma, X
        ecut=40,
        domega0=0.1,
        eta=0.2,
        bands=(3, 7),  # h**o, lumo, lumo+1, lumo+2
    )
    results = gw.calculate()
    return e, results
Exemplo n.º 4
0
def gw_calc(kptsize=12, ecut=200.0, gwg_and_gw=False, gw_only=True):
    """Calculate the gw bandstructure"""

    calc = GPAW('gs.gpw', txt=None)
    kpts = {'size': (kptsize, kptsize, 1), 'gamma': True}

    calc.set(kpts=kpts, fixdensity=True, txt='gs_gw.txt')
    calc.get_potential_energy()
    calc.diagonalize_full_hamiltonian(ecut=ecut)
    calc.write('gs_gw_nowfs.gpw')
    calc.write('gs_gw.gpw', mode='all')
    lb, ub = get_bandrange(calc)

    calc = G0W0(calc='gs_gw.gpw',
                bands=(lb, ub),
                ecut=ecut,
                ecut_extrapolation=True,
                truncation='2D',
                nblocks=get_nblocks(world.size),
                q0_correction=True,
                filename='g0w0',
                restartfile='g0w0.tmp',
                savepckl=True)

    calc.calculate()
Exemplo n.º 5
0
    def get_k_point(self, s, K, n1, n2):
        kpt = G0W0.get_k_point(self, s, K, n1, n2)
        if self.iteration > 1:
            b1, b2 = self.bands
            m1 = max(b1, n1)
            m2 = min(b2, n2)
            if m2 > m1:
                k = self.calc.wfs.kd.bz2ibz_k[K]
                i = self.kpts.index(k)
                qp_n = self.qp_xsin[-1, s, i, m1 - b1:m2 - b1]
                kpt.eps_n[m1 - n1:m2 - n1] = qp_n

        return kpt
Exemplo n.º 6
0
 def get_k_point(self, s, K, n1, n2):
     kpt = G0W0.get_k_point(self, s, K, n1, n2)
     if self.iteration > 1:
         b1, b2 = self.bands
         m1 = max(b1, n1)
         m2 = min(b2, n2)
         if m2 > m1:
             k = self.calc.wfs.kd.bz2ibz_k[K]
             i = self.kpts.index(k)
             qp_n = self.qp_xsin[-1, s, i, m1 - b1:m2 - b1]
             kpt.eps_n[m1 - n1:m2 - n1] = qp_n
             
     return kpt
Exemplo n.º 7
0
def calc_gw(mater, band_num=3):
    if not os.path.exists(es_wfs(mater)):
        calc_es(mater)
    calc = GPAW(restart=gs_wfs(mater))
    ne = calc.get_number_of_electrons()
    nb = int(ne // 2)
    bands = (nb - band_num, nb + band_num)
    print(bands)
    del calc
    calc = G0W0(
        calc=es_wfs(mater),
        nbands=nbs,
        bands=bands,
        nblocksmax=True,
        # ecut_extrapolation=True,
        truncation="2D",
        q0_correction=True,
        filename=os.path.join(data_path, mater, "g0w0"),
        restartfile=os.path.join(data_path, mater, "g0w0.tmp"),
        savepckl=True)
    calc.calculate()
Exemplo n.º 8
0
            kpts={
                'size': (2, 2, 2),
                'gamma': True
            },
            xc='LDA',
            eigensolver='rmm-diis',
            occupations=FermiDirac(0.001))

atoms.set_calculator(calc)
e0 = atoms.get_potential_energy()

calc.diagonalize_full_hamiltonian(scalapack=True)
calc.write('BN_bulk_k2_ecut400_allbands.gpw', mode='all')

gw = G0W0('BN_bulk_k2_ecut400_allbands.gpw',
          bands=(3, 5),
          nbands=9,
          nblocks=1,
          method='GW0',
          maxiter=5,
          ecut=40)

result = gw.calculate()

gaps = [3.256, 4.746, 4.937, 4.952, 4.948, 4.946]

for i in range(result['iqp'].shape[0]):
    equal(
        np.min(result['iqp'][i, 0, :, 1]) - np.max(result['iqp'][i, 0, :, 0]),
        gaps[i], 0.03)
Exemplo n.º 9
0
calc = GPAW(mode=PW(Ecut),
            parallel={'domain': 1},
            xc='PBE',
            basis='dzp',
            kpts={
                'size': (9, 9, 1),
                'gamma': True
            },
            occupations=FermiDirac(0.01),
            txt='MoS2_out_gs.txt')

structure.set_calculator(calc)
structure.get_potential_energy()
calc.write('MoS2_gs.gpw', 'all')

calc.diagonalize_full_hamiltonian()
calc.write('MoS2_fulldiag.gpw', 'all')

for ecut in [80]:
    gw = G0W0(calc='MoS2_fulldiag.gpw',
              bands=(8, 18),
              ecut=ecut,
              truncation='2D',
              nblocksmax=True,
              q0_correction=True,
              filename='MoS2_g0w0_{}'.format(ecut),
              savepckl=True)

    gw.calculate()
Exemplo n.º 10
0
            kpts={
                'size': (3, 3, 3),
                'gamma': True
            },
            xc='LDA',
            occupations=FermiDirac(0.001),
            txt='BN_groundstate.txt')

atoms.set_calculator(calc)
atoms.get_potential_energy()

calc.diagonalize_full_hamiltonian()
calc.write('BN_gs_fulldiag.gpw', 'all')

gw = G0W0('BN_gs_fulldiag.gpw',
          bands=(1, 7),
          filename='BN_GW0',
          method='GW0',
          maxiter=5,
          mixing=0.5,
          ecut=50)

gw.calculate()

result = pickle.load(open('BN_GW0_results.pckl', 'rb'))

for i in range(result['iqp'].shape[0]):
    print(
        'Ite:', i, 'Gap:',
        np.min(result['iqp'][i, 0, :, 3]) - np.max(result['iqp'][i, 0, :, 2]))
Exemplo n.º 11
0
from gpaw.response.g0w0 import G0W0

a = 3.567
atoms = bulk('C', 'diamond', a=a)

calc = GPAW(mode=PW(300),
            parallel={'domain': 1},
            kpts=(3, 3, 3),
            xc='LDA',
            occupations=FermiDirac(0.001),
            txt='C_groundstate_freq.txt')

atoms.set_calculator(calc)
atoms.get_potential_energy()

calc.diagonalize_full_hamiltonian()
calc.write('C_groundstate_freq.gpw', 'all')

for i, domega0 in enumerate([0.01, 0.02, 0.03, 0.04, 0.05]):
    for j, omega2 in enumerate([1, 5, 10, 15, 20, 25]):
        gw = G0W0(calc='C_groundstate_freq.gpw',
                  nbands=30,
                  bands=(3, 5),
                  kpts=[0],
                  ecut=20,
                  domega0=domega0,
                  omega2=omega2,
                  filename='C_g0w0_domega0_%s_omega2_%s' % (domega0, omega2))

        results = gw.calculate()
Exemplo n.º 12
0
import numpy as np
from ase.parallel import parprint
from gpaw.response.g0w0 import G0W0

# We start by setting up a G0W0 calculator object
gw = G0W0('Si_gs.gpw',             # Path to groundstate gpw file
          filename='Si_g0w0_ppa',  # filename base for output files
          kpts=None,               # List of quasiparticle k-point indices
                                   # or None = all k-points
          bands=(3, 5),            # Range of quasiparticle bands - last
                                   # index is NOT included
          ecut=100.,               # Plane wave basis cut-off energy
          ppa=True)                # Use Plasmon Pole Approximation

# Perform the GW calculation. The results, ie. quasiparticle energies, as
# well as original Kohn-Sham eigenvalues, occupation numbers, DFT XC and
# self-energy contributions and renormalization factors are returned as a
# python dictionary object
result = gw.calculate()

ks_skn = result['eps']               # Get Kohn-Sham eigenvalues
ks_cbmin = np.amin(ks_skn[0, :, 1])  # DFT conduction band minimum
ks_vbmax = np.amax(ks_skn[0, :, 0])  # DFT valence band maximum
ks_gap = ks_cbmin - ks_vbmax         # DFT band gap

qp_skn = result['qp']                # GW quasiparticle energies
qp_cbmin = np.amin(qp_skn[0, :, 1])  # GW conduction band minimum
qp_vbmax = np.amax(qp_skn[0, :, 0])  # GW valence band maximum
qp_gap = qp_cbmin - qp_vbmax         # GW band gap

parprint('Kohn-Sham gap = %.3f' % ks_gap)
Exemplo n.º 13
0
from gpaw.response.g0w0 import G0W0

gw = G0W0(
    calc='C_groundstate.gpw',
    nbands=30,  # number of bands for calculation of self-energy
    bands=(3, 5),  # VB and CB
    ecut=20.0,  # plane-wave cutoff for self-energy
    filename='C-g0w0',
    savepckl=True)  # save a .pckl file with results
result = gw.calculate()
Exemplo n.º 14
0
from gpaw.response.g0w0 import G0W0

a = 3.567
atoms = bulk('C', 'diamond', a=a)

for j, k in enumerate([6, 8, 10, 12]):
    calc = GPAW(mode=PW(600),
                kpts={
                    'size': (k, k, k),
                    'gamma': True
                },
                xc='LDA',
                basis='dzp',
                occupations=FermiDirac(0.001),
                txt='C_groundstate_%s.txt' % (k))

    atoms.set_calculator(calc)
    atoms.get_potential_energy()

    calc.diagonalize_full_hamiltonian()
    calc.write('C_groundstate_%s.gpw' % k, mode='all')

    for i, ecut in enumerate([100, 200, 300, 400]):
        gw = G0W0(calc='C_groundstate_%s.gpw' % k,
                  bands=(3, 5),
                  ecut=ecut,
                  kpts=[0],
                  filename='C-g0w0_k%s_ecut%s' % (k, ecut))

        result = gw.calculate()
Exemplo n.º 15
0
    layer.pbc = (1, 1, 0)
    layer.center(axis=2, vacuum=4.0)

    layer.set_calculator(calc)
    layer.get_potential_energy()

    nbecut = 50
    from ase.units import Bohr, Hartree
    vol = layer.get_volume() / Bohr**3
    nbands = int(vol * (nbecut / Hartree)**1.5 * 2**0.5 / 3 / np.pi**2)
    calc.diagonalize_full_hamiltonian(nbands)
    calc.write('hBN.gpw', mode='all')

gw = G0W0('hBN.gpw',
          'gw-hBN',
          ecut=50,
          domega0=0.1,
          eta=0.2,
          truncation='2D',
          kpts=[0],
          bands=(3, 5),
          ecut_extrapolation=[30, 40, 50],
          nblocksmax=True)

e_qp = gw.calculate()['qp'][0, 0]

ev = -4.38194812
ec = 3.71013806
equal(e_qp[0], ev, 0.01)
equal(e_qp[1], ec, 0.01)
Exemplo n.º 16
0
        continue

    x, a = data[name]
    atoms = bulk(name, x, a=a)
    atoms.calc = GPAW(mode=PW(600),
                      xc='LDA',
                      parallel={'band': 1},
                      occupations=FermiDirac(0.02),
                      kpts={
                          'size': (6, 6, 6),
                          'gamma': True
                      },
                      txt='%s.txt' % name)
    atoms.get_potential_energy()
    atoms.calc.diagonalize_full_hamiltonian(nbands=400)
    atoms.calc.write(name, mode='all')
    n = int(atoms.calc.get_number_of_electrons()) // 2
    gw = G0W0(name,
              'gw-' + name,
              nbands=400,
              kpts=[(0, 0, 0), (0.5, 0.5, 0.5), (0.5, 0.5, 0)],
              ecut=200,
              hilbert=True,
              fast=True,
              domega0=0.1,
              eta=0.2,
              bands=(0, n + 2))
    results = gw.calculate()
    c.write(atoms, name=name, data=results)
    del c[id]
Exemplo n.º 17
0
                  cell=cell,
                  pbc=True,
                  scaled_positions=[(0, 0, 0), (2 / 3, 1 / 3, 0.3),
                                    (2 / 3, 1 / 3, -0.3)])

    pos = layer.get_positions()
    pos[1][2] = pos[0][2] + 3.172 / 2
    pos[2][2] = pos[0][2] - 3.172 / 2
    layer.set_positions(pos)
    layer.set_calculator(calc)
    layer.get_potential_energy()
    calc.write('MoS2.gpw', mode='all')

gw = G0W0('MoS2.gpw',
          'gw-test',
          nbands=15,
          ecut=10,
          domega0=0.1,
          eta=0.2,
          truncation='2D',
          kpts=[((1 / 3, 1 / 3, 0))],
          bands=(8, 10),
          savepckl=True)

e_qp = gw.calculate()['qp'][0, 0]

ev = 2.669
ec = 6.831
equal(e_qp[0], ev, 0.01)
equal(e_qp[1], ec, 0.01)
Exemplo n.º 18
0
Ecut = 400

calc = GPAW(mode=PW(Ecut),
            xc='PBE',
            basis='dzp',
            kpts={
                'size': (9, 9, 1),
                'gamma': True
            },
            occupations=FermiDirac(0.01),
            txt='MoS2_out_gs.txt')

structure.set_calculator(calc)
structure.get_potential_energy()
calc.write('MoS2_gs.gpw', 'all')

calc.diagonalize_full_hamiltonian()
calc.write('MoS2_fulldiag.gpw', 'all')

for ecut in [80]:
    gw = G0W0(calc='MoS2_fulldiag.gpw',
              bands=(8, 18),
              ecut=ecut,
              truncation='2D',
              nblocksmax=True,
              anisotropy_correction=True,
              filename='MoS2_g0w0_%s' % ecut,
              savepckl=True)

    gw.calculate()
Exemplo n.º 19
0
            kpts={'size': (k, k, k), 'gamma': True},
            dtype=complex,
            xc='LDA',
            occupations=FermiDirac(0.001),
            txt='C_converged_ppa.txt')

atoms.set_calculator(calc)
atoms.get_potential_energy()

calc.diagonalize_full_hamiltonian()
calc.write('C_converged_ppa.gpw', 'all')

for ecut in [300, 400]:
    gw = G0W0(calc='C_converged_ppa.gpw',
              kpts=[0],
              bands=(3, 5),
              ecut=ecut,
              ppa=True,
              filename='C-g0w0_ppa_{}'.format(ecut))

    gw.calculate()

fil = pickle.load(open('C-g0w0_ppa_300_results.pckl', 'rb'))
direct_gap_300 = fil['qp'][0, 0, 1] - fil['qp'][0, 0, 0]
fil = pickle.load(open('C-g0w0_ppa_400_results.pckl', 'rb'))
direct_gap_400 = fil['qp'][0, 0, 1] - fil['qp'][0, 0, 0]

extrap_gap, slope = np.linalg.solve(np.array([[1, 1. / 300.**(3. / 2)],
                                              [1, 1. / 400.**(3. / 2)]]),
                                    np.array([direct_gap_300, direct_gap_400]))
print('Direct gap:', extrap_gap)
from gpaw.response.g0w0 import G0W0
from ase.build import mx2
from gpaw import GPAW, PW, FermiDirac

restart = 'licoo2_gs.gpw'

calc = GPAW(restart)
calc.diagonalize_full_hamiltonian()
calc.write('licoo2_fulldiag.gpw', 'all')
for ecut in [300]:
    gw = G0W0(
        calc='licoo2_fulldiag.gpw',
        bands=(10, 11),
        ecut=ecut,
        #   truncation='2D',
        nblocksmax=True,
        #   q0_correction=True,
        filename='licoo2_g0w0_{}'.format(ecut),
        savepckl=True)

    gw.calculate()
Exemplo n.º 21
0
for name in data:
    id = c.reserve(name=name, tag=tag)
    if id is None:
        continue
        
    x, a = data[name]
    atoms = bulk(name, x, a=a)
    atoms.calc = GPAW(mode=PW(600),
                      xc='LDA',
                      parallel={'band': 1},
                      occupations=FermiDirac(0.02),
                      kpts={'size': (4, 4, 4), 'gamma': True},
                      txt='%s.txt' % name)
    atoms.get_potential_energy()
    atoms.calc.diagonalize_full_hamiltonian()
    atoms.calc.write(name, mode='all')
    n = int(atoms.calc.get_number_of_electrons()) // 2
    gw = G0W0(name, name + 'gw',
              nblocks=4,
              kpts=[(0, 0, 0), (0.5, 0.5, 0.5), (0.5, 0.5, 0)],
              ecut=100,
              wstc=True,
              domega0=0.2,
              omega2=10,
              eta=0.2,
              bands=(0, n + 2))
    results = gw.calculate()
    c.write(atoms, name=name, tag=tag, data=results)
    del c[id]
Exemplo n.º 22
0
from gpaw.response.g0w0 import G0W0

ecut = 40
gw = G0W0(calc='MoS2_fulldiag.gpw',
          xc='rALDA',
          av_scheme='wavevector',
          fxc_mode='GWG',
          bands=(8, 18),
          ecut=ecut,
          truncation='2D',
          nblocksmax=True,
          q0_correction=True,
          filename='MoS2_g0w0g_%s' %ecut,
          savepckl=True)

gw.calculate()