diff --git a/dpdata/abacus/scf.py b/dpdata/abacus/scf.py index c144a4dbd..e623f0222 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,15 @@ 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 +779,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" diff --git a/tests/test_abacus_stru_dump.py b/tests/test_abacus_stru_dump.py index 8891dee3f..ee0a3082e 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(