Fix rescaling of non-cubic boxes - #5337
Merged
jngrad merged 3 commits intoAug 27, 2026
Merged
Conversation
…tors
change_volume_and_rescale_particles("xyz") computed a single scalar scale
from the x-axis (length * length_inv()[0]) and applied it to all three
particle coordinates, silently corrupting y/z positions on any non-cubic
box. The cubic-box assert was compiled out under NDEBUG.
Fix: for coord==3, store the old per-axis lengths, apply shrinking axes
before the box resize and growing axes after, each with its own
length/old_lengths[axis] scale factor.
Also remove the now-unnecessary cubic-box assert for coord==3.
Regression test added to testsuite/python/system.py: non-cubic
[10,20,30] → [5,5,5] rescale verifies each coordinate scales by its
own new/old ratio.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
Author
|
Bug is genuine IMO. Test case needs fixing. |
jngrad
marked this pull request as ready for review
August 27, 2026 19:24
jngrad
approved these changes
Aug 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
change_volume_and_rescale_particles("xyz")computed a single scalar scalefrom the x-axis (
length * length_inv()[0]) and applied it to all threeparticle coordinates, silently corrupting y/z positions on any non-cubic
box. The cubic-box assert was compiled out under NDEBUG.
Fix: for
coord==3, capture old per-axis lengths, apply shrinking axesbefore the box resize and growing axes after, each with its own
length/old_lengths[axis]scale factor(
src/script_interface/system/System.cpp). Also removes the now-vacuouscubic-box assert.
Regression test:
test_isotropic_rescale_noncubic_boxadded toTestin
testsuite/python/system.py.Fixes bug #16 of the adversarial bug sweep.