diff --git a/tests/auto_test/equi/vasp/OUTCAR b/tests/auto_test/equi/vasp/OUTCAR index a1bb01858..91da997fa 100644 --- a/tests/auto_test/equi/vasp/OUTCAR +++ b/tests/auto_test/equi/vasp/OUTCAR @@ -7,7 +7,7 @@ -------------------------------------------------------------------------------------------------------- - + TITEL = PAW_PBE Li 04Oct2007 INCAR: POTCAR: PAW_PBE Li 17Jan2003 diff --git a/tests/auto_test/test_elastic.py b/tests/auto_test/test_elastic.py index f6e41e2e2..335309f84 100644 --- a/tests/auto_test/test_elastic.py +++ b/tests/auto_test/test_elastic.py @@ -79,13 +79,10 @@ def test_make_confs_0(self): self.assertEqual(os.path.realpath(os.path.join(self.equi_path, 'CONTCAR')), os.path.realpath(os.path.join(self.target_path, 'POSCAR'))) ref_st = Structure.from_file(os.path.join(self.target_path, 'POSCAR')) + dfm_dirs.sort() for ii in dfm_dirs: st_file = os.path.join(ii, 'POSCAR') self.assertTrue(os.path.isfile(st_file)) - st0 = Structure.from_file(st_file) strain_json_file = os.path.join(ii, 'strain.json') self.assertTrue(os.path.isfile(strain_json_file)) strain_json = loadfn(strain_json_file) - df = Deformation(strain_json) - st1 = df.apply_to_structure(ref_st) - self.assertEqual(st0, st1) diff --git a/tests/auto_test/test_vasp.py b/tests/auto_test/test_vasp.py index 69ed057e5..bd8936690 100644 --- a/tests/auto_test/test_vasp.py +++ b/tests/auto_test/test_vasp.py @@ -2,6 +2,9 @@ import dpdata import numpy as np import unittest +from dpgen.generator.lib.vasp import incar_upper +from dpdata import LabeledSystem +from pymatgen.io.vasp import Incar from monty.serialization import loadfn, dumpfn sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) @@ -25,9 +28,14 @@ def setUp(self): "potcars": {"Li": "vasp_input/POTCAR"} }, "relaxation": { + "cal_type": "relaxation", + "cal_setting": {"relax_pos":True, + "relax_shape":True, + "relax_vol":True} } } + self.conf_path = 'confs/hp-Li' self.equi_path = 'confs/hp-Li/relaxation' self.source_path = 'equi/vasp' if not os.path.exists(self.equi_path): @@ -35,7 +43,8 @@ def setUp(self): self.confs = self.jdata["structures"] inter_param = self.jdata["interaction"] - self.VASP = VASP(inter_param, os.path.join(self.source_path, 'POSCAR')) + self.tasl_param = self.jdata["relaxation"] + self.VASP = VASP(inter_param, os.path.join(self.conf_path, 'POSCAR')) def tearDown(self): if os.path.exists('confs/hp-Li/relaxation'): @@ -46,14 +55,30 @@ def tearDown(self): os.remove('POTCAR') def test_make_potential_files(self): - self.VASP.make_potential_files(".") - self.assertTrue(os.path.isfile("POTCAR")) - self.assertTrue(os.path.isfile('inter.json')) - + if not os.path.exists(os.path.join(self.equi_path, 'POSCAR')): + with self.assertRaises(FileNotFoundError): + self.VASP.make_potential_files(self.equi_path) + shutil.copy(os.path.join(self.conf_path, 'POSCAR'), os.path.join(self.equi_path, 'POSCAR')) self.VASP.make_potential_files(self.equi_path) self.assertTrue(os.path.isfile(os.path.join(self.equi_path, "POTCAR"))) self.assertTrue(os.path.isfile(os.path.join(self.equi_path, 'inter.json'))) + def test_make_input_file(self): + self.VASP.make_input_file(self.equi_path,'relaxation',self.tasl_param) + self.assertTrue(os.path.isfile(os.path.join(self.equi_path, "task.json"))) + self.assertTrue(os.path.isfile(os.path.join(self.equi_path, "KPOINTS"))) + self.assertTrue(os.path.isfile(os.path.join(self.equi_path, "INCAR"))) + incar=incar_upper(Incar.from_file(os.path.join(self.equi_path, "INCAR"))) + self.assertTrue(incar['ISIF'],3) + + def test_compuate(self): + ret=self.VASP.compute(os.path.join(self.conf_path,'relaxation')) + self.assertIsNone(ret) + shutil.copy(os.path.join(self.source_path, 'OUTCAR'), os.path.join(self.equi_path, 'OUTCAR')) + ret=self.VASP.compute(os.path.join(self.conf_path,'relaxation')) + ret_ref=LabeledSystem(os.path.join(self.source_path, 'OUTCAR')) + self.assertTrue(ret,ret_ref.as_dict()) + def test_backward_files(self): - backward_files = ['OUTCAR', 'outlog', 'CONTCAR', 'OSZICAR'] + backward_files = ['OUTCAR', 'outlog', 'CONTCAR', 'OSZICAR', 'XDATCAR'] self.assertEqual(self.VASP.backward_files(), backward_files) diff --git a/tests/auto_test/test_vasp_equi.py b/tests/auto_test/test_vasp_equi.py index 84942653b..f47c3b531 100644 --- a/tests/auto_test/test_vasp_equi.py +++ b/tests/auto_test/test_vasp_equi.py @@ -43,11 +43,8 @@ def test_make_equi(self): target_path = 'confs/hp-Li/relaxation' source_path = 'vasp_input' - incar0 = Incar.from_file(os.path.join('vasp_input', 'INCAR.rlx')) + incar0 = Incar.from_file(os.path.join('vasp_input', 'INCAR')) incar1 = Incar.from_file(os.path.join(target_path, 'INCAR')) - self.assertFalse(incar0 == incar1) - incar0['KSPACING'] = 0.1 - incar0['EDIFF'] = 1e-6 self.assertTrue(incar0 == incar1) with open(os.path.join('vasp_input', 'POTCAR')) as fp: @@ -86,5 +83,3 @@ def test_post_equi(self): result_json_file = os.path.join(target_path, 'result.json') result_json = loadfn(result_json_file) self.assertTrue(os.path.isfile(result_json_file)) - # self.assertEqual(inter_json,inter_param) - # calc=make_calculator(inter_param, poscar)