-
Notifications
You must be signed in to change notification settings - Fork 136
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
add spin for abacus/stru #751
Changes from 3 commits
cf29c0e
46592e9
222148f
d0cc5f9
35e0d83
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -155,3 +155,19 @@ def test_md(self): | |
np.testing.assert_almost_equal( | ||
data["mag_forces"], sys2.data["mag_forces"], decimal=8 | ||
) | ||
|
||
def test_read_stru_spin(self): | ||
mysys = dpdata.System("abacus.spin/STRU.spin", fmt="abacus/stru") | ||
self.assertTrue("spins" in mysys.data) | ||
Comment on lines
+160
to
+161
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Path should be relative to test directory The test file exists at
🔗 Analysis chainVerify test file existence and handling. Let's verify the test file setup and error handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Verify test file existence and contents
if [ -f "abacus.spin/STRU.spin" ]; then
echo "Test file exists"
head -n 10 "abacus.spin/STRU.spin"
else
echo "Warning: Test file not found"
fi
# Check for similar test files in the repository
fd -e spin "STRU"
Length of output: 176 Script: #!/bin/bash
# Check the test file content in the correct test directory
cat tests/abacus.spin/STRU.spin
# Check if the test is using relative path correctly
rg -A 5 "abacus.spin/STRU.spin" tests/test_abacus_spin.py
# Check if there are other similar test file usages
rg "STRU.spin" tests/
Length of output: 1084 |
||
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review data handling flow in
from_system
The current implementation has potential issues:
get_frame
is called to get data for magnetic registrationget_frame_from_stru
is called to return the actual frameConsider refactoring to:
📝 Committable suggestion