示例#1
0
def xc(filename, xc, ecut=None):
    """Calculate non self-consitent energy.
    
    filename: str
        Name of restart-file.
    xc: str
        Functional
    ecut: float
        Plane-wave cutoff for exact exchange.
    """
    name, ext = filename.rsplit('.', 1)
    assert ext == 'gpw'
    if xc in ['EXX', 'PBE0', 'B3LYP']:
        from gpaw.xc.exx import EXX
        exx = EXX(filename, xc, ecut=ecut, txt=name + '-exx.txt')
        exx.calculate()
        e = exx.get_total_energy()
    else:
        from gpaw import GPAW
        calc = GPAW(filename, txt=None)
        e = calc.get_potential_energy() + calc.get_xc_difference(xc)
    print(e, 'eV')
def xc(filename, xc, ecut=None):
    """Calculate non self-consitent energy.
    
    filename: str
        Name of restart-file.
    xc: str
        Functional
    ecut: float
        Plane-wave cutoff for exact exchange.
    """
    name, ext = filename.rsplit(".", 1)
    assert ext == "gpw"
    if xc in ["EXX", "PBE0", "B3LYP"]:
        from gpaw.xc.exx import EXX

        exx = EXX(filename, xc, ecut=ecut, txt=name + "-exx.txt")
        exx.calculate()
        e = exx.get_total_energy()
    else:
        from gpaw import GPAW

        calc = GPAW(filename, txt=None)
        e = calc.get_potential_energy() + calc.get_xc_difference(xc)
    print(e, "eV")
    isolated_calc = GPAW(
        mode=PW(pwcutoff),
        dtype=complex,
        kpts=(1, 1, 1),
        xc="PBE",
        txt="si_isolated_pbe.txt",
        occupations=FermiDirac(0.01, fixmagmom=True),
        spinpol=True,
        hund=True,
        convergence={"density": 1.0e-6},
        mixer=Mixer(beta=0.05, nmaxold=5, weight=50.0),
    )

    isolated_silicon.set_calculator(isolated_calc)

    e0_isolated_pbe = isolated_silicon.get_potential_energy()
    isolated_calc.write("si.pbe+exx.isolated.gpw", mode="all")

    # Now the exact exchange
    exx = EXX("si.pbe+exx.isolated.gpw", txt="si_isolated_exx.txt")
    exx.calculate()
    si_isolated_exx = exx.get_total_energy()

    s = str(L)
    s += " "
    s += str(e0_isolated_pbe)
    s += " "
    s += str(si_isolated_exx)
    s += "\n"
    myresults.write(s)
示例#4
0
                     'size': (k, k, k),
                     'gamma': True
                 },
                 xc='PBE',
                 occupations=FermiDirac(0.01),
                 txt='si.pbe+exx.pbe_output.txt',
                 parallel={'band': 1})

bulk_crystal.set_calculator(bulk_calc)
e0_bulk_pbe = bulk_crystal.get_potential_energy()

#  Write to file
bulk_calc.write('bulk.gpw', mode='all')

# Now the exact exchange
exx_bulk = EXX('bulk.gpw', txt='si.pbe+exx.exx_output.txt')
exx_bulk.calculate()
e0_bulk_exx = exx_bulk.get_total_energy()

s = str(alat)
s += ' '
s += str(k)
s += ' '
s += str(pwcutoff)
s += ' '
s += str(e0_bulk_pbe)
s += ' '
s += str(e0_bulk_exx)
s += '\n'
resultfile.write(s)
示例#5
0
N2 = molecule('N2')
N2.center(vacuum=2.0)

calc = GPAW(mode=PW(force_complex_dtype=True),
            xc='PBE',
            parallel={'domain': 1},
            eigensolver='rmm-diis')
N2.set_calculator(calc)
E_n2_pbe = N2.get_potential_energy()

calc.diagonalize_full_hamiltonian(nbands=104, scalapack=True)
calc.write('N2.gpw', mode='all')

exx = EXX('N2.gpw')
exx.calculate()
E_n2_hf = exx.get_total_energy()

rpa = RPACorrelation('N2.gpw', nfrequencies=8)
E_n2_rpa = rpa.calculate(ecut=[ecut])

N = molecule('N')
N.set_cell(N2.cell)

calc = GPAW(mode=PW(force_complex_dtype=True),
            xc='PBE',
            parallel={'domain': 1},
            eigensolver='rmm-diis')
N.set_calculator(calc)
E_n_pbe = N.get_potential_energy()

