diff --git a/python/vasp/test/_vaspio/EIGENVAL.wrong b/python/vasp/test/_vaspio/EIGENVAL.wrong new file mode 100644 index 00000000..04b5ed4b --- /dev/null +++ b/python/vasp/test/_vaspio/EIGENVAL.wrong @@ -0,0 +1,50 @@ + 1 1 1 1 + 0.1333597E+02 0.2587511E-09 0.2587511E-09 0.2587511E-09 0.5000000E-15 + 1.000000000000000E-004 + CAR + V + 11 4 9 + + 0.0000000E+00 0.0000000E+00 0.0000000E+00 0.3703704E-01 + 1 -31.099965 + 2 -31.099965 + 3 -31.099965 + 4 -0.813470 + 5 5.974027 + 6 5.974027 + 7 5.974027 + 8 7.986328 + 9 7.986328 + + 0.3333333E+00 0.0000000E+00 0.0000000E+00 0.4444444E+00 + 1 -31.819277 + 2 -31.322999 + 3 -31.105684 + 4 2.193081 + 5 4.784864 + 6 5.839340 + 7 7.833446 + 8 8.202781 + 9 8.589551 + + 0.3333333E+00 0.3333333E+00 0.0000000E+00 0.2962963E+00 + 1 -31.750021 + 2 -31.750021 + 3 -31.217560 + 4 3.978315 + 5 4.708263 + 6 4.708263 + 7 8.262522 + 8 8.262522 + 9 14.771374 + + -0.3333333E+00 0.3333333E+00 0.3333333E+00 0.2222222E+00 + 1 -31.719893 + 2 -31.577292 + 3 -31.577292 + 4 3.383714 + 5 3.756320 + 6 7.355029 + 7 7.355029 + 8 8.411511 + 9 11.054129 diff --git a/python/vasp/test/_vaspio/test_eigenval.py b/python/vasp/test/_vaspio/test_eigenval.py index 6a55f548..d94047a2 100644 --- a/python/vasp/test/_vaspio/test_eigenval.py +++ b/python/vasp/test/_vaspio/test_eigenval.py @@ -22,6 +22,7 @@ class TestEigenval(mytest.MyTestCase): Scenarios: - correct EIGENVAL file + - wrong EIGENVAL file from old versions of VASP """ # Scenario 1 @@ -48,3 +49,12 @@ class TestEigenval(mytest.MyTestCase): expected = _rpath + 'EIGENVAL.example.out' self.assertFileEqual(testout, expected) +# Scenario 2 + def test_bad_example(self): + filename = 'EIGENVAL.wrong' + eigenval = Eigenval() + + err_mess = "EIGENVAL file is incorrect" + with self.assertRaisesRegexp(AssertionError, err_mess): + eigenval.from_file(vasp_dir=_rpath, eig_filename=filename) + diff --git a/python/vasp/vaspio.py b/python/vasp/vaspio.py index efdfac75..4498cfef 100644 --- a/python/vasp/vaspio.py +++ b/python/vasp/vaspio.py @@ -445,6 +445,7 @@ class Eigenval: for ib in xrange(self.nband): sline = f.next().split() tmp = map(float, sline) + assert len(tmp) == 2 * self.ispin + 1, "EIGENVAL file is incorrect (probably from old versions of VASP)" self.eigs[ik, ib, :] = tmp[1:self.ispin+1] self.ferw[ik, ib, :] = tmp[self.ispin+1:]