Skip to content

Fix issue #270 - #271

Merged
lohedges merged 2 commits into
develfrom
fix_270
Nov 4, 2026
Merged

lohedges merged 2 commits into
develfrom
fix_270

Conversation

@lohedges

@lohedges lohedges commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Closes #270.

When perturbed_system is used to seed replicas, its box is copied to the replicas closest to the perturbed end state. Until now the only check against the reference system was the atom count. If the two end states were equilibrated with NPT, their boxes differ, so for GCMC in the NVT ensemble the replicas would start with different volumes.

This PR raises an error in _check_inputs when all of the following hold:

  • replica exchange is on
  • a perturbed_system is given
  • gcmc is enabled
  • pressure is None
  • the two boxes differ

Boxes are compared by type and by their vectors (dimensions() for PeriodicBox, vector0/1/2() for TriclinicBox) with a relative tolerance of 1e-5, so a box with the same volume but a different shape is also caught. The error message suggests rescaling the perturbed system to the reference box, or setting a pressure to run in the osmotic ensemble.

GCMC in the osmotic ensemble (with a pressure set) is unaffected.

Tests

test_perturbed_system_box_gcmc covers four cases:

Pressure Perturbed box Expected
None same box passes
None larger box raises
None same volume, different shape raises
1 atm larger box passes

The check runs before any GPU setup, so the test runs on CPU. It's skipped on macOS, where GCMC isn't supported.

@lohedges lohedges added the bug Something isn't working label Nov 4, 2026
@lohedges
lohedges merged commit 5ecbe40 into devel Nov 4, 2026
4 checks passed
@lohedges
lohedges deleted the fix_270 branch November 4, 2026 15:50
This was referenced Nov 4, 2026

This branch was previously deployed

1 inactive deployment
somd2-build — 639f83a3 Deployed Nov 4, 2026 by lohedges via build (3.12, linux) #139
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Check that the perturbed system's box matches the reference for NVT GCMC

1 participant