3
0
mirror of https://github.com/triqs/dft_tools synced 2024-12-22 04:13:47 +01:00

Merge branch 'vasp' of ssh://github.com/TRIQS/dft_tools into vasp

This commit is contained in:
Oleg E. Peil 2015-10-16 15:56:49 +02:00
commit 82694a4c51
19 changed files with 461 additions and 117 deletions

View File

@ -0,0 +1,5 @@
r"""
The sole role of this module is to determine the current path by
examining rpath.__file__.
"""
pass

View File

@ -1 +1 @@
PYTHONPATH=../../python:../../c:$PYTHONPATH python $1 PYTHONPATH=../..:../../../../c:$PYTHONPATH python $1

View File

@ -1,6 +1,10 @@
r""" r"""
Tests of 'parse_general()' defined in ConfigParameters class Tests of 'parse_general()' defined in ConfigParameters class
""" """
import os
import rpath
_rpath = os.path.dirname(rpath.__file__) + '/'
import arraytest import arraytest
import numpy as np import numpy as np
from inpconf import ConfigParameters from inpconf import ConfigParameters
@ -22,7 +26,7 @@ class TestParseGeneral(arraytest.ArrayTestCase):
""" """
# Scenario 1 # Scenario 1
def test_example(self): def test_example(self):
conf_pars = ConfigParameters('example.cfg') conf_pars = ConfigParameters(_rpath + 'example.cfg')
conf_pars.parse_general() conf_pars.parse_general()
res = conf_pars.general res = conf_pars.general
expected = {'basename': 'test_base', 'efermi': 0.1} expected = {'basename': 'test_base', 'efermi': 0.1}

View File

