Skip to content

Fix stress normalization for left-handed cells - #818

Merged
stefaanhessmann merged 1 commit into
atomistic-machine-learning:masterfrom
davrens101:fix/stress-cell-handedness-round12
Nov 9, 2026
Merged

stefaanhessmann merged 1 commit into
atomistic-machine-learning:masterfrom
davrens101:fix/stress-cell-handedness-round12

Conversation

@davrens101

Copy link
Copy Markdown
Contributor

Problem

Both Forces and Response divide stress by the signed cell volume. Swapping two lattice basis vectors leaves the physical lattice and model energy unchanged, but reverses the reported stress.

Change

Normalize by the absolute physical volume in both response paths. The energy, force, API and checkpoint formats are unchanged. Existing docstrings clarify the volume convention.

Verification

  • A deterministic harmonic-pair regression checks both response APIs against independent analytic forces and stresses in a mixed-handedness batch with unequal cell volumes. Both new cases fail on the base and pass with this change.
  • python -m pytest tests/atomistic -q --tb=short: 15 passed, with four existing ASE/NumPy deprecation warnings.
  • Actual PaiNN + Strain + AtomsConverter on periodic H2, with two lattice rows exchanged: energy remains unchanged; stress now agrees across handedness. Maximum error against all-nine-component central energy/strain differences improves from 9.86e-5 to 2.43e-14 in both response APIs.
  • Changed-file Ruff lint and format checks pass. Independent read-only AI source/test review found no blocking issue.

Verified on Windows CPU, Python 3.12.10 / Torch 2.14.1. No GPU, full-repository, or scientific-accuracy benchmark claim. Stress-dependent results for left-handed cells intentionally change and should be reevaluated.

AI-assisted implementation and numerical validation. The submitting user confirmed reviewing the changes before submission; this is not maintainer approval.

@stefaanhessmann

Copy link
Copy Markdown
Collaborator

Hi @davrens101,
thanks for the fix!

@stefaanhessmann
stefaanhessmann merged commit 69d26f3 into atomistic-machine-learning:master Nov 9, 2026
4 checks passed
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.

2 participants