Skip to content

Commit c1d6c73

Browse files
pxlxingliangpre-commit-ci[bot]wanghan-iapcm
authored
feat: support spin for ABACUS (#718)
<!-- 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]>
1 parent 482775f commit c1d6c73

23 files changed

+3647
-46
lines changed

dpdata/abacus/md.py

+8
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
get_cell,
1313
get_coords,
1414
get_geometry_in,
15+
get_mag_force,
1516
kbar2evperang3,
1617
)
1718

@@ -199,6 +200,9 @@ def get_frame(fname):
199200
stress[iframe] *= np.linalg.det(cells[iframe, :, :].reshape([3, 3]))
200201
if np.sum(np.abs(stress[0])) < 1e-10:
201202
stress = None
203+
204+
magmom, magforce = get_mag_force(outlines)
205+
202206
data = {}
203207
data["atom_names"] = atom_names
204208
data["atom_numbs"] = natoms
@@ -213,5 +217,9 @@ def get_frame(fname):
213217
if not isinstance(data["virials"], np.ndarray):
214218
del data["virials"]
215219
data["orig"] = np.zeros(3)
220+
if len(magmom) > 0:
221+
data["spins"] = magmom
222+
if len(magforce) > 0:
223+
data["mag_forces"] = magforce
216224

217225
return data

dpdata/abacus/relax.py

+8
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
get_cell,
1414
get_coords,
1515
get_geometry_in,
16+
get_mag_force,
1617
kbar2evperang3,
1718
)
1819

@@ -198,6 +199,8 @@ def get_frame(fname):
198199
lines, atomnumber
199200
)
200201

202+
magmom, magforce = get_mag_force(lines)
203+
201204
data = {}
202205
data["atom_names"] = atom_names
203206
data["atom_numbs"] = natoms
@@ -211,4 +214,9 @@ def get_frame(fname):
211214
data["stress"] = stress
212215
data["orig"] = np.zeros(3)
213216

217+
if len(magmom) > 0:
218+
data["spins"] = magmom
219+
if len(magforce) > 0:
220+
data["mag_forces"] = magforce
221+
214222
return data

0 commit comments

Comments
 (0)