@ -1,6 +1,10 @@
r""" r"""
Tests of 'parse_groups()' defined in ConfigParameters class Tests of 'parse_groups()' defined in ConfigParameters class
""" """
import os
import rpath
_rpath = os.path.dirname(rpath.__file__) + '/'
import arraytest import arraytest
import numpy as np import numpy as np
from inpconf import ConfigParameters from inpconf import ConfigParameters
@ -24,14 +28,14 @@ class TestParseGroups(arraytest.ArrayTestCase):
""" """
# Scenario 1 # Scenario 1
def test_gr_required(self): def test_gr_required(self):
conf_pars = ConfigParameters('parse_groups_1.cfg') conf_pars = ConfigParameters(_rpath + 'parse_groups_1.cfg')
err_mess = "Required parameter" err_mess = "Required parameter"
with self.assertRaisesRegexp(Exception, err_mess): with self.assertRaisesRegexp(Exception, err_mess):
conf_pars.parse_groups() conf_pars.parse_groups()
# Scenario 2 # Scenario 2
def test_example(self): def test_example(self):
conf_pars = ConfigParameters('example.cfg') conf_pars = ConfigParameters(_rpath + 'example.cfg')
conf_pars.parse_groups() conf_pars.parse_groups()
res = conf_pars.groups res = conf_pars.groups
expected = [{'index': 1, 'shells': [1, 2], 'emin': -7.6, 'emax': 3.0, expected = [{'index': 1, 'shells': [1, 2], 'emin': -7.6, 'emax': 3.0,

View File

@ -1,6 +1,10 @@
r""" r"""
Tests of 'parse_input()' defined in ConfigParameters class Tests of 'parse_input()' defined in ConfigParameters class
""" """
import os
import rpath
_rpath = os.path.dirname(rpath.__file__) + '/'
import arraytest import arraytest
import numpy as np import numpy as np
from inpconf import ConfigParameters from inpconf import ConfigParameters
@ -32,35 +36,35 @@ class TestParseInput(arraytest.ArrayTestCase):
""" """
# Scenario 1 # Scenario 1
def test_no_group(self): def test_no_group(self):
conf_pars = ConfigParameters('input_test_1.cfg') conf_pars = ConfigParameters(_rpath + 'input_test_1.cfg')
err_mess = "At least one group" err_mess = "At least one group"
with self.assertRaisesRegexp(AssertionError, err_mess): with self.assertRaisesRegexp(AssertionError, err_mess):
conf_pars.parse_input() conf_pars.parse_input()
# Scenario 2 # Scenario 2
def test_gr_required(self): def test_gr_required(self):
conf_pars = ConfigParameters('input_test_2.cfg') conf_pars = ConfigParameters(_rpath + 'input_test_2.cfg')
err_mess = "One \[Shell\] section is" err_mess = "One \[Shell\] section is"
with self.assertRaisesRegexp(KeyError, err_mess): with self.assertRaisesRegexp(KeyError, err_mess):
conf_pars.parse_input() conf_pars.parse_input()
# Scenario 3 # Scenario 3
def test_no_shell(self): def test_no_shell(self):
conf_pars = ConfigParameters('input_test_3.cfg') conf_pars = ConfigParameters(_rpath + 'input_test_3.cfg')
err_mess = "Shell 3 referenced in" err_mess = "Shell 3 referenced in"
with self.assertRaisesRegexp(Exception, err_mess): with self.assertRaisesRegexp(Exception, err_mess):
conf_pars.parse_input() conf_pars.parse_input()
# Scenario 4 # Scenario 4
def test_shell_outside_groups(self): def test_shell_outside_groups(self):
conf_pars = ConfigParameters('input_test_4.cfg') conf_pars = ConfigParameters(_rpath + 'input_test_4.cfg')
err_mess = "Some shells are not inside" err_mess = "Some shells are not inside"
with self.assertRaisesRegexp(AssertionError, err_mess): with self.assertRaisesRegexp(AssertionError, err_mess):
conf_pars.parse_input() conf_pars.parse_input()
# Scenario 5 # Scenario 5
def test_example(self): def test_example(self):
conf_pars = ConfigParameters('example.cfg') conf_pars = ConfigParameters(_rpath + 'example.cfg')
conf_pars.parse_input() conf_pars.parse_input()
# with open('parse_input.output.test', 'wt') as f: # with open('parse_input.output.test', 'wt') as f:
# f.write("Shells:\n") # f.write("Shells:\n")
@ -84,7 +88,7 @@ Groups:
# Scenario 6 # Scenario 6
def test_example_no_groups(self): def test_example_no_groups(self):
conf_pars = ConfigParameters('example_nogroup.cfg') conf_pars = ConfigParameters(_rpath + 'example_nogroup.cfg')
conf_pars.parse_input() conf_pars.parse_input()
# with open('parse_input.output.test', 'wt') as f: # with open('parse_input.output.test', 'wt') as f:
# f.write("Shells:\n") # f.write("Shells:\n")

View File

@ -1,6 +1,10 @@
r""" r"""
Tests of 'parse_parameter_set()' defined in ConfigParameters class Tests of 'parse_parameter_set()' defined in ConfigParameters class
""" """
import os
import rpath
_rpath = os.path.dirname(rpath.__file__) + '/'
import arraytest import arraytest
import numpy as np import numpy as np
from inpconf import ConfigParameters from inpconf import ConfigParameters
@ -29,7 +33,7 @@ class TestParseParameterSet(arraytest.ArrayTestCase):
""" """
""" """
# Dummy ConfigParameters object # Dummy ConfigParameters object
self.cpars = ConfigParameters('test1.cfg') self.cpars = ConfigParameters(_rpath + 'test1.cfg')
# Scenario 1 # Scenario 1
def test_sh_required(self): def test_sh_required(self):

View File

@ -1,6 +1,10 @@
r""" r"""
Tests of 'parse_shells()' defined in ConfigParameters class Tests of 'parse_shells()' defined in ConfigParameters class
""" """
import os
import rpath
_rpath = os.path.dirname(rpath.__file__) + '/'
import arraytest import arraytest
import numpy as np import numpy as np
from inpconf import ConfigParameters from inpconf import ConfigParameters
@ -29,28 +33,28 @@ class TestParseShells(arraytest.ArrayTestCase):
""" """
# Scenario 1 # Scenario 1
def test_no_shell(self): def test_no_shell(self):
conf_pars = ConfigParameters('parse_shells_1.cfg') conf_pars = ConfigParameters(_rpath + 'parse_shells_1.cfg')
err_mess = "No projected shells" err_mess = "No projected shells"
with self.assertRaisesRegexp(AssertionError, err_mess): with self.assertRaisesRegexp(AssertionError, err_mess):
conf_pars.parse_shells() conf_pars.parse_shells()
# Scenario 2 # Scenario 2
def test_bad_indices(self): def test_bad_indices(self):
conf_pars = ConfigParameters('parse_shells_2.cfg') conf_pars = ConfigParameters(_rpath + 'parse_shells_2.cfg')
err_mess = "Failed to extract shell indices" err_mess = "Failed to extract shell indices"
with self.assertRaisesRegexp(ValueError, err_mess): with self.assertRaisesRegexp(ValueError, err_mess):
conf_pars.parse_shells() conf_pars.parse_shells()
# Scenario 3 # Scenario 3
def test_sh_required(self): def test_sh_required(self):
conf_pars = ConfigParameters('parse_shells_3.cfg') conf_pars = ConfigParameters(_rpath + 'parse_shells_3.cfg')
err_mess = "Required parameter" err_mess = "Required parameter"
with self.assertRaisesRegexp(Exception, err_mess): with self.assertRaisesRegexp(Exception, err_mess):
conf_pars.parse_shells() conf_pars.parse_shells()
# Scenario 4 # Scenario 4
def test_two_shells(self): def test_two_shells(self):
conf_pars = ConfigParameters('parse_shells_4.cfg') conf_pars = ConfigParameters(_rpath + 'parse_shells_4.cfg')
conf_pars.parse_shells() conf_pars.parse_shells()
res = conf_pars.shells res = conf_pars.shells
expected = [{'user_index': 1, 'lshell': 2, 'ion_list': np.array([4, 5, 6, 7])}, expected = [{'user_index': 1, 'lshell': 2, 'ion_list': np.array([4, 5, 6, 7])},

View File

@ -1,6 +1,10 @@
r""" r"""
Tests of special parseres defined in ConfigParameters class Tests of special parseres defined in ConfigParameters class
""" """
import os
import rpath
_rpath = os.path.dirname(rpath.__file__) + '/'
import arraytest import arraytest
import numpy as np import numpy as np
from inpconf import ConfigParameters from inpconf import ConfigParameters
@ -26,7 +30,7 @@ class TestParseStringLogical(arraytest.ArrayTestCase):
""" """
""" """
# Dummy ConfigParameters object # Dummy ConfigParameters object
self.cpars = ConfigParameters('test1.cfg') self.cpars = ConfigParameters(_rpath + 'test1.cfg')
# Scenario 1 # Scenario 1
def test_true(self): def test_true(self):
@ -66,7 +70,7 @@ class TestParseStringIonList(arraytest.ArrayTestCase):
""" """
""" """
# Dummy ConfigParameters object # Dummy ConfigParameters object
self.cpars = ConfigParameters('test1.cfg') self.cpars = ConfigParameters(_rpath + 'test1.cfg')
# Scenario 1 # Scenario 1
def test_simple_list(self): def test_simple_list(self):
@ -123,7 +127,7 @@ class TestParseStringTmatrix(arraytest.ArrayTestCase):
""" """
""" """
# Dummy ConfigParameters object # Dummy ConfigParameters object
self.cpars = ConfigParameters('test1.cfg') self.cpars = ConfigParameters(_rpath + 'test1.cfg')
# Scenario 1 # Scenario 1
def test_number_of_columns(self): def test_number_of_columns(self):

View File

@ -3,48 +3,114 @@
1.000000000000000E-004 1.000000000000000E-004
CAR CAR
V V
11 4 9 11 10 9
0.0000000E+00 0.0000000E+00 0.0000000E+00 0.3703704E-01 0.0000000E+00 0.0000000E+00 0.0000000E+00 0.8000000E-02
1 -31.099965 1 -30.901243 1.000000
2 -31.099965 2 -30.901242 1.000000
3 -31.099965 3 -30.901242 1.000000
4 -0.813470 4 -0.812822 1.000000
5 5.974027 5 6.116281 0.307472
6 5.974027 6 6.116282 0.000314
7 5.974027 7 6.116282 0.000000
8 7.986328 8 8.139559 0.000000
9 7.986328 9 8.139559 0.000000
0.3333333E+00 0.0000000E+00 0.0000000E+00 0.4444444E+00 0.2000000E+00 0.0000000E+00 0.0000000E+00 0.9600000E-01
1 -31.819277 1 -31.244548 1.000000
2 -31.322999 2 -31.006017 1.000000
3 -31.105684 3 -30.904003 1.000000
4 2.193081 4 0.680258 1.000000
5 4.784864 5 5.527848 0.997357
6 5.839340 6 5.837887 0.407717
7 7.833446 7 7.226963 0.000000
8 8.202781 8 7.781889 0.000000
9 8.589551 9 8.207361 0.000000
0.3333333E+00 0.3333333E+00 0.0000000E+00 0.2962963E+00 0.4000000E+00 0.0000000E+00 0.0000000E+00 0.9600000E-01
1 -31.750021 1 -31.771778 1.000000
2 -31.750021 2 -31.171899 1.000000
3 -31.217560 3 -30.908401 1.000000
4 3.978315 4 2.486834 1.000000
5 4.708263 5 4.687631 1.003771
6 4.708263 6 6.633241 -0.148217
7 8.262522 7 8.121131 0.000000
8 8.262522 8 8.444990 0.000000
9 14.771374 9 9.443636 0.000000
-0.3333333E+00 0.3333333E+00 0.3333333E+00 0.2222222E+00 0.2000000E+00 0.2000000E+00 0.0000000E+00 0.1920000E+00
1 -31.719893 1 -31.593915 1.000000
2 -31.577292 2 -31.156860 1.000000
3 -31.577292 3 -30.976267 1.000000
4 3.383714 4 2.768444 1.000000
5 3.756320 5 4.858815 1.008186
6 7.355029 6 5.229541 1.085485
7 7.355029 7 7.709737 0.000000
8 8.411511 8 8.541449 0.000000
9 11.054129 9 9.490980 0.000000
0.4000000E+00 0.2000000E+00 -0.5551115E-16 0.1920000E+00
1 -31.739891 1.000000
2 -31.337400 1.000000
3 -30.997116 1.000000
4 3.394894 1.000000
5 4.629829 1.000179
6 5.695587 0.810394
7 8.098534 0.000000
8 8.743598 0.000000
9 12.244586 0.000000
0.2000000E+00 0.2000000E+00 0.2000000E+00 0.6400000E-01
1 -31.617656 1.000000
2 -31.220150 1.000000
3 -31.220150 1.000000
4 4.450254 1.000000
5 4.450254 1.000000
6 4.634359 1.062133
7 8.491526 0.000000
8 8.491526 0.000000
9 12.973660 0.000000
-0.2000000E+00 0.2000000E+00 0.2000000E+00 0.4800000E-01
1 -31.296977 1.000000
2 -31.117861 1.000000
3 -31.117861 1.000000
4 1.927890 1.000000
5 5.995969 0.879283
6 6.272225 -0.010798
7 6.272226 0.000000
8 7.198547 0.000000
9 8.910235 0.000000
-0.4000000E+00 0.4000000E+00 0.2000000E+00 0.1920000E+00
1 -31.682485 1.000000
2 -31.294549 1.000000
3 -31.142973 1.000000
4 3.381464 1.000000
5 4.651227 1.002211
6 5.929509 0.183505
7 7.231965 0.000000
8 9.259558 0.000000
9 10.660847 0.000000
-0.4000000E+00 -0.4000000E+00 0.2000000E+00 0.6400000E-01
1 -31.585360 1.000000
2 -31.585359 1.000000
3 -31.188820 1.000000
4 3.846295 1.000000
5 3.846295 1.000298
6 5.810197 0.324984
7 8.723375 0.000000
8 8.723376 0.000000
9 15.381038 0.000000
-0.4000000E+00 0.4000000E+00 0.4000000E+00 0.4800000E-01
1 -31.554619 1.000000
2 -31.488158 1.000000
3 -31.488158 1.000000
4 3.090314 1.000000
5 3.105025 1.000861
6 8.500437 -0.068292
7 8.500437 0.000000
8 9.144518 0.000000
9 13.491662 0.000000

View File

@ -1,52 +1,218 @@
nq = 1 nq = 1
ispin = 1 ispin = 1
nelect = 11 nelect = 11
nktot = 4 nktot = 10
nband = 9 nband = 9
kpts: kpts:
[[ 0. 0. 0. ] [[ 0.00000000e+00 0.00000000e+00 0.00000000e+00]
[ 0.3333333 0. 0. ] [ 2.00000000e-01 0.00000000e+00 0.00000000e+00]
[ 0.3333333 0.3333333 0. ] [ 4.00000000e-01 0.00000000e+00 0.00000000e+00]
[-0.3333333 0.3333333 0.3333333]] [ 2.00000000e-01 2.00000000e-01 0.00000000e+00]
[ 4.00000000e-01 2.00000000e-01 -5.55111500e-17]
[ 2.00000000e-01 2.00000000e-01 2.00000000e-01]
[ -2.00000000e-01 2.00000000e-01 2.00000000e-01]
[ -4.00000000e-01 4.00000000e-01 2.00000000e-01]
[ -4.00000000e-01 -4.00000000e-01 2.00000000e-01]
[ -4.00000000e-01 4.00000000e-01 4.00000000e-01]]
kwghts: kwghts:
[ 0.03703704 0.4444444 0.2962963 0.2222222 ] [ 0.008 0.096 0.096 0.192 0.192 0.064 0.048 0.192 0.064 0.048]
eigs: eigs:
[[[-31.099965] [[[-30.901243]
[-31.099965] [-30.901242]
[-31.099965] [-30.901242]
[ -0.81347 ] [ -0.812822]
[ 5.974027] [ 6.116281]
[ 5.974027] [ 6.116282]
[ 5.974027] [ 6.116282]
[ 7.986328] [ 8.139559]
[ 7.986328]] [ 8.139559]]
[[-31.819277] [[-31.244548]
[-31.322999] [-31.006017]
[-31.105684] [-30.904003]
[ 2.193081] [ 0.680258]
[ 4.784864] [ 5.527848]
[ 5.83934 ] [ 5.837887]
[ 7.833446] [ 7.226963]
[ 8.202781] [ 7.781889]
[ 8.589551]] [ 8.207361]]
[[-31.750021] [[-31.771778]
[-31.750021] [-31.171899]
[-31.21756 ] [-30.908401]
[ 3.978315] [ 2.486834]
[ 4.708263] [ 4.687631]
[ 4.708263] [ 6.633241]
[ 8.262522] [ 8.121131]
[ 8.262522] [ 8.44499 ]
[ 14.771374]] [ 9.443636]]
[[-31.719893] [[-31.593915]
[-31.577292] [-31.15686 ]
[-31.577292] [-30.976267]
[ 3.383714] [ 2.768444]
[ 3.75632 ] [ 4.858815]
[ 7.355029] [ 5.229541]
[ 7.355029] [ 7.709737]
[ 8.411511] [ 8.541449]
[ 11.054129]]] [ 9.49098 ]]
[[-31.739891]
[-31.3374 ]
[-30.997116]
[ 3.394894]
[ 4.629829]
[ 5.695587]
[ 8.098534]
[ 8.743598]
[ 12.244586]]
[[-31.617656]
[-31.22015 ]
[-31.22015 ]
[ 4.450254]
[ 4.450254]
[ 4.634359]
[ 8.491526]
[ 8.491526]
[ 12.97366 ]]
[[-31.296977]
[-31.117861]
[-31.117861]
[ 1.92789 ]
[ 5.995969]
[ 6.272225]
[ 6.272226]
[ 7.198547]
[ 8.910235]]
[[-31.682485]
[-31.294549]
[-31.142973]
[ 3.381464]
[ 4.651227]
[ 5.929509]
[ 7.231965]
[ 9.259558]
[ 10.660847]]
[[-31.58536 ]
[-31.585359]
[-31.18882 ]
[ 3.846295]
[ 3.846295]
[ 5.810197]
[ 8.723375]
[ 8.723376]
[ 15.381038]]
[[-31.554619]
[-31.488158]
[-31.488158]
[ 3.090314]
[ 3.105025]
[ 8.500437]
[ 8.500437]
[ 9.144518]
[ 13.491662]]]
ferw:
[[[ 1.00000000e+00]
[ 1.00000000e+00]
[ 1.00000000e+00]
[ 1.00000000e+00]
[ 3.07472000e-01]
[ 3.14000000e-04]
[ 0.00000000e+00]
[ 0.00000000e+00]
[ 0.00000000e+00]]
[[ 1.00000000e+00]
[ 1.00000000e+00]
[ 1.00000000e+00]
[ 1.00000000e+00]
[ 9.97357000e-01]
[ 4.07717000e-01]
[ 0.00000000e+00]
[ 0.00000000e+00]
[ 0.00000000e+00]]
[[ 1.00000000e+00]
[ 1.00000000e+00]
[ 1.00000000e+00]
[ 1.00000000e+00]
[ 1.00377100e+00]
[ -1.48217000e-01]
[ 0.00000000e+00]
[ 0.00000000e+00]
[ 0.00000000e+00]]
[[ 1.00000000e+00]
[ 1.00000000e+00]
[ 1.00000000e+00]
[ 1.00000000e+00]
[ 1.00818600e+00]
[ 1.08548500e+00]
[ 0.00000000e+00]
[ 0.00000000e+00]
[ 0.00000000e+00]]
[[ 1.00000000e+00]
[ 1.00000000e+00]
[ 1.00000000e+00]
[ 1.00000000e+00]
[ 1.00017900e+00]
[ 8.10394000e-01]
[ 0.00000000e+00]
[ 0.00000000e+00]
[ 0.00000000e+00]]
[[ 1.00000000e+00]
[ 1.00000000e+00]
[ 1.00000000e+00]
[ 1.00000000e+00]
[ 1.00000000e+00]
[ 1.06213300e+00]
[ 0.00000000e+00]
[ 0.00000000e+00]
[ 0.00000000e+00]]
[[ 1.00000000e+00]
[ 1.00000000e+00]
[ 1.00000000e+00]
[ 1.00000000e+00]
[ 8.79283000e-01]
[ -1.07980000e-02]
[ 0.00000000e+00]
[ 0.00000000e+00]
[ 0.00000000e+00]]
[[ 1.00000000e+00]
[ 1.00000000e+00]
[ 1.00000000e+00]
[ 1.00000000e+00]
[ 1.00221100e+00]
[ 1.83505000e-01]
[ 0.00000000e+00]
[ 0.00000000e+00]
[ 0.00000000e+00]]
[[ 1.00000000e+00]
[ 1.00000000e+00]
[ 1.00000000e+00]
[ 1.00000000e+00]
[ 1.00029800e+00]
[ 3.24984000e-01]
[ 0.00000000e+00]
[ 0.00000000e+00]
[ 0.00000000e+00]]
[[ 1.00000000e+00]
[ 1.00000000e+00]
[ 1.00000000e+00]
[ 1.00000000e+00]
[ 1.00086100e+00]
[ -6.82920000e-02]
[ 0.00000000e+00]
[ 0.00000000e+00]
[ 0.00000000e+00]]]

View File

@ -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

View File

@ -0,0 +1,5 @@
r"""
The sole role of this module is to determine the current path by
examining rpath.__file__.
"""
pass

View File

@ -1 +1 @@
PYTHONPATH=../../python:../../c:$PYTHONPATH python $1 PYTHONPATH=../..:../../../../c:$PYTHONPATH python $1

View File

@ -1,6 +1,10 @@
r""" r"""
Tests for class 'Doscar' from module 'vaspio' Tests for class 'Doscar' from module 'vaspio'
""" """
import os
import rpath
_rpath = os.path.dirname(rpath.__file__) + '/'
import mytest import mytest
import numpy as np import numpy as np
from vaspio import Doscar from vaspio import Doscar
@ -24,7 +28,7 @@ class TestDoscar(mytest.MyTestCase):
def test_example(self): def test_example(self):
filename = 'DOSCAR.example' filename = 'DOSCAR.example'
doscar = Doscar() doscar = Doscar()
doscar.from_file(vasp_dir='./', dos_filename=filename) doscar.from_file(vasp_dir=_rpath, dos_filename=filename)
test_efermi = doscar.efermi test_efermi = doscar.efermi
expected = 5.84395237 expected = 5.84395237

View File

@ -1,6 +1,10 @@
r""" r"""
Tests for class 'Eigneval' from module 'vaspio' Tests for class 'Eigneval' from module 'vaspio'
""" """
import os
import rpath
_rpath = os.path.dirname(rpath.__file__) + '/'
import mytest import mytest
import numpy as np import numpy as np
from vaspio import Eigenval from vaspio import Eigenval
@ -18,15 +22,16 @@ class TestEigenval(mytest.MyTestCase):
Scenarios: Scenarios:
- correct EIGENVAL file - correct EIGENVAL file
- wrong EIGENVAL file from old versions of VASP
""" """
# Scenario 1 # Scenario 1
def test_example(self): def test_example(self):
filename = 'EIGENVAL.example' filename = 'EIGENVAL.example'
eigenval = Eigenval() eigenval = Eigenval()
eigenval.from_file(vasp_dir='./', eig_filename=filename) eigenval.from_file(vasp_dir=_rpath, eig_filename=filename)
testout = 'EIGENVAL.example.out.test' testout = _rpath + 'EIGENVAL.example.out.test'
with open(testout, 'w') as f: with open(testout, 'w') as f:
writeline = lambda s: f.write(s + '\n') writeline = lambda s: f.write(s + '\n')
writeprop = lambda pname: writeline("%s = %s"%(pname, eigenval.__dict__[pname])) writeprop = lambda pname: writeline("%s = %s"%(pname, eigenval.__dict__[pname]))
@ -39,7 +44,17 @@ class TestEigenval(mytest.MyTestCase):
writeline("kpts:\n%s"%(eigenval.kpts)) writeline("kpts:\n%s"%(eigenval.kpts))
writeline("kwghts:\n%s"%(eigenval.kwghts)) writeline("kwghts:\n%s"%(eigenval.kwghts))
writeline("eigs:\n%s"%(eigenval.eigs)) writeline("eigs:\n%s"%(eigenval.eigs))
writeline("ferw:\n%s"%(eigenval.ferw))
expected = 'EIGENVAL.example.out' expected = _rpath + 'EIGENVAL.example.out'
self.assertFileEqual(testout, expected) 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)

View File

@ -1,6 +1,10 @@
r""" r"""
Tests for class 'Ibzkpt' from module 'vaspio' Tests for class 'Ibzkpt' from module 'vaspio'
""" """
import os
import rpath
_rpath = os.path.dirname(rpath.__file__) + '/'
import mytest import mytest
import numpy as np import numpy as np
from vaspio import Kpoints from vaspio import Kpoints
@ -25,9 +29,9 @@ class TestIbzkpt(mytest.MyTestCase):
def test_example(self): def test_example(self):
ibz_file = 'IBZKPT.example' ibz_file = 'IBZKPT.example'
kpoints = Kpoints() kpoints = Kpoints()
kpoints.from_file(vasp_dir='./', ibz_filename=ibz_file) kpoints.from_file(vasp_dir=_rpath, ibz_filename=ibz_file)
testout = 'IBZKPT.example.out.test' testout = _rpath + 'IBZKPT.example.out.test'
with open(testout, 'w') as f: with open(testout, 'w') as f:
writeline = lambda s: f.write(s + '\n') writeline = lambda s: f.write(s + '\n')
writeline("nktot = %s"%(kpoints.nktot)) writeline("nktot = %s"%(kpoints.nktot))
@ -36,22 +40,22 @@ class TestIbzkpt(mytest.MyTestCase):
writeline("kpts:\n%s"%(kpoints.kpts)) writeline("kpts:\n%s"%(kpoints.kpts))
writeline("tets:\n%s"%(kpoints.itet)) writeline("tets:\n%s"%(kpoints.itet))
expected = 'IBZKPT.example.out' expected = _rpath + 'IBZKPT.example.out'
self.assertFileEqual(testout, expected) self.assertFileEqual(testout, expected)
# Scenario 2 # Scenario 2
def test_notet(self): def test_notet(self):
ibz_file = 'IBZKPT.notet' ibz_file = 'IBZKPT.notet'
kpoints = Kpoints() kpoints = Kpoints()
kpoints.from_file(vasp_dir='./', ibz_filename=ibz_file) kpoints.from_file(vasp_dir=_rpath, ibz_filename=ibz_file)
testout = 'IBZKPT.notet.out.test' testout = _rpath + 'IBZKPT.notet.out.test'
with open(testout, 'w') as f: with open(testout, 'w') as f:
writeline = lambda s: f.write(s + '\n') writeline = lambda s: f.write(s + '\n')
writeline("nktot = %s"%(kpoints.nktot)) writeline("nktot = %s"%(kpoints.nktot))
writeline("kpts:\n%s"%(kpoints.kpts)) writeline("kpts:\n%s"%(kpoints.kpts))
expected = 'IBZKPT.notet.out' expected = _rpath + 'IBZKPT.notet.out'
self.assertFileEqual(testout, expected) self.assertFileEqual(testout, expected)

View File

@ -1,6 +1,10 @@
r""" r"""
Tests for class 'Poscar' from module 'vaspio' Tests for class 'Poscar' from module 'vaspio'
""" """
import os
import rpath
_rpath = os.path.dirname(rpath.__file__) + '/'
import mytest import mytest
import numpy as np import numpy as np
from vaspio import Poscar from vaspio import Poscar
@ -25,9 +29,9 @@ class TestPoscar(mytest.MyTestCase):
def test_example(self): def test_example(self):
filename = 'POSCAR.example' filename = 'POSCAR.example'
poscar = Poscar() poscar = Poscar()
poscar.from_file(vasp_dir='./', poscar_filename=filename) poscar.from_file(vasp_dir=_rpath, poscar_filename=filename)
testout = 'POSCAR.example.out.test' testout = _rpath + 'POSCAR.example.out.test'
with open(testout, 'w') as f: with open(testout, 'w') as f:
writeline = lambda s: f.write(s + '\n') writeline = lambda s: f.write(s + '\n')
writeprop = lambda pname: writeline("%s = %s"%(pname, poscar.__dict__[pname])) writeprop = lambda pname: writeline("%s = %s"%(pname, poscar.__dict__[pname]))
@ -39,14 +43,14 @@ class TestPoscar(mytest.MyTestCase):
writeline("a_brav:\n%s"%(poscar.a_brav)) writeline("a_brav:\n%s"%(poscar.a_brav))
writeline("q_types:\n%s"%(poscar.q_types)) writeline("q_types:\n%s"%(poscar.q_types))
expected = 'POSCAR.example.out' expected = _rpath + 'POSCAR.example.out'
self.assertFileEqual(testout, expected) self.assertFileEqual(testout, expected)
# Scenario 2 # Scenario 2
def test_type_of_ion(self): def test_type_of_ion(self):
filename = 'POSCAR.complex' filename = 'POSCAR.complex'
poscar = Poscar() poscar = Poscar()
poscar.from_file(vasp_dir='./', poscar_filename=filename) poscar.from_file(vasp_dir=_rpath, poscar_filename=filename)
test_types = 4 * [0] + 4 * [1] + 12 * [2] test_types = 4 * [0] + 4 * [1] + 12 * [2]
self.assertListEqual(test_types, poscar.type_of_ion) self.assertListEqual(test_types, poscar.type_of_ion)

View File

@ -1 +1 @@
PYTHONPATH=$HOME/Codes/vasp/vasp5.3/plo_vasp/plovasp/python:$HOME/Codes/vasp/vasp5.3/plo_vasp/plovasp/c:$PYTHONPATH python test_all.py PYTHONPATH=../:../../../c:$PYTHONPATH python test_all.py

View File

@ -445,6 +445,7 @@ class Eigenval:
for ib in xrange(self.nband): for ib in xrange(self.nband):
sline = f.next().split() sline = f.next().split()
tmp = map(float, sline) 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.eigs[ik, ib, :] = tmp[1:self.ispin+1]
self.ferw[ik, ib, :] = tmp[self.ispin+1:] self.ferw[ik, ib, :] = tmp[self.ispin+1:]