From 4905fbe78c9270bdfd31bd11d9b5974b375a2234 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 25 Feb 2025 10:24:20 +0800 Subject: [PATCH 1/6] [pre-commit.ci] pre-commit autoupdate (#798) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.9.6 → v0.9.7](https://github.com/astral-sh/ruff-pre-commit/compare/v0.9.6...v0.9.7) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 98dbd363..bffe4e2f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -21,7 +21,7 @@ repos: # Python - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: v0.9.6 + rev: v0.9.7 hooks: - id: ruff args: ["--fix"] From 94d318bbc2cb542a4265a789f4ac98ac898e0009 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 5 Mar 2025 09:16:10 +0800 Subject: [PATCH 2/6] [pre-commit.ci] pre-commit autoupdate (#799) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.9.7 → v0.9.9](https://github.com/astral-sh/ruff-pre-commit/compare/v0.9.7...v0.9.9) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bffe4e2f..4d2553a5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -21,7 +21,7 @@ repos: # Python - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: v0.9.7 + rev: v0.9.9 hooks: - id: ruff args: ["--fix"] From e91d8e6bb2984c0620e0d18d87087e6bbb74d8b2 Mon Sep 17 00:00:00 2001 From: Peng Xingliang <91927439+pxlxingliang@users.noreply.github.com> Date: Fri, 7 Mar 2025 08:52:44 +0800 Subject: [PATCH 3/6] abacus/stru: return spins only when atomic magnetic moment is specified (#800) The old version will induce a bug that dpdata will always store the spin information, and when dpdata save it to lammps format, the spin information will also be written, which is invalid for a non-spin lammps job. Now, the spin information is saved to dpdata only when the magnetic moment of one atom is specified, which is necessary for a spin job. ## Summary by CodeRabbit - **New Features** - Spin data is now processed to include only explicitly defined moments, ensuring accurate output. - **Documentation** - User-facing documentation has been updated to clarify when spin information appears. - **Tests** - Test entries for atomic positions have been streamlined by removing redundant markers. --------- Co-authored-by: root Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- dpdata/abacus/stru.py | 18 +++++++++++++++--- tests/abacus.scf/stru_test | 10 +++++----- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/dpdata/abacus/stru.py b/dpdata/abacus/stru.py index 131aba79..cda25d00 100644 --- a/dpdata/abacus/stru.py +++ b/dpdata/abacus/stru.py @@ -362,6 +362,7 @@ def parse_pos(coords_lines, atom_names, celldm, cell): ntype = len(atom_names) line_idx = 1 # starting line of first element + define_atom_mag = False for it in range(ntype): atom_name = coords_lines[line_idx].split()[0] if atom_name != atom_names[it]: @@ -390,6 +391,9 @@ def parse_pos(coords_lines, atom_names, celldm, cell): mag = [0, 0, atom_type_mag] mags.append(mag) + if imagmom is not None: + define_atom_mag = True + line_idx += 1 coords = np.array(coords) # need transformation!!! @@ -409,7 +413,11 @@ def parse_pos(coords_lines, atom_names, celldm, cell): if all([i is None for i in lambda_]): lambda_ = [] - mags = np.array(mags) + # here return the magnetic moment only when the atom magnetic moment is specified. + if not define_atom_mag: + mags = [] + else: + mags = np.array(mags) return atom_numbs, coords, move, mags, velocity, sc, lambda_ @@ -438,10 +446,13 @@ def get_frame_from_stru(stru): "cells": list of cell vectors, "coords": list of atomic coordinates, - "spins": list of magnetic moments, + "spins": list of magnetic moments, # return only when set "mag xxx" for each atom in STRU file "moves": list of move flags, } For some keys, if the information is not provided in the STRU file, then it will not be included in the dictionary. + "spins" is designed for delta spin calculation, and when dpdata.System is write to lmp format, the spin will be written as magmom. + But we should note that this file format is valid only for a spin lammps job, not for a normal job. + If you want to use dpgen to run the non-spin job, then you should not define "mag x x x" in the STRU file. """ if not os.path.isfile(stru): raise FileNotFoundError(f"ABACUS STRU file {stru} not found!!!") @@ -472,8 +483,9 @@ def get_frame_from_stru(stru): "pp_files": pp_files, "cells": np.array([cell]), "coords": np.array([coords]), - "spins": np.array([mags]), } + if len(mags) > 0: + data["spins"] = np.array([mags]) if len(orb_files) > 0: data["orb_files"] = orb_files if len(dpks_descriptor) > 0: diff --git a/tests/abacus.scf/stru_test b/tests/abacus.scf/stru_test index c3a1917d..e4036409 100644 --- a/tests/abacus.scf/stru_test +++ b/tests/abacus.scf/stru_test @@ -22,11 +22,11 @@ Cartesian # Cartesian(Unit is LATTICE_CONSTANT) C 0.0 1 -5.192682633809 4.557725978258 4.436846615358 1 1 1 mag 0.000000000000 0.000000000000 0.000000000000 +5.192682633809 4.557725978258 4.436846615358 1 1 1 H 0.0 4 -5.416431453540 4.011298860305 3.511161492417 0 0 0 mag 0.000000000000 0.000000000000 0.000000000000 -4.131588222365 4.706745191323 4.431136645083 1 0 1 mag 0.000000000000 0.000000000000 0.000000000000 -5.630930319126 5.521640894956 4.450356541303 1 0 1 mag 0.000000000000 0.000000000000 0.000000000000 -5.499851012568 4.003388899277 5.342621842622 0 1 1 mag 0.000000000000 0.000000000000 0.000000000000 +5.416431453540 4.011298860305 3.511161492417 0 0 0 +4.131588222365 4.706745191323 4.431136645083 1 0 1 +5.630930319126 5.521640894956 4.450356541303 1 0 1 +5.499851012568 4.003388899277 5.342621842622 0 1 1 From 0679ee29f26c0f72c188d5d56a897b6c6949b872 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 11 Mar 2025 08:19:45 +0800 Subject: [PATCH 4/6] [pre-commit.ci] pre-commit autoupdate (#802) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.9.9 → v0.9.10](https://github.com/astral-sh/ruff-pre-commit/compare/v0.9.9...v0.9.10) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4d2553a5..b4759716 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -21,7 +21,7 @@ repos: # Python - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: v0.9.9 + rev: v0.9.10 hooks: - id: ruff args: ["--fix"] From b735969e09828f29bf4122589a917daa6c35612a Mon Sep 17 00:00:00 2001 From: ".Del" <10773382+zrzrv5@users.noreply.github.com> Date: Thu, 13 Mar 2025 02:49:35 -0500 Subject: [PATCH 5/6] update coords after shift_orig_zero (#803) Hi, I think this part of the code was attempting to modify local variables (`ii`) rather than the actual array elements in `self.data["coords"]`. Before: ``` @post_funcs.register("shift_orig_zero") def _shift_orig_zero(self): for ff in self.data["coords"]: for ii in ff: ii = ii - self.data["orig"] ... ``` After: ``` ... self.data["coords"] = self.data["coords"] - self.data["orig"] ``` ## Summary by CodeRabbit - **Refactor** - Enhanced the efficiency of coordinate adjustments for improved performance on larger datasets. Signed-off-by: .Del <10773382+zrzrv5@users.noreply.github.com> --- dpdata/system.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/dpdata/system.py b/dpdata/system.py index cfc0f184..d7cf2657 100644 --- a/dpdata/system.py +++ b/dpdata/system.py @@ -710,9 +710,7 @@ def affine_map(self, trans, f_idx: int | numbers.Integral = 0): @post_funcs.register("shift_orig_zero") def _shift_orig_zero(self): - for ff in self.data["coords"]: - for ii in ff: - ii = ii - self.data["orig"] + self.data["coords"] = self.data["coords"] - self.data["orig"] self.data["orig"] = self.data["orig"] - self.data["orig"] assert (np.zeros([3]) == self.data["orig"]).all() From a96b30553cf891897d96df276ee182a8402e000d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 18 Mar 2025 11:18:37 +0800 Subject: [PATCH 6/6] [pre-commit.ci] pre-commit autoupdate (#804) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.9.10 → v0.11.0](https://github.com/astral-sh/ruff-pre-commit/compare/v0.9.10...v0.11.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b4759716..5ed33166 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -21,7 +21,7 @@ repos: # Python - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: v0.9.10 + rev: v0.11.0 hooks: - id: ruff args: ["--fix"]