From e623b91aebb4e8422fe6243391b631016ed96bfe Mon Sep 17 00:00:00 2001 From: root Date: Fri, 8 Nov 2024 10:26:09 +0800 Subject: [PATCH 1/4] Adjust pp_file as an unnessary parameter in save to abacus/stru --- dpdata/abacus/scf.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/dpdata/abacus/scf.py b/dpdata/abacus/scf.py index c144a4db..f3daa030 100644 --- a/dpdata/abacus/scf.py +++ b/dpdata/abacus/scf.py @@ -635,7 +635,7 @@ def get_frame_from_stru(fname): def make_unlabeled_stru( data, frame_idx, - pp_file, + pp_file=None, numerical_orbital=None, numerical_descriptor=None, mass=None, @@ -759,7 +759,11 @@ def process_file_input(file_input, atom_names, input_name): # ATOMIC_SPECIES block out = "ATOMIC_SPECIES\n" - ppfiles = process_file_input(ndarray2list(pp_file), data["atom_names"], "pp_file") + if pp_file is not None: + ppfiles = process_file_input(ndarray2list(pp_file), data["atom_names"], "pp_file") + else: + warnings.warn("pp_file is not provided, will use empty string for pseudo potential file.") + ppfiles = [""] * len(data["atom_names"]) for iele in range(len(data["atom_names"])): if data["atom_numbs"][iele] == 0: @@ -771,12 +775,13 @@ def process_file_input(file_input, atom_names, input_name): out += "1 " ipp_file = ppfiles[iele] - if not link_file: - out += ipp_file - else: - out += os.path.basename(ipp_file.rstrip("/")) - if dest_dir is not None: - _link_file(dest_dir, ipp_file) + if ipp_file != "": + if not link_file: + out += ipp_file + else: + out += os.path.basename(ipp_file.rstrip("/")) + if dest_dir is not None: + _link_file(dest_dir, ipp_file) out += "\n" out += "\n" From 50c138e078967facedd233565d78ef4a6680cfec Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 8 Nov 2024 02:28:42 +0000 Subject: [PATCH 2/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- dpdata/abacus/scf.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/dpdata/abacus/scf.py b/dpdata/abacus/scf.py index f3daa030..e623f022 100644 --- a/dpdata/abacus/scf.py +++ b/dpdata/abacus/scf.py @@ -760,9 +760,13 @@ def process_file_input(file_input, atom_names, input_name): # ATOMIC_SPECIES block out = "ATOMIC_SPECIES\n" if pp_file is not None: - ppfiles = process_file_input(ndarray2list(pp_file), data["atom_names"], "pp_file") + ppfiles = process_file_input( + ndarray2list(pp_file), data["atom_names"], "pp_file" + ) else: - warnings.warn("pp_file is not provided, will use empty string for pseudo potential file.") + warnings.warn( + "pp_file is not provided, will use empty string for pseudo potential file." + ) ppfiles = [""] * len(data["atom_names"]) for iele in range(len(data["atom_names"])): From d5f23ce3f21b9bbf63cce959eaf54438b11af513 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 8 Nov 2024 12:59:21 +0800 Subject: [PATCH 3/4] add test --- tests/test_abacus_stru_dump.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/test_abacus_stru_dump.py b/tests/test_abacus_stru_dump.py index 8891dee3..1de852c5 100644 --- a/tests/test_abacus_stru_dump.py +++ b/tests/test_abacus_stru_dump.py @@ -29,6 +29,10 @@ def test_dump_stru(self): ) myfilecmp(self, "abacus.scf/stru_test", "STRU_tmp") + def test_dump_stru_without_pporb(self): + self.system_ch4.to("stru", "STRU_tmp", mass=[12, 1]) + self.assertTrue(os.path.isfile("STRU_tmp")) + def test_dumpStruLinkFile(self): os.makedirs("abacus.scf/tmp", exist_ok=True) self.system_ch4.to( From aaa12e69272baaa9704b95fda28617c1646ccd22 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 8 Nov 2024 04:59:54 +0000 Subject: [PATCH 4/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_abacus_stru_dump.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_abacus_stru_dump.py b/tests/test_abacus_stru_dump.py index 1de852c5..ee0a3082 100644 --- a/tests/test_abacus_stru_dump.py +++ b/tests/test_abacus_stru_dump.py @@ -32,7 +32,7 @@ def test_dump_stru(self): def test_dump_stru_without_pporb(self): self.system_ch4.to("stru", "STRU_tmp", mass=[12, 1]) self.assertTrue(os.path.isfile("STRU_tmp")) - + def test_dumpStruLinkFile(self): os.makedirs("abacus.scf/tmp", exist_ok=True) self.system_ch4.to(