calc.diagonalize_full_hamiltonian(nbands=104, scalapack=True)
示例#6
0
CO = Atoms('CO', [(0, 0, 0), (0, 0, 1.1283)])
CO.set_pbc(True)
CO.center(vacuum=3.0)
calc = GPAW(mode=PW(600, force_complex_dtype=True),
            parallel={'domain': 1},
            xc='PBE',
            txt='CO.ralda_01_CO_pbe.txt',
            convergence={'density': 1.e-6})

CO.set_calculator(calc)
E0_pbe = CO.get_potential_energy()

exx = EXX(calc, txt='CO.ralda_01_CO_exx.txt')
exx.calculate()
E0_hf = exx.get_total_energy()

calc.diagonalize_full_hamiltonian()
calc.write('CO.ralda.pbe_wfcs_CO.gpw', mode='all')

# C

C = Atoms('C')
C.set_pbc(True)
C.set_cell(CO.cell)
C.center()
calc = GPAW(mode=PW(600, force_complex_dtype=True),
            parallel={'domain': 1},
            xc='PBE',
            mixer=MixerSum(beta=0.1, nmaxold=5, weight=50.0),
            hund=True,
示例#7
0
CO = Atoms('CO', [(0, 0, 0), (0, 0, 1.1283)])
CO.set_pbc(True)
CO.center(vacuum=3.0)
calc = GPAW(mode=PW(600),
            dtype=complex,
            xc='PBE',
            txt='CO_pbe.txt',
            convergence={'density': 1.e-6})

CO.set_calculator(calc)
E0_pbe= CO.get_potential_energy()

exx = EXX(calc, txt='CO_exx.txt')
exx.calculate()
E0_hf = exx.get_total_energy()

calc.diagonalize_full_hamiltonian()
calc.write('CO.gpw', mode='all')

# C -------------------------------------------

C = Atoms('C')
C.set_pbc(True)
C.set_cell(CO.cell)
C.center()
calc = GPAW(mode=PW(600),
            dtype=complex,
            xc='PBE',
            mixer=MixerSum(beta=0.1, nmaxold=5, weight=50.0),
            hund=True,
示例#8
0
                             pbc=(1, 1, 1))

    isolated_calc = GPAW(mode=PW(pwcutoff),
                         dtype=complex,
                         kpts=(1, 1, 1),
                         xc='PBE',
                         txt='si_isolated_pbe.txt',
                         occupations=FermiDirac(0.01, fixmagmom=True),
                         spinpol=True,
                         hund=True,
                         convergence={'density': 1.e-6},
                         mixer=Mixer(beta=0.05, nmaxold=5, weight=50.0))

    isolated_silicon.set_calculator(isolated_calc)

    e0_isolated_pbe = isolated_silicon.get_potential_energy()
    isolated_calc.write('si.pbe+exx.isolated.gpw', mode='all')

    # Now the exact exchange
    exx = EXX('si.pbe+exx.isolated.gpw', txt='si_isolated_exx.txt')
    exx.calculate()
    si_isolated_exx = exx.get_total_energy()

    s = str(L)
    s += ' '
    s += str(e0_isolated_pbe)
    s += ' '
    s += str(si_isolated_exx)
    s += '\n'
    myresults.write(s)
    pos = slab.get_positions()
    add_adsorbate(slab, 'C', d, position=(pos[3,0], pos[3,1]))
    add_adsorbate(slab, 'C', d, position=(cell[0,0]/3 + cell[1,0]/3,
                                          cell[0,1]/3 + cell[1,1]/3))
    #view(slab)
    calc = GPAW(xc='PBE',
                eigensolver='cg',
                mode=PW(600),
                kpts=kpts,
                occupations=FermiDirac(width=0.01),
                mixer=MixerSum(beta=0.1, nmaxold=5, weight=50.0),
                convergence={'density': 1.e-6},
                maxiter=300,
                parallel={'domain': 1,
                          'band': 1},
                txt='gs_%s.txt' % d)
    slab.set_calculator(calc)
    E = slab.get_potential_energy()
    exx = EXX(calc, txt='exx_%s.txt' % d)
    exx.calculate()
    E_hf = exx.get_total_energy()

    calc.diagonalize_full_hamiltonian()
    calc.write('gs_%s.gpw' % d, mode='all')

    f = paropen('hf_acdf.dat', 'a')
    print(d, E, E_hf, file=f)
    f.close()
    
    del slab[-2:]
示例#10
0
cell = bulk('C', 'fcc', a=3.553).get_cell()
a = Atoms('C2',
          cell=cell,
          pbc=True,
          scaled_positions=((0, 0, 0), (0.25, 0.25, 0.25)))

calc = GPAW(mode=PW(600),
            xc='PBE',
            occupations=FermiDirac(width=0.01),
            convergence={'density': 1.e-6},
            kpts=kpts,
            parallel={'domain': 1},
            txt='diamond.ralda_01_pbe.txt')

a.set_calculator(calc)
E_pbe = a.get_potential_energy()

exx = EXX(calc, txt='diamond.ralda_01_exx.txt')
exx.calculate()
E_hf = exx.get_total_energy()

E_C = np.loadtxt('CO.ralda.PBE_HF_C.dat')

f = paropen('diamond.ralda.PBE_HF_diamond.dat', 'w')
print('PBE: ', E_pbe / 2 - E_C[0], file=f)
print('HF: ', E_hf / 2 - E_C[1], file=f)
f.close()

calc.diagonalize_full_hamiltonian()
calc.write('diamond.ralda.pbe_wfcs.gpw', mode='all')
示例#11
0
                   (0.0000, 0.0000, -1.1560)]),
   'Be2': ('Be2', [(0.0000, 0.0000, 0.0000),
                   (0.0000, 0.0000, 2.460)])}


