Skip to content

[Code scan] Complete CALYPSO safe-distance handling for common elements #353

Description

@njzjz

Found by Codex global repository scan of deepmodeling/dpgen2 at commit 2679611a3704f5c2646c8cb353e34177518db758.

parse_traj filters selected CALYPSO frames with a hard-coded safe-distance table:

safe_dist_dict = {
"He": 0.0,
"Li": 1.5,
"Na": 1.45,
"K": 2.3,
"Rb": 2.5,
"Mg": 1.7,
"Ca": 2.3,
"Sr": 2.5,
"Al": 1.7,
"Sc": 2.0,
"Y": 2.1,
"La": 2.5,
"Ti": 2.0,
"Zr": 2.1,
"Hf": 2.4,
"Mo": 2.1,
"W": 2.3,
"B": 1.1,
"C": 1.1,
"Si": 1.6,
"P": 1.5,
"As": 2.0,
"S": 1.5,
"Se": 2.1,
"Te": 2.0,
"Br": 2.3,
"H": 0.813,
}

The table is indexed directly for every atom pair:

# 2nd filter for selected traj. It filters out all FRAMES that are to close.
i_keep = []
for t in selected_traj:
t2 = make_supercell(t, [[2, 0, 0], [0, 2, 0], [0, 0, 2]])
frame_is_reasonable = True
dist_dict = t2.get_all_distances(mic=True)
atype = t2.get_chemical_symbols()
for a in range(len(atype)):
for b in range(a + 1, len(atype)):
dd = dist_dict[a][b]
dr = (
(safe_dist_dict[atype[a]] + safe_dist_dict[atype[b]])
* 0.529
/ 1.2
)

Many common elements are missing, including O, N, F, Cl, Fe, Ni, and Cu. A trajectory containing any omitted element raises KeyError before model-deviation output is written.

Suggested fix: use a complete element table from a maintained source, fall back with a clear validation error, or reuse the covalent-radius data already present elsewhere in the package. Add a regression test with an element currently missing from the dictionary.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status
    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions