Skip to content

fix(dpdata): read newer CP2K output with dpdata's cp2k/output parser - #23

Open
ChiahsinChu wants to merge 1 commit into
chenggroup:mainfrom
ChiahsinChu:fix/cp2k-2025-output
Open

ChiahsinChu wants to merge 1 commit into
chenggroup:mainfrom
ChiahsinChu:fix/cp2k-2025-output

Conversation

@ChiahsinChu

Copy link
Copy Markdown
Contributor

Problem

ai2-kit tool dpdata read <out> --fmt cp2k/output fails on CP2K 2025.2 ENERGY_FORCE output:

TypeError: unsupported operand type(s) for *: 'NoneType' and 'float'
  File ".../cp2kdata/dpdata_plugin.py", line 64, in from_labeled_system

The format name is taken over by another package. cp2kdata's dpdata plugin (0.7.3, the latest release) registers its own parser under cp2k/output (and cp2k/aimd_output), which overrides dpdata's built-in parser whenever cp2kdata is installed. cp2kdata cannot read the newer output layout (ENERGY| ... energy [hartree], FORCES| block), so it returns None for the energy.

dpdata's built-in parser handles this layout from dpdata 1.1.0 (deepmodeling/dpdata#978). ai2-kit, however, pins dpdata = "0.2.18", which also fails on it (cannot find forces).

Change

  • ai2_kit/tool/dpdata.py: register_data_types() now re-registers dpdata's CP2KOutputFormat under cp2k/output. Every cp2k/output call site goes through this function, either through ai2_kit.tool.dpdata or through domain/deepmd.py. cp2k/aimd_output is left with cp2kdata.
  • pyproject.toml: require dpdata >= 1.1.0 on Python >= 3.10. Python 3.9 stays on 0.2.18, because dpdata 1.1.0 requires Python >= 3.10.
  • poetry.lock: regenerated with poetry lock --no-update (Poetry 1.8.3). This also picks up oh-my-batch 0.7.6, which pyproject.toml already requires (>=0.7.0) but the old lock still had at 0.6.1. The per-package ustc source entries are gone because packages now resolve from the primary PyPI source.

Is anything lost by not using cp2kdata for cp2k/output?

I compared both parsers on dpdata's CP2K test outputs (CP2K 6.1, 7.1 and a synthetic 2025.1) and on a CP2K 2022.1 output. On every file cp2kdata can read, energies, forces, coordinates, cells, virials and atom names are identical. Two differences remain:

Testing

In a Python 3.11 env with dpdata 1.1.0 and cp2kdata 0.7.3 installed:

  • ai2-kit tool dpdata read cp2k.2025.2.out --fmt cp2k/output - write out now works: 906 atoms, E = −262255.859 eV. It matches an independent ASE-based parser to 2.5e-8 eV/Å in forces. A CP2K 2022.1 output parses as before.
  • tests/test_data.py and tests/test_dplr.py: test_dpdata_to_ase now passes (it failed before under cp2kdata). The two TestDPFFDPData failures come from deepmd not being installed and happen on main too.
  • poetry check --lock: OK.

🤖 Generated with Claude Code

`tool dpdata read --fmt cp2k/output` failed on CP2K 2025 ENERGY_FORCE
output with "unsupported operand type(s) for *: 'NoneType' and 'float'".
cp2kdata's dpdata plugin re-registers "cp2k/output" and its parser
cannot read the new layout (ENERGY| ... [hartree], FORCES| block).
dpdata >= 1.1.0's built-in parser handles it, so re-register it in
register_data_types(), which every cp2k/output call site runs through.
Outputs match the previous cp2kdata parser on older CP2K versions.

Require dpdata >= 1.1.0 on python >= 3.10 (keep 0.2.18 on 3.9, which
dpdata 1.1.0 no longer supports) and regenerate poetry.lock. The lock
also picks up oh-my-batch 0.7.6, already required by pyproject.toml.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

1 participant