fix: Filter SIESTA pseudopotentials by system atom types#1861
Conversation
Co-authored-by: njzjz <9496702+njzjz@users.noreply.github.com>
Co-authored-by: njzjz <9496702+njzjz@users.noreply.github.com>
There was a problem hiding this comment.
Verdict: Changes requested. Filtering SIESTA pseudopotentials by the system elements is correct in the main make_fp_siesta path, but the relabel initial-data path still has a deterministic UnboundLocalError. The new test does not cover that branch, and pre-commit is failing.
Note: The Codex quota is about to reset, so I am using the remaining tokens to review all open PRs in this repository.
Coding agent: Codex
Codex version: codex-cli 0.144.6
Model: gpt-5.6-sol
Reasoning effort: xhigh
| ) | ||
| elif fp_style == "siesta": | ||
| make_siesta(".", fp_params, fp_pp_files, fp_pp_files) | ||
| make_siesta(".", fp_params, fp_pp_path, fp_pp_files, type_map) |
There was a problem hiding this comment.
[Blocking] When fp_style == "siesta", the preceding mutually exclusive PWSCF branch does not run, so the local variable fp_params is unbound. The SIESTA path in create_init_tasks() therefore deterministically raises UnboundLocalError. Read user_fp_params/fp_params inside the SIESTA branch and add a relabel init-task regression test. For example:
| make_siesta(".", fp_params, fp_pp_path, fp_pp_files, type_map) | |
| elif fp_style == "siesta": | |
| if "user_fp_params" in fp_jdata: | |
| fp_params = fp_jdata["user_fp_params"] | |
| else: | |
| fp_params = fp_jdata["fp_params"] | |
| make_siesta(".", fp_params, fp_pp_path, fp_pp_files, type_map) |
SIESTA input generation failed with
AssertionErrorwhen systems contained a subset of elements fromfp_pp_files(e.g., pure C systems when both C.psf and H.psf were provided).Changes
dpgen/generator/run.py: Filter
fp_pp_filesto match system atom types before passing tomake_siesta_input, following PWSCF pattern:dpgen/tools/relabel.py: Apply same filtering in
make_siestahelper and fix parameter passingtests/generator/test_make_fp.py: Add
TestMakeFPSIESTASubsetElementsto validate subset element handlingThe assertion
assert ntypes == len(pps)in_make_siesta_02_speciesnow receives correctly filtered pseudopotentials matching the system's atom types.Original prompt
This section details on the original issue you should resolve
<issue_title>[BUG] Un-necessary assertion ntypes < len(pps) when making siesta input files</issue_title>
<issue_description>### Bug summary
Hi!
I'm running DPGEN for systems containing element 'C' and 'H' with SIESTA as the DFT engine.
In this task, 'sys_configs' includes pure 'C' systems and systems with both 'C' and 'H'. The 'fp_pp_files = ["C.psf", "H.psf"]'. However, an unexpected error occurs:
The root reason seems to be a unnecessary assert check in dpgen/generator/lib/siesta.py:_make_siesta_02_species. The 'ntypes' is just necessary to be a subset of 'pps'.
DP-GEN Version
Version: 0.13.2.dev62+g037d6b819
Platform, Python Version, Remote Platform, etc
No response
Input Files, Running Commands, Error Log, etc.
'param.json'