Skip to content

Commit b9d1221

Browse files
author
root
committed
add test for chaotic atomic species
1 parent 1040555 commit b9d1221

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

tests/test_abacus_stru_dump.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,45 @@ def test_dump_move_from_vasp(self):
206206
"""
207207
self.assertTrue(stru_ref in c)
208208

209+
210+
def test_dump_chaotic_atomic_species(self):
211+
import copy
212+
import numpy as np
213+
from dpdata.abacus.stru import split_stru_block
214+
temp_system = copy.deepcopy(self.system_ch4)
215+
temp_system.data["atom_types"] = np.array([1,0,1,1,1])
216+
temp_system.data["coords"] = np.array([[[1,1,1],[0,0,0],[2,2,2],[3,3,3],[4,4,4]]])
217+
temp_system.data["move"] = np.array([[[1,0,0],[0,1,1],[1,1,1],[1,1,1],[1,1,1]]])
218+
velocity = np.array([[1,1,1],[2,2,2],[3,3,3],[4,4,4],[5,5,5]])
219+
mag = np.array([[11,11,11],[22,22,22],[33,33,33],[44,44,44],[55,55,55]])
220+
constrain = np.array([1, 0, 1, 0, 1])
221+
sc = np.array([[0,1,1],[0,0,1],[1,1,1],[1,1,1],[1,1,1]])
222+
lambda_ = np.array([[0.1, 0.2, 0.3], [0.4, 0.5, 0.6], [0.7, 0.8, 0.9], [1.0, 1.1, 1.2], [1.3, 1.4, 1.5]])
223+
temp_system.to(
224+
"stru",
225+
"STRU_tmp",
226+
velocity=velocity,
227+
mag=mag,
228+
constrain=constrain,
229+
sc=sc,
230+
lambda_=lambda_,
231+
)
232+
233+
assert os.path.isfile("STRU_tmp")
234+
with open("STRU_tmp") as f: lines = f.read()
235+
ref_c = """C
236+
0.0
237+
1
238+
0.000000000000 0.000000000000 0.000000000000 0 1 1 v 2.000000000000 2.000000000000 2.000000000000 mag 22.000000000000 22.000000000000 22.000000000000 sc 0 0 1 lambda 0.400000000000 0.500000000000 0.600000000000
239+
H
240+
0.0
241+
4
242+
1.000000000000 1.000000000000 1.000000000000 1 0 0 v 1.000000000000 1.000000000000 1.000000000000 mag 11.000000000000 11.000000000000 11.000000000000 sc 0 1 1 lambda 0.100000000000 0.200000000000 0.300000000000
243+
2.000000000000 2.000000000000 2.000000000000 1 1 1 v 3.000000000000 3.000000000000 3.000000000000 mag 33.000000000000 33.000000000000 33.000000000000 sc 1 1 1 lambda 0.700000000000 0.800000000000 0.900000000000
244+
3.000000000000 3.000000000000 3.000000000000 1 1 1 v 4.000000000000 4.000000000000 4.000000000000 mag 44.000000000000 44.000000000000 44.000000000000 sc 1 1 1 lambda 1.000000000000 1.100000000000 1.200000000000
245+
4.000000000000 4.000000000000 4.000000000000 1 1 1 v 5.000000000000 5.000000000000 5.000000000000 mag 55.000000000000 55.000000000000 55.000000000000 sc 1 1 1 lambda 1.300000000000 1.400000000000 1.500000000000"""
246+
247+
self.assertTrue(ref_c in lines)
209248

210249
class TestABACUSParseStru(unittest.TestCase):
211250
def test_parse_pos_oneline(self):

0 commit comments

Comments
 (0)