Skip to content

Commit

Permalink
add outcar tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gpetretto committed Sep 6, 2022
1 parent 350f992 commit 1911784
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions pymatgen/io/vasp/tests/test_outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1543,6 +1543,34 @@ def test_energies(self):
self.assertAlmostEqual(o.final_energy_wo_entrp, -15.83863167)
self.assertAlmostEqual(o.final_fr_energy, -15.92115453)

def test_read_table_pattern(self):
outcar = Outcar(self.TEST_FILES_DIR / "OUTCAR")

header_pattern = r"\(the norm of the test charge is\s+[\.\-\d]+\)"
table_pattern = r"((?:\s+\d+\s*[\.\-\d]+)+)"
footer_pattern = r"\s+E-fermi :"

pots = outcar.read_table_pattern(header_pattern, table_pattern, footer_pattern, last_one_only=True)
ref_last = [
[" 1 -26.0704 2 -45.5046 3 -45.5046 4 -72.9539 5 -73.0621"],
[" 6 -72.9539 7 -73.0621"],
]
self.assertEqual(pots, ref_last)

pots = outcar.read_table_pattern(
header_pattern, table_pattern, footer_pattern, last_one_only=False, first_one_only=True
)
ref_first = [
[" 1 -26.1149 2 -45.5359 3 -45.5359 4 -72.9831 5 -73.1068"],
[" 6 -72.9831 7 -73.1068"],
]
self.assertEqual(pots, ref_first)

with self.assertRaises(ValueError):
outcar.read_table_pattern(
header_pattern, table_pattern, footer_pattern, last_one_only=True, first_one_only=True
)


class BSVasprunTest(PymatgenTest):
_multiprocess_shared_ = True
Expand Down

0 comments on commit 1911784

Please sign in to comment.