Skip to content
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

feat: support spin for ABACUS #718

Merged
merged 13 commits into from
Sep 20, 2024
Merged
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