def test_orthorombic(self): """Orthorombic (ORC)""" a = 9.0714 #1.0 b = 8.7683 #2.0 c = 12.8024 #3.0 #lat = Lattice({'type': 'ORC', 'param': [a, b, c], 'path': 'Gamma-S-X-Gamma-Z'}) lat = Lattice({ 'type': 'ORC', 'param': [a, b, c], 'path': 'Gamma-S-Y-Gamma-Z' }) # Default Path lat = Lattice({'type': 'ORC', 'param': [a, b, c]}) logger.debug(lat)
def test_get_klines(self): #lat = lattice.FCC(3.6955*2) lat = Lattice({'type': 'FCC', 'param': 3.6955*2}) refklines = [('X', 0), ('Gamma', 85), ('K', 175), ('L', 227), ('Gamma', 300)] refklinesdict = {'L': [227], 'K': [175], 'X': [0], 'Gamma': [85, 300]} klines, klinesdict = get_klines(lat, workdir='test_dftbutils/bs') self.assertListEqual(refklines, klines) self.assertDictEqual(refklinesdict, klinesdict)
def test_tetragonal(self): """Tetragonal (TET)""" a = 8.9385 #1.0 c = 12.9824 #2.0 lat = Lattice({ 'type': 'TET', 'param': [a, c], 'path': 'Gamma-M-X-Gamma-Z' }) logger.debug(lat)
def test_get_kvec_abscissa3(self): """Can we get the bandstructure and extract the kvector info, from vasp style kLines""" latticeinfo = {'type': 'FCC', 'param': 1.} lat = Lattice(latticeinfo) kLines = [('X', 0), ('Gamma', 9), ('Gamma', 10), ('K', 19), ('K', 20), ('L', 29), ('L', 30), ('Gamma', 39)] xx, xt, xl = get_kvec_abscissa(lat, kLines) refxl = ['X', 'Γ', 'K', 'L', 'Γ'] refxt = [0, 6.28319, 12.94751, 16.79516, 22.23656] self.assertListEqual(xl, refxl) nptest.assert_almost_equal(xt, refxt, 5) self.assertAlmostEqual(xx[-1], xt[-1]) self.assertEqual(len(xx), kLines[-1][-1]+1)
def test_get_kvec_abscissa(self): """Can we get the bandstructure and extract the kvector info""" latticeinfo = {'type': 'FCC', 'param': 1.} lat = Lattice(latticeinfo) kLines = [('L', 0), ('Gamma', 10), ('X', 20), ('U', 30), ('K', 31), ('Gamma', 41)] logger.debug('kLines : {}'.format(kLines)) xx, xt, xl = get_kvec_abscissa(lat, kLines) refxl = ['L', 'Γ', 'X', 'U|K', 'Γ'] refxt = [0, 5.44140, 11.724583399882238, 13.946024868961421, 20.610349276198971] self.assertListEqual(xl, refxl) nptest.assert_almost_equal(xt, refxt, 5) self.assertAlmostEqual(xx[-1], xt[-1]) self.assertEqual(len(xx), kLines[-1][-1]+1)
def test_get_kvec_abscissa2(self): """Can we get the bandstructure and extract the kvector info""" latticeinfo = {'type': 'FCC', 'param': 1.} lat = Lattice(latticeinfo) database = Database() src = 'test_dftbutils/bs' get_bandstructure({'workroot': '.'}, database, src, 'test', latticeinfo=latticeinfo) kLines = database.get_item('test', 'kLines') bands = database.get_item('test', 'bands') logger.debug('Bands.shape: {}'.format(bands.shape)) logger.debug('kLines : {}'.format(kLines)) xx, xt, xl = get_kvec_abscissa(lat, kLines) refxl = ['X', 'Γ', 'K', 'L', 'Γ'] refxt = [0, 6.28319, 12.94751, 16.79516, 22.23656] self.assertListEqual(xl, refxl) nptest.assert_almost_equal(xt, refxt, 5) self.assertAlmostEqual(xx[-1], xt[-1]) self.assertEqual(len(xx), kLines[-1][-1]+1)
def get_bandstructure(implargs, database, source, model, detailfile='detailed.out', bandsfile='bands_tot.dat', hsdfile='dftb_pin.hsd', latticeinfo=None, *args, **kwargs): """Get bandstructure and related data from dftb+. Assume that `source` is the execution directory where `detailed.out`, and `bands_tot.dat` can be found. Additionally, the parsed input of dftb+ -- `dftb_pin.hsd` is also checked if lattice info is given, in order to analyse k-paths and provide data for subsequent plotting. """ logger = implargs.get('logger', LOGGER) workroot = implargs.get('workroot', '.') assert isdir(expanduser(joinpath(workroot, source))) fin1 = joinpath(abspath(expanduser(workroot)), source, detailfile) fin2 = joinpath(abspath(expanduser(workroot)), source, bandsfile) fin3 = joinpath(abspath(expanduser(workroot)), source, hsdfile) data = Bandstructure.fromfiles(fin1, fin2) # if latticeinfo is not None: lattice = Lattice(latticeinfo) kLines, kLinesDict = get_klines(lattice, hsdfile=fin3) kvec, kticks, klabels = get_kvec_abscissa(lattice, kLines) data.update({'lattice': lattice, 'kLines': kLines, 'kLinesDict': kLinesDict, 'kvector': kvec, 'kticklabels': list(zip(kticks, klabels)), }) #logger.debug(data['lattice']) #logger.debug(data['kLines']) #logger.debug(data['kLinesDict']) try: # assume model in database database.get(model).update(data) except (KeyError, AttributeError): # model not in database database.update({model: data})
def test_monoclinic_facecentered(self): """Face-centered Monoclinic (MCLC)""" a, b, c, beta = 12.23, 3.04, 5.8, 103.70 lat = Lattice({'type': 'MCLC', 'param': [a, b, c, beta]}) logger.debug(lat)
def test_monoclinic(self): """Monoclinic (MCL)""" a, b, c, angle = 5.17500, 5.17500, 5.29100, 80.78 lat = Lattice({'type': 'MCL', 'param': [a, b, c, angle]}) logger.debug(lat)
def test_rhombohedral(self): """Rhombohedral (RHL)""" a, angle = 5.32208613808, 55.8216166097 lat = Lattice({'type': 'RHL', 'param': [a, angle]}) logger.debug(lat)
def test_hexagonal(self): """Hexagonal (HEX)""" a = 1.0 c = 2.0 lat = Lattice({'type': 'HEX', 'param': [a, c]}) logger.debug(lat)
def test_facecenteredcubic(self): """Face centered cubic (FCC)""" latinfo = {'type': 'FCC', 'param': 1.0} lat = Lattice(latinfo) logger.debug(lat)
def test_bodycenteredcubic(self): """Body centered cubic (BCC)""" latinfo = {'type': 'BCC', 'param': 1.0} lat = Lattice(latinfo) logger.debug(lat)
def test_simplecubic(self): """Simple cubic (CUB)""" latinfo = {'type': 'CUB', 'param': 1.0} lat = Lattice(latinfo) logger.debug(lat)