Skip to content

fix(abacus): transform forces for left-handed SCF cells - #1065

Open
SchrodingersCattt wants to merge 1 commit into
deepmodeling:masterfrom
SchrodingersCattt:fix/abacus-scf-left-handed
Open

SchrodingersCattt wants to merge 1 commit into
deepmodeling:masterfrom
SchrodingersCattt:fix/abacus-scf-left-handed

Conversation

@SchrodingersCattt

@SchrodingersCattt SchrodingersCattt commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1061.

ABACUS normalizes left-handed STRU cells by reflecting the cell and Cartesian coordinates. Propagate that reflection to SCF force vectors so coordinates and forces remain in the same spatial representation. Add a regression test covering a left-handed cell with nonzero forces.

Tests: ABACUS test suite and ruff checks pass.

Summary by CodeRabbit

  • Bug Fixes
    • Corrected force handling when reading ABACUS results that use a left-handed cell. Forces now stay consistent with the corrected cell orientation, avoiding sign errors in parsed data.
    • Results with right-handed cells are unaffected, and files without force data continue to be read without changes.

@codspeed

codspeed Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

✅ 2 untouched benchmarks


Comparing SchrodingersCattt:fix/abacus-scf-left-handed (f116b43) with master (520a909)

Open in CodSpeed

@codecov

codecov Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.09%. Comparing base (520a909) to head (f116b43).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1065   +/-   ##
=======================================
  Coverage   88.08%   88.09%           
=======================================
  Files          91       91           
  Lines        9685     9690    +5     
=======================================
+ Hits         8531     8536    +5     
  Misses       1154     1154           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@coderabbitai

coderabbitai Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ba10e785-d0f7-4ef1-bd21-8cc08e38321b

📥 Commits

Reviewing files that changed from the base of the PR and between f3f354c and f116b43.


You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ac34b71a-b403-4783-854b-e31f166c62e2

📥 Commits

Reviewing files that changed from the base of the PR and between 520a909 and f3f354c.


📒 Files selected for processing (3)
  • dpdata/formats/abacus/scf.py
  • dpdata/formats/abacus/stru.py
  • tests/test_abacus_pw_scf.py

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.



📝 Walkthrough

Walkthrough

The STRU reader can report when it reflects a left-handed cell. The SCF reader uses that flag to negate collected forces. A regression test checks the parsed coordinates and forces.

Changes

ABACUS SCF force transformation

Layer / File(s) Summary
Expose the cell reflection flag
dpdata/formats/abacus/stru.py
get_frame_from_stru records whether the cell has a negative determinant. It can return the parsed data with that flag, while its default return remains data-only.
Apply the reflection to SCF forces
dpdata/formats/abacus/scf.py, tests/test_abacus_pw_scf.py
When the structure reader reports a flipped cell, get_frame negates collected forces. The regression test checks the parsed coordinates and forces against the methane reference.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: pxlxingliang


Merge Risk: ⚪ Minimal · up to f3f35

The force transformation matches the coordinate correction for left-handed cells, so no material merge-blocking risk is identified.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: transforming forces for left-handed ABACUS SCF cells.
Linked Issues check Passed Issue #1061 requires force transformation when ABACUS applies the left-handed-cell correction. The PR records whether get_frame_from_stru flips the cell and negates available SCF forces in `get_fram…
Out of Scope Changes check Passed The changes are limited to the STRU flip-status propagation, conditional SCF force negation, and a regression test. These changes directly support issue #1061. No unrelated behavior or files are ident…


✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR


  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@SchrodingersCattt
SchrodingersCattt force-pushed the fix/abacus-scf-left-handed branch from f3f354c to f116b43 Compare October 9, 2026 16:18

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.

[BUG] ABACUS SCF reader inverts coordinates for left-handed cells without transforming forces

1 participant