Пример #1
0
def evaluate(args):
    x = str(args['xc'][0])
    be = bool(str(args['beefensemble'][0]))
    pe = bool(str(args['printensemble'][0]))
    kpoints = tuple(float(args['kpts'][0][0]), float(args['kpts'][0][1]),
                    float(args['kpts'][0][2]))
    p = float(args['pw'][0])
    d = float(args['dw'][0])
    sp = bool(args['spinpol'][0])
    pflags = str(args['parflags'][0])
    odir = str(args['outdir'][0])

    calcargs = dict(
        xc=x,
        beefensemble=be,
        printensemble=pe,
        kpts=kpoints,  #only need 1 kpt in z-direction
        pw=p,
        dw=d,
        spinpol=sp,
        parflags=pflags,
        outdir=odir)

    calc = espresso(**calcargs)

    atoms = io.read(
        'Pt_111.json')  #Read in the structure built by the other script

    atoms.set_calculator(calc)

    energy = atoms.get_potential_energy(
    )  #this is the potential energy of the electrons as computed by DFT. It will be closely related to the enthalpy.

    f = open('converged.log', 'w')
    f.write(str(energy))
    f.close()

    return calc
Пример #2
0
            txt=myGpaw.symstr+'.out',
            occupations=FermiDirac(width=0.05),
          #   nbands=-2,
            convergence={'energy': 0.0005,  # eV / electron
               'density': 1.0e-4,
               'eigenstates': 4.0e-8,  # eV^2 / electron
               'bands': 'CBM+2.0',
               'forces': float('inf')}, # eV / Ang Max
            )

atoms.calc = calc
e2 = atoms.get_potential_energy()
d0 = atoms.get_distance(0, 1)
calc.write(myGpaw.symstr+'.gpw')

fd = open('optimization.txt', 'w')
print('experimental bond length:', file=fd)
print('experimental energy: %5.2f eV' % e2, file=fd)
print('bondlength              : %5.2f Ang' % d0, file=fd)

# # Find the theoretical bond length:
relax = QuasiNewton(atoms, logfile='qn.log', trajectory=myGpaw.symstr+'.emt.traj')
relax.run(fmax=0.05)

e2 = atoms.get_potential_energy()
d0 = atoms.get_distance(0, 1)
# calc.write(myGpaw.symstr+'relax.gpw')

print(file=fd)
print('PBE energy minimum:', file=fd)
print('PBE minimal energy: %5.2f eV' % e2, file=fd)
Пример #3
0
from __future__ import print_function

from gpaw import restart
from ase.parallel import paropen as open
from ase.optimize import QuasiNewton


molecule, calc = restart('H2.gpw', txt='H2-relaxed.txt')

e2 = molecule.get_potential_energy()
d0 = molecule.get_distance(0, 1)

fd = open('optimization.txt', 'w')
print('experimental bond length:', file=fd)
print('hydrogen molecule energy: %5.2f eV' % e2, file=fd)
print('bondlength              : %5.2f Ang' % d0, file=fd)

# Find the theoretical bond length:
relax = QuasiNewton(molecule, logfile='qn.log')
relax.run(fmax=0.05)

e2 = molecule.get_potential_energy()
d0 = molecule.get_distance(0, 1)

print(file=fd)
print('PBE energy minimum:', file=fd)
print('hydrogen molecule energy: %5.2f eV' % e2, file=fd)
print('bondlength              : %5.2f Ang' % d0, file=fd)
fd.close()
Пример #4
0
            xc='PBE',
            hund=True,
            eigensolver='rmm-diis',  # This solver can parallelize over bands
            occupations=FermiDirac(0.0, fixmagmom=True),
            txt='H.out',
            )
atom.set_calculator(calc)

e1 = atom.get_potential_energy()
calc.write('H.gpw')

# Hydrogen molecule:
d = 0.74  # Experimental bond length
molecule = Atoms('H2',
                 positions=([c - d / 2, c, c],
                            [c + d / 2, c, c]),
                 cell=(a, a, a))

calc.set(txt='H2.out')
calc.set(hund=False)  # No hund rule for molecules

molecule.set_calculator(calc)
e2 = molecule.get_potential_energy()
calc.write('H2.gpw')

fd = open('atomization.txt', 'w')
print('  hydrogen atom energy:     %5.2f eV' % e1, file=fd)
print('  hydrogen molecule energy: %5.2f eV' % e2, file=fd)
print('  atomization energy:       %5.2f eV' % (2 * e1 - e2), file=fd)
fd.close()
Пример #5
0
        'npoints': 60
    },
    symmetry='off',
    convergence={'bands': 'CBM+2.0'},
    txt=myGpaw.symstr + '_bs.out')

# Plot the band structure
bs = bs_calc.band_structure().subtract_reference()
bs.plot(filename=myGpaw.symstr + 'bs.png', emin=-6, emax=6)

# Get the accurate H**O and LUMO from the band structure calculator
h**o, lumo = bs_calc.get_homo_lumo()

# Calculate the discontinuity potential using the ground state calculator and
# the accurate H**O and LUMO
response = calc.hamiltonian.xc.response
dxc_pot = response.calculate_discontinuity_potential(h**o, lumo)

# Calculate the discontinuity using the band structure calculator
bs_response = bs_calc.hamiltonian.xc.response
KS_gap, dxc = bs_response.calculate_discontinuity(dxc_pot)

# Fundamental band gap = Kohn-Sham band gap + derivative discontinuity
QP_gap = KS_gap + dxc

