Ejemplo n.º 1
0
 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)
Ejemplo n.º 2
0
 def test_database(self):
     """Can we update model DB"""
     database = Database()
     self.assertTrue(database is not None)
     #
     database.update('m1', {'i1': 42})
     self.assertDictEqual(database.all(), {'m1': {'i1': 42}})
     #
     database.update('m1', {'i1': 33})
     self.assertDictEqual(database.all(), {'m1': {'i1': 33}})
     #
     database.update('m2', {'i1': 10})
     self.assertDictEqual(database.all(), {'m1': {'i1': 33},
                                           'm2': {'i1': 10}})
     #
     database.update('m2', {'i2': 20})
     self.assertDictEqual(database.all(), {'m1': {'i1': 33},
                                           'm2': {'i1': 10,
                                                  'i2': 20}})
     update(database, 'm1', {'i2': 25})
     self.assertDictEqual(database.all(), {'m1': {'i1': 33,
                                                  'i2': 25},
                                           'm2': {'i1': 10,
                                                  'i2': 20}})
     database.update({'m2': {'i3': 40}})
     self.assertDictEqual(database.all(), {'m1': {'i1': 33,
                                                  'i2': 25},
                                           'm2': {'i3': 40}})
     #
     mdb = database.get('m2')
     self.assertDictEqual(mdb, {'i3': 40})
     self.assertEqual(database.get_item('m1', 'i2'), 25)
     #
     # check query initialised without database
     query = Query('m2', 'i1')
     self.assertEqual(query(database, atleast_1d=False), None)
     query = Query('m2', 'i3')
     self.assertEqual(query(database, atleast_1d=False), 40)
     #
     # check query initialised with database within database.query method
     self.assertEqual(database.query('m1', 'i1', atleast_1d=False), 33)
     nptest.assert_array_equal(database.query('m1', 'i1'), [33])
     #
     database.clear()
     self.assertDictEqual(database.all(), {})