Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed Nov 5, 2024
1 parent cf29c0e commit 46592e9
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
24 changes: 24 additions & 0 deletions tests/abacus.spin/STRU.spin
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
ATOMIC_SPECIES
Fe 55.845 Fe.upf

NUMERICAL_ORBITAL
Fe_gga_10au_200.0Ry_4s2p2d1f.orb

LATTICE_CONSTANT
1.880277359
LATTICE_VECTORS
2.8274254848 0.0000000000 0.0000000000 #latvec1
0.0000000000 2.8274254848 0.0000000000 #latvec2
0.0000000000 0.0000000000 2.8274254848 #latvec3

ATOMIC_POSITIONS
Direct

Fe #label
1 #magnetism
4 #number of atoms
0.0000000000 0.000000000 0.000000000 mag 0 0 2
0.1000000000 0.1000000000 0.1000000000 mag 3
0.2000000000 0.2000000000 0.2000000000 mag 3 angle1 90
0.3000000000 0.3000000000 0.3000000000 mag 3 4 0 angle1 90 angle2 90

17 changes: 15 additions & 2 deletions tests/test_abacus_spin.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,21 @@ def test_md(self):
)

def test_read_stru_spin(self):
mysys = dpdata.System("abacus.spin/STRU", fmt="abacus/stru")
mysys = dpdata.System("abacus.spin/STRU.spin", fmt="abacus/stru")
self.assertTrue("spins" in mysys.data)
np.testing.assert_almost_equal(mysys.data["spins"],[[[0,0,2.4],[0,0,2.4]]],decimal=8)
print(mysys.data["spins"])

"""
0.0000000000 0.000000000 0.000000000 mag 0 0 2
0.1000000000 0.1000000000 0.1000000000 mag 3
0.2000000000 0.2000000000 0.2000000000 mag 3 angle1 90
0.3000000000 0.3000000000 0.3000000000 mag 3 4 0 angle1 90 angle2 90
"""
np.testing.assert_almost_equal(mysys.data["spins"][0][0],[0,0,2],decimal=8)
np.testing.assert_almost_equal(mysys.data["spins"][0][1],[0,0,3],decimal=8)
np.testing.assert_almost_equal(mysys.data["spins"][0][2],[3,0,0],decimal=8)
np.testing.assert_almost_equal(mysys.data["spins"][0][3],[0,5,0],decimal=8)




0 comments on commit 46592e9

Please sign in to comment.