Skip to content

fix: Filter SIESTA pseudopotentials by system atom types - #1861

Draft
njzjz with Copilot wants to merge 3 commits into
masterfrom
copilot/fix-assertion-error-siestafiles
Draft

fix: Filter SIESTA pseudopotentials by system atom types#1861
njzjz with Copilot wants to merge 3 commits into
masterfrom
copilot/fix-assertion-error-siestafiles

Conversation

Copilot AI commented Feb 13, 2026

Copy link
Copy Markdown
Contributor

SIESTA input generation failed with AssertionError when systems contained a subset of elements from fp_pp_files (e.g., pure C systems when both C.psf and H.psf were provided).

Changes

  • dpgen/generator/run.py: Filter fp_pp_files to match system atom types before passing to make_siesta_input, following PWSCF pattern:

    pps = []
    for iii in sys_data["atom_names"]:
        pps.append(fp_pp_files[jdata["type_map"].index(iii)])
    ret = make_siesta_input(sys_data, pps, fp_params)
  • dpgen/tools/relabel.py: Apply same filtering in make_siesta helper and fix parameter passing

  • tests/generator/test_make_fp.py: Add TestMakeFPSIESTASubsetElements to validate subset element handling

The assertion assert ntypes == len(pps) in _make_siesta_02_species now 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:

INFO:dpgen:-------------------------iter.000015 task 06--------------------------
INFO:dpgen:system 015 candidate :      1 in     11   9.09 %
INFO:dpgen:system 015 failed    :     10 in     11  90.91 %
INFO:dpgen:system 015 accurate  :      0 in     11   0.00 %
INFO:dpgen:system 015 accurate_ratio:   0.0000    thresholds: 1.0000 and 1.0000   eff. task min and max   -1   20   number of fp tasks:      1
Traceback (most recent call last):
  File "/home/ubuntu/miniconda3/envs/dpgen/bin/dpgen", line 7, in <module>
    sys.exit(main())
  File "/home/ubuntu/miniconda3/envs/dpgen/lib/python3.10/site-packages/dpgen/main.py", line 255, in main
    args.func(args)
  File "/home/ubuntu/miniconda3/envs/dpgen/lib/python3.10/site-packages/dpgen/generator/run.py", line 5721, in gen_run
    run_iter(args.PARAM, args.MACHINE)
  File "/home/ubuntu/miniconda3/envs/dpgen/lib/python3.10/site-packages/dpgen/generator/run.py", line 5070, in run_iter
    make_fp(ii, jdata, mdata)
  File "/home/ubuntu/miniconda3/envs/dpgen/lib/python3.10/site-packages/dpgen/generator/run.py", line 4011, in make_fp
    make_fp_calculation(iter_index, jdata, mdata)
  File "/home/ubuntu/miniconda3/envs/dpgen/lib/python3.10/site-packages/dpgen/generator/run.py", line 4034, in make_fp_calculation
    make_fp_siesta(iter_index, jdata)
  File "/home/ubuntu/miniconda3/envs/dpgen/lib/python3.10/site-packages/dpgen/generator/run.py", line 3723, in make_fp_siesta
    ret = make_siesta_input(sys_data, fp_pp_files, fp_params)
  File "/home/ubuntu/miniconda3/envs/dpgen/lib/python3.10/site-packages/dpgen/generator/lib/siesta.py", line 137, in make_siesta_input
    ret += _make_siesta_02_species(sys_data, fp_pp_files)
  File "/home/ubuntu/miniconda3/envs/dpgen/lib/python3.10/site-packages/dpgen/generator/lib/siesta.py", line 50, in _make_siesta_02_species
    assert ntypes == len(pps)
AssertionError

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'

