Skip to content

Commit 4f20fa4

Browse files
author
root
committed
add error handling
1 parent 9d61f6a commit 4f20fa4

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

dpgen/generator/lib/abacus_scf.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,23 @@ def make_abacus_scf_stru(
218218
if type_map is None:
219219
type_map = sys_data_copy["atom_names"]
220220

221+
missing_atoms = set(sys_data_copy["atom_names"]) - set(type_map)
222+
if len(missing_atoms) > 0:
223+
raise ValueError(
224+
f"Some atoms in sys_data are not in type_map: {missing_atoms}. "
225+
"Please provide a valid type_map."
226+
)
227+
228+
if len(fp_pp_files) != len(type_map):
229+
raise ValueError(
230+
"The length of fp_pp_files should be equal to the length of type_map."
231+
)
232+
if fp_orb_files is not None and len(fp_orb_files) != len(type_map):
233+
raise ValueError(
234+
"The length of fp_orb_files should be equal to the length of type_map."
235+
)
236+
237+
221238
fp_pp_files = [
222239
os.path.join(pporb, fp_pp_files[type_map.index(atom_name)])
223240
for atom_name in sys_data_copy["atom_names"]

0 commit comments

Comments
 (0)