fd = open('band.txt', 'w')
print(file=fd)
print(f'Kohn-Sham band gap:         {KS_gap:.5f} eV', file=fd)
print(f'Discontinuity from GLLB-sc: {dxc:.5f} eV', file=fd)
print(f'Fundamental band gap:       {QP_gap:.5f} eV', file=fd)
fd.close()
Пример #6
0
from __future__ import print_function

import numpy as np
from ase.utils.bee import get_ensemble_energies
from ase.parallel import paropen as open
from gpaw import GPAW

atom = GPAW('H.gpw', txt=None).get_atoms()
molecule = GPAW('H2.gpw', txt=None).get_atoms()
e1 = atom.get_potential_energy()
e2 = molecule.get_potential_energy()
ea = 2 * e1 - e2

fd = open('ensemble_energies.txt', 'w')
print('PBE:', ea, 'eV', file=fd)

e1i = get_ensemble_energies(atom)
e2i = get_ensemble_energies(molecule)
eai = 2 * e1i - e2i

n = len(eai)
ea0 = np.sum(eai) / n
sigma = (np.sum((eai - ea0)**2) / n)**0.5
print('Best fit:', ea0, '+-', sigma, 'eV', file=fd)
fd.close()

fd = open('ensemble.dat', 'w')
for e in eai:
    print(e, file=fd)
fd.close()
Пример #7
0
from __future__ import print_function

import numpy as np
from ase.utils.bee import get_ensemble_energies
from ase.parallel import paropen as open
from gpaw import GPAW 

atom = GPAW('H.gpw', txt=None).get_atoms()
molecule = GPAW('H2.gpw', txt=None).get_atoms()
e1 = atom.get_potential_energy()
e2 = molecule.get_potential_energy()
ea = 2 * e1 - e2

fd = open('ensemble_energies.txt', 'w')
print('PBE:', ea, 'eV', file=fd)

e1i = get_ensemble_energies(atom)
e2i = get_ensemble_energies(molecule)
eai = 2 * e1i - e2i

n = len(eai)
ea0 = np.sum(eai) / n
sigma = (np.sum((eai - ea0)**2) / n)**0.5
print('Best fit:', ea0, '+-', sigma, 'eV', file=fd)
fd.close()

fd = open('ensemble.dat', 'w')
for e in eai:
    print(e, file=fd)
fd.close()
Пример #8
0
from gpaw import restart
from ase.parallel import paropen as open
from ase.optimize import QuasiNewton


molecule, calc = restart("../01_atomization_energies/H2.gpw", txt="LOG_H2-relaxed.txt")

e2 = molecule.get_potential_energy()
d0 = molecule.get_distance(0, 1) # distance between H atoms

fd = open("LOG_optimization.txt", "w")
print("experimental bond length:", file=fd)
print("hydrogen molecule energy: %5.2f eV" % e2, file=fd)
print("bondlength              : %5.2f Ang" % d0, file=fd)

# Find the theoretical bond length:
relax = QuasiNewton(molecule, logfile="LOG_qn.txt")
relax.run(fmax=0.05)

e2 = molecule.get_potential_energy()
d0 = molecule.get_distance(0, 1)

print(file=fd)
print("PBE energy minimum:", file=fd)
print("hydrogen molecule energy: %5.2f eV" % e2, file=fd)
print("bondlength              : %5.2f Ang" % d0, file=fd)
fd.close()
Пример #9
0
# gpaw calculator:
calc = GPAW(
    mode=PW(),
    xc="PBE",
    hund=True,
    eigensolver="rmm-diis",  # This solver can parallelize over bands
    occupations=FermiDirac(0.0, fixmagmom=True),
    txt="H.out",
)
atom.set_calculator(calc)

e1 = atom.get_potential_energy()
calc.write("H.gpw")

# Hydrogen molecule:
d = 0.74  # Experimental bond length
molecule = Atoms("H2", positions=([c - d / 2, c, c], [c + d / 2, c, c]), cell=(a, a, a))

calc.set(txt="H2.out")
calc.set(hund=False)  # No hund rule for molecules

molecule.set_calculator(calc)
e2 = molecule.get_potential_energy()
calc.write("H2.gpw")

fd = open("atomization.txt", "w")
print("  hydrogen atom energy:     %5.2f eV" % e1, file=fd)
print("  hydrogen molecule energy: %5.2f eV" % e2, file=fd)
print("  atomization energy:       %5.2f eV" % (2 * e1 - e2), file=fd)
fd.close()
Пример #10
0
calc = GPAW(mode=PW(),
            xc="PBE",
            hund=True,
            eigensolver="rmm-diis",  # This solver can parallelize over bands
            occupations=FermiDirac(0.0, fixmagmom=True),
            txt="H.out",
            )
atom.set_calculator(calc)

e1 = atom.get_potential_energy()
calc.write("H.gpw")

# Hydrogen molecule:
d = 0.74  # Experimental bond length
molecule = Atoms("H2",
                 positions=([c - d / 2, c, c],
                            [c + d / 2, c, c]),
                 cell=(a, a, a))

calc.set(txt="H2.out")
calc.set(hund=False)  # No hund rule for molecules

molecule.set_calculator(calc)
e2 = molecule.get_potential_energy()
calc.write("H2.gpw")

fd = open("LOG_atomization.txt", "w")
print("  hydrogen atom energy:     %5.2f eV" % e1, file=fd)
print("  hydrogen molecule energy: %5.2f eV" % e2, file=fd)
print("  atomization energy:       %5.2f eV" % (2 * e1 - e2), file=fd)
fd.close()