def run(name): Calculator = get_calculator(name) par = required.get(name, {}) calc = Calculator( label=name + '_bandgap', xc='PBE', # abinit, aims, elk - do not recognize the syntax below: # https://trac.fysik.dtu.dk/projects/ase/ticket/98 # kpts={'size': kpts, 'gamma': True}, **par) kpts=kpts, **par) si = bulk('Si', crystalstructure='diamond', a=5.43) si.calc = calc si.get_potential_energy() print(name, get_band_gap(si.calc)) del si.calc # test spin-polarization calc = Calculator( label=name + '_bandgap_spinpol', xc='PBE', # abinit, aims, elk - do not recognize the syntax below: # https://trac.fysik.dtu.dk/projects/ase/ticket/98 # kpts={'size': kpts, 'gamma': True}, **par) kpts=kpts, **par) si.set_initial_magnetic_moments([-0.1, 0.1]) # this should not be necessary in the new ase interface standard ... if si.get_initial_magnetic_moments().any(): # spin-polarization if name == 'aims': calc.set(spin='collinear') if name == 'elk': calc.set(spinpol=True) si.set_calculator(calc) si.get_potential_energy() print(name, get_band_gap(si.calc))
def run(name): Calculator = get_calculator(name) par = required.get(name, {}) calc = Calculator(label=name + '_bandgap', xc='PBE', kpts=kpts, **par) # abinit, aims, elk - do not recognize the syntax below: # https://trac.fysik.dtu.dk/projects/ase/ticket/98 #kpts={'size': kpts, 'gamma': True}, **par) si = bulk('Si', crystalstructure='diamond', a=5.43) si.calc = calc e = si.get_potential_energy() print(name, get_band_gap(si.calc)) del si.calc # test spin-polarization calc = Calculator(label=name + '_bandgap_spinpol', xc='PBE', kpts=kpts, **par) # abinit, aims, elk - do not recognize the syntax below: # https://trac.fysik.dtu.dk/projects/ase/ticket/98 #kpts={'size': kpts, 'gamma': True}, **par) si.set_initial_magnetic_moments([-0.1, 0.1]) # this should not be neccesary in the new ase interface standard ... if si.get_initial_magnetic_moments().any(): # spin-polarization if name == 'aims': calc.set(spin='collinear') if name == 'elk': calc.set(spinpol=True) si.set_calculator(calc) e = si.get_potential_energy() print(name, get_band_gap(si.calc))
def test(e_skn): c = Calculator(e_skn) if c.ns == 1: result = [get_band_gap(c), get_band_gap(c, True)] else: result = [get_band_gap(c), get_band_gap(c, True), get_band_gap(c, False, 0), get_band_gap(c, True, 0), get_band_gap(c, False, 1), get_band_gap(c, True, 1)] print(result) return result
def test(e_skn): c = Calculator(e_skn) if c.ns == 1: result = [get_band_gap(c), get_band_gap(c, True)] else: result = [ get_band_gap(c), get_band_gap(c, True), get_band_gap(c, False, 0), get_band_gap(c, True, 0), get_band_gap(c, False, 1), get_band_gap(c, True, 1) ] print(result) return result
from ase.dft.bandgap import get_band_gap class Test: def get_ibz_k_points(self): return [(0, 0, 0)] def get_number_of_spins(self): return 2 def get_eigenvalues(self, kpt, spin): return [-10, spin, spin + 2.0] def get_fermi_level(self): return 0.5 gaps = [2, 11, 1, 2, 11, 2] calc = Test() for direct in [0, 1]: for spin in [0, 1, None]: gap, k1, k2 = get_band_gap(calc, direct, spin) assert gap == gaps.pop(0)