Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UT: add UT for create_disturb_abacus_dev #852

Merged
merged 1 commit into from
Aug 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dpgen/data/tools/create_random_disturb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
23 changes: 23 additions & 0 deletions tests/data/STRU.hcp
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions tests/data/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)))
29 changes: 29 additions & 0 deletions tests/data/test_disturb_abacus.py
Original file line number Diff line number Diff line change
@@ -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()