def test_micro_pyawk(self): filename = os.path.join(test_dir, "OUTCAR") data = [] def f(x, y): data.append(y.group(1).strip()) f2 = lambda x, y: y micro_pyawk(filename, [["POTCAR:(.*)", f2, f]]) self.assertEqual(len(data), 6)
def test_micro_pyawk(self): filename = os.path.join(test_dir, "OUTCAR") data = [] def f(x, y): data.append(y.group(1).strip()) f2 = lambda x, y: y micro_pyawk(filename, [["POTCAR:(.*)", f2, f]]) self.assertEqual(len(data), 6)
def test_micro_pyawk(self): filename = os.path.join(PymatgenTest.TEST_FILES_DIR, "OUTCAR") data = [] def f(x, y): data.append(y.group(1).strip()) def f2(x, y): return y micro_pyawk(filename, [["POTCAR:(.*)", f2, f]]) self.assertEqual(len(data), 6)
def read_berry_ev(self, fname): """ Read berry_ev in pymatgen way. """ berry_ev = [] for spin in [1, 2]: search = [] def func_berry_ev(results, match): results.berry = np.array([ float(match.group(1)), float(match.group(2)), float(match.group(3)), ]) search.append([ r"Spin component " + str(spin) + "\s" r"*e<r>_ev=\( *([-0-9.Ee+]*) *([-0-9.Ee+]*) " r"*([-0-9.Ee+]*) *\)", None, func_berry_ev ]) results = micro_pyawk(fname, search, self) berry_ev.append(results.berry) # average over spin components 1 and 2 berry_ev = np.mean(berry_ev, axis=0) return (berry_ev)