support to read coord/cell from STRU_ION*_D in abacus/relax#957
support to read coord/cell from STRU_ION*_D in abacus/relax#957pxlxingliang wants to merge 6 commits intodeepmodeling:masterfrom
Conversation
for more information, see https://pre-commit.ci
Merging this PR will not alter performance
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdds STRU_ION*_D discovery and parsing to the ABACUS relax reader so intermediate relaxation snapshots (coordinates/cells) are incorporated into frames; updates coordinate conversion to angstroms, expands NaN pruning, and adds a test fixture and unit test validating multi-frame reads. Changes
Sequence Diagram(s)sequenceDiagram
participant Reader as LabeledSystem.get_frame
participant LogParser as get_coords_from_log
participant FS as Filesystem
participant STRUParser as STRU reader (get_relax_stru_files / STRU_ION*_D)
Reader->>FS: locate ABACUS output dir
Reader->>STRUParser: get_relax_stru_files(output_dir)
STRUParser-->>Reader: list of STRU_ION*_D paths
Reader->>FS: read log file lines
Reader->>LogParser: get_coords_from_log(loglines, natoms, stru_files)
LogParser->>STRUParser: open STRU_ION*_D as needed
STRUParser-->>LogParser: coordinates / cells for missing frames
LogParser-->>Reader: frames with energies, coords, cells, forces, stress (with bohr→Å applied)
Reader->>Reader: prune NaN frames and assemble LabeledSystem
(Note: colored rectangles not required for simple flow.) Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
tests/test_abacus_relax.py (1)
198-200: Please remove commented-out artifact generation code.This is test-debug residue and can be dropped to keep the suite clean.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/test_abacus_relax.py` around lines 198 - 200, Remove the commented-out test artifact generation block (the np.save loop) so the test no longer contains leftover debug code; specifically delete the commented lines that iterate over the keys list ["energies", "cells", "coords", "forces", "stress", "virials"] and call np.save with self.system.data (the commented np.save(...) lines), leaving only the functional test code intact.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@dpdata/abacus/relax.py`:
- Around line 134-138: get_frame_from_stru returns coordinates/cells in Angstrom
but later code multiplies all frames by bohr2ang, causing STRU-derived frames to
be double-scaled; modify the block that assigns stru-derived data (where
coords[iframe] and cells[iframe] are set from get_frame_from_stru) to normalize
those values back to Bohr (divide by bohr2ang) so the later common conversion is
correct; reference get_frame_from_stru, coords, cells, bohr2ang, stru_files,
stru_file_name, and iframe when locating the change.
- Line 51: Replace the mutable default argument in get_coords_from_log: change
the signature from stru_files=[] to stru_files=None and inside the function set
stru_files = [] if stru_files is None; update any downstream logic that assumes
stru_files is a list to use the initialized local list to avoid shared-state
bugs caused by the original mutable default.
---
Nitpick comments:
In `@tests/test_abacus_relax.py`:
- Around line 198-200: Remove the commented-out test artifact generation block
(the np.save loop) so the test no longer contains leftover debug code;
specifically delete the commented lines that iterate over the keys list
["energies", "cells", "coords", "forces", "stress", "virials"] and call np.save
with self.system.data (the commented np.save(...) lines), leaving only the
functional test code intact.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 3ee3a62b-cd30-4386-a867-f3e832e6c647
⛔ Files ignored due to path filters (1)
tests/abacus.relax.readFromSTRUIOND/OUT.ABACUS/running_cell-relax.logis excluded by!**/*.log
📒 Files selected for processing (17)
dpdata/abacus/relax.pytests/abacus.relax.readFromSTRUIOND/INPUTtests/abacus.relax.readFromSTRUIOND/KPTtests/abacus.relax.readFromSTRUIOND/OUT.ABACUS/STRU_ION1_Dtests/abacus.relax.readFromSTRUIOND/OUT.ABACUS/STRU_ION2_Dtests/abacus.relax.readFromSTRUIOND/OUT.ABACUS/STRU_ION3_Dtests/abacus.relax.readFromSTRUIOND/OUT.ABACUS/STRU_ION4_Dtests/abacus.relax.readFromSTRUIOND/OUT.ABACUS/STRU_ION5_Dtests/abacus.relax.readFromSTRUIOND/OUT.ABACUS/STRU_ION_Dtests/abacus.relax.readFromSTRUIOND/STRUtests/abacus.relax.readFromSTRUIOND/cells.npytests/abacus.relax.readFromSTRUIOND/coords.npytests/abacus.relax.readFromSTRUIOND/energies.npytests/abacus.relax.readFromSTRUIOND/forces.npytests/abacus.relax.readFromSTRUIOND/stress.npytests/abacus.relax.readFromSTRUIOND/virials.npytests/test_abacus_relax.py
fix #951
Summary by CodeRabbit
New Features
Bug Fixes
Tests