{
     "type_map": ["C","H"],
     "mass_map": [12,1],
     "init_data_prefix": "../init/deepmd_data",
     "init_data_sys": [
  "C110H0", "C112H0", "C123H3", "C126H0", "C128H0",
  "C55H3", "C62H0", "C64H0", "C71H3", "C82H0",
  "C84H0", "C87H3", "C111H3", "C122H0", "C124H0",
  "C127H3", "C54H0", "C56H0", "C63H3", "C70H0",
  "C72H0", "C83H3", "C86H0", "C88H0"
],
     "sys_configs_prefix": "/home/ubuntu/run/CNT_single_1560/init",
     "sys_configs": [
  ["POSCARS_OUT/1000k/6_6/5775/POSCAR"],
  ["POSCARS_OUT/1000k/6_6/DV/POSCAR"],
  ["POSCARS_OUT/1000k/6_6/MVH/POSCAR"],
  ["POSCARS_OUT/1000k/6_6/P/POSCAR"],
  ["POSCARS_OUT/1000k/7_1/5775/POSCAR"],
  ["POSCARS_OUT/1000k/7_1/DV/POSCAR"],
  ["POSCARS_OUT/1000k/7_1/MVH/POSCAR"],
  ["POSCARS_OUT/1000k/7_1/P/POSCAR"],
  ["POSCARS_OUT/1000k/9_0/5775/POSCAR"],
  ["POSCARS_OUT/1000k/9_0/DV/POSCAR"],
  ["POSCARS_OUT/1000k/9_0/MVH/POSCAR"],
  ["POSCARS_OUT/1000k/9_0/P/POSCAR"],
  ["POSCARS_OUT/300k/6_6/5775/POSCAR"],
  ["POSCARS_OUT/300k/6_6/DV/POSCAR"],
  ["POSCARS_OUT/300k/6_6/MVH/POSCAR"],
  ["POSCARS_OUT/300k/6_6/P/POSCAR"],
  ["POSCARS_OUT/300k/7_1/5775/POSCAR"],
  ["POSCARS_OUT/300k/7_1/DV/POSCAR"],
  ["POSCARS_OUT/300k/7_1/MVH/POSCAR"],
  ["POSCARS_OUT/300k/7_1/P/POSCAR"],
  ["POSCARS_OUT/300k/9_0/5775/POSCAR"],
  ["POSCARS_OUT/300k/9_0/DV/POSCAR"],
  ["POSCARS_OUT/300k/9_0/MVH/POSCAR"],
  ["POSCARS_OUT/300k/9_0/P/POSCAR"],
  ["POSCARS_OUT/50k/6_6/5775/POSCAR"],
  ["POSCARS_OUT/50k/6_6/DV/POSCAR"],
  ["POSCARS_OUT/50k/6_6/MVH/POSCAR"],
  ["POSCARS_OUT/50k/6_6/P/POSCAR"],
  ["POSCARS_OUT/50k/7_1/5775/POSCAR"],
  ["POSCARS_OUT/50k/7_1/DV/POSCAR"],
  ["POSCARS_OUT/50k/7_1/MVH/POSCAR"],
  ["POSCARS_OUT/50k/7_1/P/POSCAR"],
  ["POSCARS_OUT/50k/9_0/5775/POSCAR"],
  ["POSCARS_OUT/50k/9_0/DV/POSCAR"],
  ["POSCARS_OUT/50k/9_0/MVH/POSCAR"],
  ["POSCARS_OUT/50k/9_0/P/POSCAR"],
  ["POSCARS_OUT/700k/6_6/5775/POSCAR"],
  ["POSCARS_OUT/700k/6_6/DV/POSCAR"],
  ["POSCARS_OUT/700k/6_6/MVH/POSCAR"],
  ["POSCARS_OUT/700k/6_6/P/POSCAR"],
  ["POSCARS_OUT/700k/7_1/5775/POSCAR"],
  ["POSCARS_OUT/700k/7_1/DV/POSCAR"],
  ["POSCARS_OUT/700k/7_1/MVH/POSCAR"],
  ["POSCARS_OUT/700k/7_1/P/POSCAR"],
  ["POSCARS_OUT/700k/9_0/5775/POSCAR"],
  ["POSCARS_OUT/700k/9_0/DV/POSCAR"],
  ["POSCARS_OUT/700k/9_0/MVH/POSCAR"],
  ["POSC...

</details>



<!-- START COPILOT CODING AGENT SUFFIX -->

- Fixes deepmodeling/dpgen#1859

<!-- START COPILOT CODING AGENT TIPS -->
---

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs.

Copilot AI and others added 2 commits February 13, 2026 10:58
Co-authored-by: njzjz <9496702+njzjz@users.noreply.github.com>
Co-authored-by: njzjz <9496702+njzjz@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix unnecessary assertion in Siesta input file generation fix: Filter SIESTA pseudopotentials by system atom types Feb 13, 2026
Copilot AI requested a review from njzjz February 13, 2026 11:05

@njzjz-bot njzjz-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread dpgen/tools/relabel.py
)
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)

@njzjz-bot njzjz-bot Aug 10, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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:

Suggested change
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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants