fix(ase): symmetrize reshaped virial stress#5799
Conversation
Reshape the nine-component virial before transposing and project it onto ASE symmetric Cauchy stress while preserving the original virial matrix. Add a backend-independent asymmetric mock regression for the Voigt shear components. Coding-Agent: Codex Codex-Version: codex-cli 0.144.1 Model: gpt-5.6-sol Reasoning-Effort: xhigh
|
Warning Review limit reached
Next review available in: 22 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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 configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
Summary
results["virial"]Root cause and fix
The calculator stored
v[0].reshape(3, 3)as the virial, but formed stress from:v[0]is one-dimensional with shape(9,), and transposing a one-dimensional NumPy array is a no-op. The calculation therefore selected only one side of each off-diagonal pair when converting to ASE Voigt order.The code now names the reshaped
3 x 3virial, preserves it unchanged in the results dictionary, and computes:This matches ASE's symmetric stress convention and retains tensile-positive sign handling. It does not hide the original virial: callers can still inspect any antisymmetric component through
results["virial"].Why existing tests missed this
Standard conservative DeePMD models normally return a total virial that is already symmetric up to floating-point noise. Existing calculator integration tests use such real model output and mainly check permutation consistency, so the ineffective transpose was numerically invisible.
The new lightweight regression mocks the model with the intentionally asymmetric virial:
For volume 8, the correct ASE Voigt shear entries are based on averages
yz=7,xz=5, andxy=3. The previous implementation deterministically returned the single-sided values6,3, and2; the fixed implementation returns the expected symmetric values and leaves the stored virial unchanged.Validation
ruff format --check .ruff check .git diff --checkCloses #5689.
Coding agent: Codex
Codex version: codex-cli 0.144.1
Model: gpt-5.6-sol
Reasoning effort: xhigh