[gpaw-users] Tutorial of Band calculation craches with TypeError
Maxim Skripnik
maxim.skripnik at uni-konstanz.de
Mon Feb 13 16:15:43 CET 2017
I think there is a mistake in the tutorial. The GPAW object needs the
k-points in a different format. You first have to create a k-point path
with ASE and then pass it path to GPAW().
Example (Si):
from __future__ import print_function
##################################################################################################
# Perform standard ground state calculation (with plane wave basis)
from ase.build import bulk
from gpaw import GPAW, PW, FermiDirac
si = bulk('Si', 'diamond', 5.43)
calc = GPAW(mode=PW(200),
xc='PBE',
kpts=(8, 8, 8),
random=True, # random guess (needed if many empty bands
required)
occupations=FermiDirac(0.01),
txt='Si_gs.txt')
si.calc = calc
si.get_potential_energy()
ef = calc.get_fermi_level()
calc.write('Si_gs.gpw')
##################################################################################################
# calculate the band structure
nband = 8
import numpy
from ase.dft.kpoints import ibz_points, get_bandpath
from gpaw import PW, FermiDirac
# Restart from ground state and fix potential:
calc = GPAW('Si_gs.gpw',
nbands=nband+10,
convergence={'bands': nband},
fixdensity=True,
symmetry='off')
# 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']
kpts, x, X = get_bandpath([G, M, K, G], calc.atoms.cell, npoints=40)
calc.set(kpts=kpts)
calc.get_potential_energy()
e_kn = numpy.array([calc.get_eigenvalues(k) for k in range(len(kpts))])
##################################################################################################
# save the band structure
e_kn -= ef
emin = e_kn.min() - 1.0
emax = e_kn[:, nband-1].max() + 1.0
fd = open('bands.data', 'w')
for i in range(len(x)):
print('%5.2f ' % x[i], file=fd, end="")
for j in range(len(e_kn[i])):
print('%5.2f ' % e_kn[i][j], file=fd, end="")
print('', file=fd)
fd.close()
More information about the gpaw-users
mailing list