diff --git a/dpgen/data/tools/create_random_disturb.py b/dpgen/data/tools/create_random_disturb.py index 12a9b963f..4c2aa1064 100755 --- a/dpgen/data/tools/create_random_disturb.py +++ b/dpgen/data/tools/create_random_disturb.py @@ -8,7 +8,7 @@ import numpy as np import ase.io -import io_lammps +import dpgen.data.tools.io_lammps as io_lammps from dpgen.generator.lib.abacus_scf import get_abacus_STRU, make_abacus_scf_stru diff --git a/tests/data/STRU.hcp b/tests/data/STRU.hcp new file mode 100644 index 000000000..d55f24cb6 --- /dev/null +++ b/tests/data/STRU.hcp @@ -0,0 +1,23 @@ +ATOMIC_SPECIES +Al 26.982 Al.PD04.PBE.UPF + +NUMERICAL_ORBITAL +./Al_gga_10au_100Ry_3s3p3d.orb + +LATTICE_CONSTANT +1.889716 + +LATTICE_VECTORS + 1.42857 -2.47436 0.00000 + 1.42857 2.47436 0.00000 + 0.00000 0.00000 9.29698 + +ATOMIC_POSITIONS +Direct +Al +0.0 +4 + 0.0000000 0.0000000 0.5000000 1 1 1 + 0.6666670 0.3333330 0.7500000 1 1 1 + 0.0000000 0.0000000 0.0000000 1 1 1 + 0.3333330 0.6666670 0.2500000 1 1 1 diff --git a/tests/data/context.py b/tests/data/context.py index b1d625352..d99d19c1f 100644 --- a/tests/data/context.py +++ b/tests/data/context.py @@ -4,5 +4,6 @@ param_file = 'al.json' abacus_param_file = 'ch4.json' +abacus_stru_file = 'STRU.hcp' def setUpModule(): os.chdir(os.path.abspath(os.path.dirname(__file__))) diff --git a/tests/data/test_disturb_abacus.py b/tests/data/test_disturb_abacus.py new file mode 100644 index 000000000..1b27d3090 --- /dev/null +++ b/tests/data/test_disturb_abacus.py @@ -0,0 +1,29 @@ +import sys, os +import unittest +from dpgen.data.tools.create_random_disturb import create_disturbs_abacus_dev +sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) +__package__ = 'data' +from .context import * + +class TestPertAbacus(unittest.TestCase): + def setUp(self): + create_disturbs_abacus_dev(abacus_stru_file,1) + def tearDown(self): + if os.path.isfile('STRU.hcp1.abacus'): + os.remove('STRU.hcp1.abacus') + def test_stru(self): + if os.path.isfile('STRU.hcp1.abacus'): + stru1 = get_abacus_STRU('STRU.hcp1.abacus') + stru0 = get_abacus_STRU(abacus_stru_file) + self.assertEqual(stru0['atom_names'],stru1['atom_names']) + self.assertEqual(stru0['atom_numbs'],stru1['atom_numbs']) + self.assertEqual(stru0['atom_masses'],stru1['atom_masses']) + #print(stru0['atom_numbs'],stru1['atom_numbs']) + #print(stru0['coords'],stru1['coords']) + #print(stru0['cells'],stru1['cells']) + #print(stru0['atom_types'],stru1['atom_types']) + def test_FileExist(self): + self.assertTrue(os.path.isfile('STRU.hcp1.abacus')) + +if __name__ == '__main__': + unittest.main()