Skip to content

fix(vasp): interpret negative POSCAR scale as volume#1019

Open
njzjz-bot wants to merge 1 commit into
deepmodeling:masterfrom
njzjz-bot:fix/issue-993
Open

fix(vasp): interpret negative POSCAR scale as volume#1019
njzjz-bot wants to merge 1 commit into
deepmodeling:masterfrom
njzjz-bot:fix/issue-993

Conversation

@njzjz-bot

Copy link
Copy Markdown
Contributor

Fixes #993.

Convert negative POSCAR scale factors from target volume to a positive linear factor while preserving positive-scale behavior.

Tests: cd tests && python -m unittest test_vasp_poscar_to_system.TestVaspNegativeScale

Why existing tests missed it: All previous POSCAR fixtures used positive scale factors, so the VASP volume convention was untested.

Coding agent: Codex
Codex version: codex-cli 0.144.4
Model: gpt-5.6-sol
Reasoning effort: xhigh

Convert negative POSCAR scale factors to a positive linear factor that realizes the requested cell volume, while retaining direct multiplier behavior for positive scales. Add a regression for volume and Cartesian coordinate scaling; the previous fixtures only used positive factors.

Coding-Agent: Codex
Codex-Version: codex-cli 0.144.4
Model: gpt-5.6-sol
Reasoning-Effort: xhigh
@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. dpdata vasp labels Jul 16, 2026
@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@njzjz-bot, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 59 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: dfa8b4d3-179d-4267-8ee0-89e576f2d448

📥 Commits

Reviewing files that changed from the base of the PR and between 0416b54 and 4b71fbe.

📒 Files selected for processing (2)
  • dpdata/formats/vasp/poscar.py
  • tests/test_vasp_poscar_to_system.py

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.

@codspeed-hq

codspeed-hq Bot commented Jul 16, 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 njzjz-bot:fix/issue-993 (4b71fbe) with master (0416b54)

Open in CodSpeed

@codecov

codecov Bot commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.71429% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 86.87%. Comparing base (0416b54) to head (4b71fbe).

Files with missing lines Patch % Lines
dpdata/formats/vasp/poscar.py 85.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1019      +/-   ##
==========================================
- Coverage   86.87%   86.87%   -0.01%     
==========================================
  Files          89       89              
  Lines        8266     8273       +7     
==========================================
+ Hits         7181     7187       +6     
- Misses       1085     1086       +1     

☔ 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.

@wanghan-iapcm wanghan-iapcm 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.

The negative-scale-as-volume fix is correct and matches the algorithm in #993. One follow-up: codecov/patch is red because the added test exercises only the Direct-coordinates path — see the inline note for the Cartesian case worth adding.



class TestVaspNegativeScale(unittest.TestCase):
def test_negative_scale_is_target_volume(self):

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.

The fix itself is correct, but codecov/patch is red because this test only covers the Direct-coordinates path. Under a Direct POSCAR the derived scale never touches the coordinates (they go through matmul with the already-scaled cell), so the Cartesian negative-scale path — which issue #993 explicitly emphasized — and the raw_volume == 0 guard are both unexercised. Could you add a Cartesian variant (a C/Cartesian POSCAR with a negative scale) asserting the coords are multiplied by (|scale| / V_raw) ** (1/3)? That closes the coverage gap the patch check is flagging.

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

Labels

dpdata size:S This PR changes 10-29 lines, ignoring generated files. vasp

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Code scan] VASP POSCAR negative scale factor is interpreted as a direct multiplier

2 participants