c = ase.db.connect('results.db')

for name in ex_atomization.keys() + 'H Li Be B C N O F Cl P'.split():
    id = c.reserve(name=name)
    if id is None:
        continue
        
    if name in extra:
        a = Atoms(*extra[name])
    else:
        a = molecule(name)
        if name in bondlengths:
            a.set_distance(0, 1, bondlengths[name])
    a.cell = [11, 12, 13]
    a.center()
   
    a.calc = GPAW(xc='PBE', mode=PW(500), txt=name + '.txt', dtype=complex)
    a.get_potential_energy()
    
    exx = EXX(a.calc)
    exx.calculate()
    eexx = exx.get_total_energy()

    c.write(a, name=name, exx=eexx)
    del c[id]
    
ecut = 25

N2 = molecule("N2")
N2.center(vacuum=2.0)

calc = GPAW(mode="pw", dtype=complex, xc="PBE", eigensolver="rmm-diis")
N2.set_calculator(calc)
E_n2_pbe = N2.get_potential_energy()

calc.diagonalize_full_hamiltonian(nbands=104, scalapack=True)
calc.write("N2.gpw", mode="all")

exx = EXX("N2.gpw")
exx.calculate()
E_n2_hf = exx.get_total_energy()

rpa = RPACorrelation("N2.gpw", nfrequencies=8)
E_n2_rpa = rpa.calculate(ecut=[ecut])

# -------------------------------------------------------------------------

N = molecule("N")
N.set_cell(N2.cell)

calc = GPAW(mode="pw", dtype=complex, xc="PBE", eigensolver="rmm-diis")
N.set_calculator(calc)
E_n_pbe = N.get_potential_energy()

calc.diagonalize_full_hamiltonian(nbands=104, scalapack=True)
calc.write("N.gpw", mode="all")
示例#13
0
            mode = PW(pwcutoff),
            kpts={'size': (k, k, k), 'gamma': True},
            dtype=complex,
            xc='PBE',
            txt='si.pbe+exx.pbe_output.txt',
            parallel={'band':1}
            )

bulk_crystal.set_calculator(bulk_calc)
e0_bulk_pbe = bulk_crystal.get_potential_energy()

#  Write to file
bulk_calc.write('bulk.gpw',mode='all')

# Now the exact exchange
exx_bulk = EXX('bulk.gpw', txt='si.pbe+exx.exx_output.txt')
exx_bulk.calculate()
e0_bulk_exx = exx_bulk.get_total_energy()

s = str(alat)
s += ' '
s += str(k)
s += ' '
s += str(pwcutoff)
s += ' '
s += str(e0_bulk_pbe)
s += ' '
s += str(e0_bulk_exx)
s += '\n'
resultfile.write(s)
示例#14
0
文件: eos.py 项目: thonmaker/gpaw
import ase.db
from ase.build import bulk
import numpy as np
from gpaw.xc.exx import EXX
from gpaw import GPAW, PW

a0 = 5.43

con = ase.db.connect('si.db')

for k in range(2, 9):
    for a in np.linspace(a0 - 0.04, a0 + 0.04, 5):
        id = con.reserve(a=a, k=k)
        if id is None:
            continue
        si = bulk('Si', 'diamond', a)
        si.calc = GPAW(kpts=(k, k, k),
                       mode=PW(400),
                       xc='PBE',
                       eigensolver='rmm-diis',
                       txt=None)
        si.get_potential_energy()
        name = 'si-{0:.2f}-{1}'.format(a, k)
        si.calc.write(name + '.gpw', mode='all')
        pbe0 = EXX(name + '.gpw', 'PBE0', txt=name + '.pbe0.txt')
        pbe0.calculate()
        epbe0 = pbe0.get_total_energy()

        con.write(si, a=a, k=k, epbe0=epbe0)
        del con[id]