def test_get_kpoint_weights(self): for name in ["SrTiO3", "LiFePO4", "Graphite"]: s = PymatgenTest.get_structure(name) a = SpacegroupAnalyzer(s) ir_mesh = a.get_ir_reciprocal_mesh((4, 4, 4)) weights = [i[1] for i in ir_mesh] weights = np.array(weights) / sum(weights) for i, w in zip(weights, a.get_kpoint_weights([i[0] for i in ir_mesh])): self.assertAlmostEqual(i, w) for name in ["SrTiO3", "LiFePO4", "Graphite"]: s = PymatgenTest.get_structure(name) a = SpacegroupAnalyzer(s) ir_mesh = a.get_ir_reciprocal_mesh((1, 2, 3)) weights = [i[1] for i in ir_mesh] weights = np.array(weights) / sum(weights) for i, w in zip(weights, a.get_kpoint_weights([i[0] for i in ir_mesh])): self.assertAlmostEqual(i, w) v = Vasprun(os.path.join(test_dir, "vasprun.xml")) a = SpacegroupAnalyzer(v.final_structure) wts = a.get_kpoint_weights(v.actual_kpoints) for w1, w2 in zip(v.actual_kpoints_weights, wts): self.assertAlmostEqual(w1, w2) kpts = [[0, 0, 0], [0.15, 0.15, 0.15], [0.2, 0.2, 0.2]] self.assertRaises(ValueError, a.get_kpoint_weights, kpts)
def test_get_kpoint_weights(self): for name in ["SrTiO3", "LiFePO4", "Graphite"]: s = PymatgenTest.get_structure(name) a = SpacegroupAnalyzer(s) ir_mesh = a.get_ir_reciprocal_mesh((4, 4, 4)) weights = [i[1] for i in ir_mesh] weights = np.array(weights) / sum(weights) for i, w in zip(weights, a.get_kpoint_weights([i[0] for i in ir_mesh])): self.assertAlmostEqual(i, w) for name in ["SrTiO3", "LiFePO4", "Graphite"]: s = PymatgenTest.get_structure(name) a = SpacegroupAnalyzer(s) ir_mesh = a.get_ir_reciprocal_mesh((1, 2, 3)) weights = [i[1] for i in ir_mesh] weights = np.array(weights) / sum(weights) for i, w in zip(weights, a.get_kpoint_weights([i[0] for i in ir_mesh])): self.assertAlmostEqual(i, w) v = Vasprun(os.path.join(test_dir, "vasprun.xml")) a = SpacegroupAnalyzer(v.final_structure) wts = a.get_kpoint_weights(v.actual_kpoints) for w1, w2 in zip(v.actual_kpoints_weights, wts): self.assertAlmostEqual(w1, w2) kpts = [[0, 0, 0], [0.15, 0.15, 0.15], [0.2, 0.2, 0.2]] self.assertRaises(ValueError, a.get_kpoint_weights, kpts)
def test_get_kpoint_weights(self): s = PymatgenTest.get_structure("SrTiO3") a = SpacegroupAnalyzer(s) ir_mesh = a.get_ir_reciprocal_mesh() for i, w in zip(ir_mesh, a.get_kpoint_weights([i[0] for i in ir_mesh])): self.assertEqual(i[1], w)