diff --git a/python/converters/vasp/python/plotools.py b/python/converters/vasp/python/plotools.py index 44fa053f..0bd14a16 100644 --- a/python/converters/vasp/python/plotools.py +++ b/python/converters/vasp/python/plotools.py @@ -76,7 +76,10 @@ def check_data_consistency(pars, el_struct): """ Check the consistency of the VASP data. """ - pass +# Check that ions inside each shell are of the same sort + for sh in pars.shells: + sorts = set(el_struct.poscar.type_of_ion[sh['ion_list']]) + assert len(sorts) == 1, "Each projected shell must contain only ions of the same sort" ################################################################################ # select_bands() diff --git a/python/converters/vasp/test/_plotools/POSCAR.complex b/python/converters/vasp/test/_plotools/POSCAR.complex new file mode 100644 index 00000000..c7693ced --- /dev/null +++ b/python/converters/vasp/test/_plotools/POSCAR.complex @@ -0,0 +1,28 @@ +NdNiO3 +1.0 + 5.3871197701 0.0000000000 0.0000000000 + 0.0000000000 5.3826699257 0.0000000000 + 0.0000000000 0.0000000000 7.6093997955 + Nd Ni O + 4 4 12 +Direct + 0.995800018 0.035000000 0.250000000 + 0.004199982 0.964999974 0.750000000 + 0.495800018 0.465000004 0.750000000 + 0.504199982 0.535000026 0.250000000 + 0.500000000 0.000000000 0.000000000 + 0.000000000 0.500000000 0.000000000 + 0.500000000 0.000000000 0.500000000 + 0.000000000 0.500000000 0.500000000 + 0.069300003 0.489699990 0.250000000 + 0.930700004 0.510300040 0.750000000 + 0.569299996 0.010300010 0.750000000 + 0.430700004 0.989699960 0.250000000 + 0.716600001 0.287099987 0.039500002 + 0.283399999 0.712900043 0.960500002 + 0.216600001 0.212900013 0.960500002 + 0.783399999 0.787099957 0.039500002 + 0.283399999 0.712900043 0.539499998 + 0.716600001 0.287099987 0.460500002 + 0.783399999 0.787099957 0.460500002 + 0.216600001 0.212900013 0.539499998 diff --git a/python/converters/vasp/test/_plotools/test_consistency.py b/python/converters/vasp/test/_plotools/test_consistency.py index eeac9961..bf0a7c0a 100644 --- a/python/converters/vasp/test/_plotools/test_consistency.py +++ b/python/converters/vasp/test/_plotools/test_consistency.py @@ -1,6 +1,8 @@ import vaspio from inpconf import ConfigParameters +from plotools import check_data_consistency +from elstruct import ElectronicStructure import mytest ################################################################################ @@ -12,23 +14,26 @@ class TestDataConsistency(mytest.MyTestCase): """ Function: - def read_plocar(filename) + def check_data_consistency(pars, el_struct) Scenarios: - - **if** file PLOCAR does not exist **raise** IOError - - **if** PLOCAR is truncated **raise** IOError - - **if** the precision flag is not 4 or 8 **raise** ValueError - - **if** PLOCAR with prec=8 is read **compare** the output - - **if** PLOCAR with prec=4 is read **compare** the output + - **if** a shell contains ions of different types **raise** AssertionError """ # Scenario 1 - def test_example(self): - conf_file = 'example.cfg' - pars = ConfigParameters(conf_file) - pars.parse_input() - vasp_data = vaspio.VaspData('./') - - print pars.shells - print pars.groups + def test_shell_ion_types(self): + pass +# conf_file = 'wrong_shell.cfg' +# pars = ConfigParameters(conf_file) +# pars.parse_input() +# vasp_data = vaspio.VaspData('./', read_all=False) +# vasp_data.poscar.from_file('./', poscar_filename='POSCAR.complex') +# el_strct = ElectronicStructure(vasp_data) +# +# print pars.shells +# print vasp_data.poscar.type_of_ion +# +# err_mess = "Each projected shell must" +# with self.assertRaisesRegexp(Exception, err_mess): +# check_data_consistency(pars, el_struct) diff --git a/python/converters/vasp/test/_plotools/wrong_shell.cfg b/python/converters/vasp/test/_plotools/wrong_shell.cfg new file mode 100644 index 00000000..13435387 --- /dev/null +++ b/python/converters/vasp/test/_plotools/wrong_shell.cfg @@ -0,0 +1,8 @@ + +[Shell 1] +LSHELL = 2 +IONS = 4 5 6 7 +EMIN = -15.0 +EMAX = 5.0 + +