Skip to content

Commit

Permalink
feat: support spin for ABACUS (#718)
Browse files Browse the repository at this point in the history
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Enhanced data retrieval capabilities with the inclusion of magnetic
moment and force data in the output.
- Streamlined method for handling parameters in the ABACUS plugin,
improving usability.
- New function added for registering magnetic data types, enhancing
functionality.
- Comprehensive test suite introduced for validating ABACUS spin
simulation functionalities.

- **Bug Fixes**
- Improved control flow to ensure accurate integration of new magnetic
data.

- **Tests**
- Introduced new test cases to validate the accuracy of ABACUS spin
simulation outputs, enhancing overall test coverage.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: root <pxlxingliang>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Han Wang <[email protected]>
  • Loading branch information
3 people authored Sep 20, 2024
1 parent 482775f commit c1d6c73
Show file tree
Hide file tree
Showing 23 changed files with 3,647 additions and 46 deletions.
8 changes: 8 additions & 0 deletions dpdata/abacus/md.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
get_cell,
get_coords,
get_geometry_in,
get_mag_force,
kbar2evperang3,
)

Expand Down Expand Up @@ -199,6 +200,9 @@ def get_frame(fname):
stress[iframe] *= np.linalg.det(cells[iframe, :, :].reshape([3, 3]))
if np.sum(np.abs(stress[0])) < 1e-10:
stress = None

magmom, magforce = get_mag_force(outlines)

data = {}
data["atom_names"] = atom_names
data["atom_numbs"] = natoms
Expand All @@ -213,5 +217,9 @@ def get_frame(fname):
if not isinstance(data["virials"], np.ndarray):
del data["virials"]
data["orig"] = np.zeros(3)
if len(magmom) > 0:
data["spins"] = magmom
if len(magforce) > 0:
data["mag_forces"] = magforce

return data
8 changes: 8 additions & 0 deletions dpdata/abacus/relax.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
get_cell,
get_coords,
get_geometry_in,
get_mag_force,
kbar2evperang3,
)

Expand Down Expand Up @@ -198,6 +199,8 @@ def get_frame(fname):
lines, atomnumber
)

magmom, magforce = get_mag_force(lines)

data = {}
data["atom_names"] = atom_names
data["atom_numbs"] = natoms
Expand All @@ -211,4 +214,9 @@ def get_frame(fname):
data["stress"] = stress
data["orig"] = np.zeros(3)

if len(magmom) > 0:
data["spins"] = magmom
if len(magforce) > 0:
data["mag_forces"] = magforce

return data
Loading

0 comments on commit c1d6c73

Please sign in to comment.